mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:45:31 +00:00
Merge branch 'z-up' into graphics
Conflicts: apps/openmw/mwrender/localmap.cpp apps/openmw/mwrender/renderingmanager.cpp apps/openmw/mwrender/water.cpp files/materials/water.shader
This commit is contained in:
commit
d4264353a3
25 changed files with 158 additions and 175 deletions
|
@ -88,7 +88,7 @@ void LocalMapBase::applyFogOfWar()
|
||||||
+ boost::lexical_cast<std::string>(my);
|
+ boost::lexical_cast<std::string>(my);
|
||||||
|
|
||||||
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(mCurX + (mx-1)) + "_"
|
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(mCurX + (mx-1)) + "_"
|
||||||
+ boost::lexical_cast<std::string>(mCurY + (mInterior ? (my-1) : -1*(my-1)));
|
+ boost::lexical_cast<std::string>(mCurY + (-1*(my-1)));
|
||||||
MyGUI::ImageBox* fog = mFogWidgets[my + 3*mx];
|
MyGUI::ImageBox* fog = mFogWidgets[my + 3*mx];
|
||||||
fog->setImageTexture(mFogOfWar ?
|
fog->setImageTexture(mFogOfWar ?
|
||||||
((MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0) ? image+"_fog"
|
((MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0) ? image+"_fog"
|
||||||
|
@ -127,7 +127,7 @@ void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
||||||
{
|
{
|
||||||
// map
|
// map
|
||||||
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_"
|
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_"
|
||||||
+ boost::lexical_cast<std::string>(y + (interior ? (my-1) : -1*(my-1)));
|
+ boost::lexical_cast<std::string>(y + (-1*(my-1)));
|
||||||
|
|
||||||
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
|
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
|
||||||
+ boost::lexical_cast<std::string>(my);
|
+ boost::lexical_cast<std::string>(my);
|
||||||
|
@ -173,7 +173,7 @@ void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Ogre::Vector2 position (marker.x, -marker.y);
|
Ogre::Vector2 position (marker.x, marker.y);
|
||||||
MWBase::Environment::get().getWorld ()->getInteriorMapPosition (position, nX, nY, cellDx, cellDy);
|
MWBase::Environment::get().getWorld ()->getInteriorMapPosition (position, nX, nY, cellDx, cellDy);
|
||||||
|
|
||||||
widgetCoord = MyGUI::IntCoord(nX * 512 - 4 + (1+cellDx-x) * 512, nY * 512 - 4 + (1+cellDy-y) * 512, 8, 8);
|
widgetCoord = MyGUI::IntCoord(nX * 512 - 4 + (1+cellDx-x) * 512, nY * 512 - 4 + (1+cellDy-y) * 512, 8, 8);
|
||||||
|
@ -394,10 +394,10 @@ void MapWindow::globalMapUpdatePlayer ()
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedPosition ();
|
Ogre::Vector3 pos = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedPosition ();
|
||||||
Ogre::Quaternion orient = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedOrientation ();
|
Ogre::Quaternion orient = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer().getRefData ().getBaseNode ()->_getDerivedOrientation ();
|
||||||
Ogre::Vector2 dir (orient.yAxis ().x, -orient.yAxis().z);
|
Ogre::Vector2 dir (orient.yAxis ().x, orient.yAxis().y);
|
||||||
|
|
||||||
float worldX, worldY;
|
float worldX, worldY;
|
||||||
mGlobalMapRender->worldPosToImageSpace (pos.x, pos.z, worldX, worldY);
|
mGlobalMapRender->worldPosToImageSpace (pos.x, pos.y, worldX, worldY);
|
||||||
worldX *= mGlobalMapRender->getWidth();
|
worldX *= mGlobalMapRender->getWidth();
|
||||||
worldY *= mGlobalMapRender->getHeight();
|
worldY *= mGlobalMapRender->getHeight();
|
||||||
|
|
||||||
|
|
|
@ -89,10 +89,12 @@ namespace MWInput
|
||||||
std::string("false")));
|
std::string("false")));
|
||||||
pl.insert(std::make_pair(std::string("x11_keyboard_grab"),
|
pl.insert(std::make_pair(std::string("x11_keyboard_grab"),
|
||||||
std::string("false")));
|
std::string("false")));
|
||||||
pl.insert(std::make_pair(std::string("XAutoRepeatOn"),
|
|
||||||
std::string("true")));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if defined OIS_LINUX_PLATFORM
|
||||||
|
pl.insert(std::make_pair(std::string("XAutoRepeatOn"),
|
||||||
|
std::string("true")));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
#if defined(__APPLE__) && !defined(__LP64__)
|
||||||
// Give the application window focus to receive input events
|
// Give the application window focus to receive input events
|
||||||
|
|
|
@ -28,8 +28,8 @@ Actors::~Actors()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::setMwRoot(Ogre::SceneNode* root)
|
void Actors::setRootNode(Ogre::SceneNode* root)
|
||||||
{ mMwRoot = root; }
|
{ mRootNode = root; }
|
||||||
|
|
||||||
void Actors::insertBegin(const MWWorld::Ptr &ptr)
|
void Actors::insertBegin(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ void Actors::insertBegin(const MWWorld::Ptr &ptr)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Create the scenenode and put it in the map
|
//Create the scenenode and put it in the map
|
||||||
cellnode = mMwRoot->createChildSceneNode();
|
cellnode = mRootNode->createChildSceneNode();
|
||||||
mCellSceneNodes[ptr.getCell()] = cellnode;
|
mCellSceneNodes[ptr.getCell()] = cellnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void Actors::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
|
||||||
node = celliter->second;
|
node = celliter->second;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node = mMwRoot->createChildSceneNode();
|
node = mRootNode->createChildSceneNode();
|
||||||
mCellSceneNodes[newCell] = node;
|
mCellSceneNodes[newCell] = node;
|
||||||
}
|
}
|
||||||
node->addChild(cur.getRefData().getBaseNode());
|
node->addChild(cur.getRefData().getBaseNode());
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace MWRender
|
||||||
typedef std::map<MWWorld::Ptr,Animation*> PtrAnimationMap;
|
typedef std::map<MWWorld::Ptr,Animation*> PtrAnimationMap;
|
||||||
|
|
||||||
OEngine::Render::OgreRenderer &mRend;
|
OEngine::Render::OgreRenderer &mRend;
|
||||||
Ogre::SceneNode* mMwRoot;
|
Ogre::SceneNode* mRootNode;
|
||||||
|
|
||||||
CellSceneNodeMap mCellSceneNodes;
|
CellSceneNodeMap mCellSceneNodes;
|
||||||
PtrAnimationMap mAllActors;
|
PtrAnimationMap mAllActors;
|
||||||
|
@ -29,7 +29,7 @@ namespace MWRender
|
||||||
Actors(OEngine::Render::OgreRenderer& _rend): mRend(_rend) {}
|
Actors(OEngine::Render::OgreRenderer& _rend): mRend(_rend) {}
|
||||||
~Actors();
|
~Actors();
|
||||||
|
|
||||||
void setMwRoot(Ogre::SceneNode* root);
|
void setRootNode(Ogre::SceneNode* root);
|
||||||
void insertBegin (const MWWorld::Ptr& ptr);
|
void insertBegin (const MWWorld::Ptr& ptr);
|
||||||
void insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv);
|
void insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv);
|
||||||
void insertCreature (const MWWorld::Ptr& ptr);
|
void insertCreature (const MWWorld::Ptr& ptr);
|
||||||
|
|
|
@ -150,9 +150,9 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debugging::Debugging(SceneNode *mwRoot, OEngine::Physic::PhysicEngine *engine) :
|
Debugging::Debugging(SceneNode *root, OEngine::Physic::PhysicEngine *engine) :
|
||||||
mMwRoot(mwRoot), mEngine(engine),
|
mRootNode(root), mEngine(engine),
|
||||||
mSceneMgr(mwRoot->getCreator()),
|
mSceneMgr(root->getCreator()),
|
||||||
mPathgridEnabled(false),
|
mPathgridEnabled(false),
|
||||||
mInteriorPathgridNode(NULL), mPathGridRoot(NULL),
|
mInteriorPathgridNode(NULL), mPathGridRoot(NULL),
|
||||||
mGridMatsCreated(false)
|
mGridMatsCreated(false)
|
||||||
|
@ -208,7 +208,7 @@ void Debugging::togglePathgrid()
|
||||||
createGridMaterials();
|
createGridMaterials();
|
||||||
|
|
||||||
// add path grid meshes to already loaded cells
|
// add path grid meshes to already loaded cells
|
||||||
mPathGridRoot = mMwRoot->createChildSceneNode();
|
mPathGridRoot = mRootNode->createChildSceneNode();
|
||||||
for(CellList::iterator it = mActiveCells.begin(); it != mActiveCells.end(); ++it)
|
for(CellList::iterator it = mActiveCells.begin(); it != mActiveCells.end(); ++it)
|
||||||
{
|
{
|
||||||
enableCellPathgrid(*it);
|
enableCellPathgrid(*it);
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace MWRender
|
||||||
typedef std::vector<MWWorld::CellStore *> CellList;
|
typedef std::vector<MWWorld::CellStore *> CellList;
|
||||||
CellList mActiveCells;
|
CellList mActiveCells;
|
||||||
|
|
||||||
Ogre::SceneNode *mMwRoot;
|
Ogre::SceneNode *mRootNode;
|
||||||
|
|
||||||
Ogre::SceneNode *mPathGridRoot;
|
Ogre::SceneNode *mPathGridRoot;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ namespace MWRender
|
||||||
Ogre::ManualObject *createPathgridLines(const ESM::Pathgrid *pathgrid);
|
Ogre::ManualObject *createPathgridLines(const ESM::Pathgrid *pathgrid);
|
||||||
Ogre::ManualObject *createPathgridPoints(const ESM::Pathgrid *pathgrid);
|
Ogre::ManualObject *createPathgridPoints(const ESM::Pathgrid *pathgrid);
|
||||||
public:
|
public:
|
||||||
Debugging(Ogre::SceneNode* mwRoot, OEngine::Physic::PhysicEngine *engine);
|
Debugging(Ogre::SceneNode* root, OEngine::Physic::PhysicEngine *engine);
|
||||||
~Debugging();
|
~Debugging();
|
||||||
bool toggleRenderMode (int mode);
|
bool toggleRenderMode (int mode);
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
imageX = float(x / 8192.f - mMinX) / (mMaxX - mMinX + 1);
|
imageX = float(x / 8192.f - mMinX) / (mMaxX - mMinX + 1);
|
||||||
|
|
||||||
imageY = 1.f-float(-z / 8192.f - mMinY) / (mMaxY - mMinY + 1);
|
imageY = 1.f-float(z / 8192.f - mMinY) / (mMaxY - mMinY + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalMap::cellTopLeftCornerToImageSpace(int x, int y, float& imageX, float& imageY)
|
void GlobalMap::cellTopLeftCornerToImageSpace(int x, int y, float& imageX, float& imageY)
|
||||||
|
|
|
@ -27,9 +27,6 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManag
|
||||||
|
|
||||||
mCellCamera = mRendering->getScene()->createCamera("CellCamera");
|
mCellCamera = mRendering->getScene()->createCamera("CellCamera");
|
||||||
mCellCamera->setProjectionType(PT_ORTHOGRAPHIC);
|
mCellCamera->setProjectionType(PT_ORTHOGRAPHIC);
|
||||||
// look down -y
|
|
||||||
const float sqrt0pt5 = 0.707106781;
|
|
||||||
mCellCamera->setOrientation(Quaternion(sqrt0pt5, -sqrt0pt5, 0, 0));
|
|
||||||
|
|
||||||
mCameraNode->attachObject(mCellCamera);
|
mCameraNode->attachObject(mCellCamera);
|
||||||
|
|
||||||
|
@ -87,8 +84,8 @@ void LocalMap::saveFogOfWar(MWWorld::Ptr::CellStore* cell)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y);
|
||||||
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z);
|
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().y);
|
||||||
Vector2 length = max-min;
|
Vector2 length = max-min;
|
||||||
|
|
||||||
// divide into segments
|
// divide into segments
|
||||||
|
@ -112,6 +109,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell)
|
||||||
mInterior = false;
|
mInterior = false;
|
||||||
|
|
||||||
mCameraRotNode->setOrientation(Quaternion::IDENTITY);
|
mCameraRotNode->setOrientation(Quaternion::IDENTITY);
|
||||||
|
mCellCamera->setOrientation(Quaternion(Ogre::Math::Cos(Ogre::Degree(0)/2.f), 0, 0, -Ogre::Math::Sin(Ogre::Degree(0)/2.f)));
|
||||||
|
|
||||||
int x = cell->mCell->getGridX();
|
int x = cell->mCell->getGridX();
|
||||||
int y = cell->mCell->getGridY();
|
int y = cell->mCell->getGridY();
|
||||||
|
@ -120,7 +118,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell)
|
||||||
|
|
||||||
mCameraPosNode->setPosition(Vector3(0,0,0));
|
mCameraPosNode->setPosition(Vector3(0,0,0));
|
||||||
|
|
||||||
render((x+0.5)*sSize, (-y-0.5)*sSize, -10000, 10000, sSize, sSize, name);
|
render((x+0.5)*sSize, (y+0.5)*sSize, -10000, 10000, sSize, sSize, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
|
void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
|
||||||
|
@ -129,40 +127,44 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
|
||||||
mInterior = true;
|
mInterior = true;
|
||||||
mBounds = bounds;
|
mBounds = bounds;
|
||||||
|
|
||||||
Vector2 z(mBounds.getMaximum().y, mBounds.getMinimum().y);
|
float zMin = mBounds.getMinimum().z;
|
||||||
|
float zMax = mBounds.getMaximum().z;
|
||||||
|
|
||||||
const Vector2& north = MWBase::Environment::get().getWorld()->getNorthVector(cell);
|
const Vector2& north = MWBase::Environment::get().getWorld()->getNorthVector(cell);
|
||||||
Radian angle(std::atan2(-north.x, -north.y));
|
Radian angle = Ogre::Math::ATan2 (north.x, north.y);
|
||||||
mAngle = angle.valueRadians();
|
mAngle = angle.valueRadians();
|
||||||
mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, Math::Sin(angle/2.f), 0));
|
|
||||||
|
mCellCamera->setOrientation(Quaternion::IDENTITY);
|
||||||
|
mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, 0, -Math::Sin(angle/2.f)));
|
||||||
|
|
||||||
// rotate the cell and merge the rotated corners to the bounding box
|
// rotate the cell and merge the rotated corners to the bounding box
|
||||||
Vector2 _center(bounds.getCenter().x, bounds.getCenter().z);
|
Vector2 _center(bounds.getCenter().x, bounds.getCenter().y);
|
||||||
Vector3 _c1 = bounds.getCorner(AxisAlignedBox::NEAR_LEFT_BOTTOM);
|
Vector3 _c1 = bounds.getCorner(AxisAlignedBox::FAR_LEFT_BOTTOM);
|
||||||
Vector3 _c2 = bounds.getCorner(AxisAlignedBox::FAR_LEFT_BOTTOM);
|
Vector3 _c2 = bounds.getCorner(AxisAlignedBox::FAR_RIGHT_BOTTOM);
|
||||||
Vector3 _c3 = bounds.getCorner(AxisAlignedBox::NEAR_RIGHT_BOTTOM);
|
Vector3 _c3 = bounds.getCorner(AxisAlignedBox::FAR_LEFT_TOP);
|
||||||
Vector3 _c4 = bounds.getCorner(AxisAlignedBox::FAR_RIGHT_BOTTOM);
|
Vector3 _c4 = bounds.getCorner(AxisAlignedBox::FAR_RIGHT_TOP);
|
||||||
Vector2 c1(_c1.x, _c1.z);
|
|
||||||
Vector2 c2(_c2.x, _c2.z);
|
Vector2 c1(_c1.x, _c1.y);
|
||||||
Vector2 c3(_c3.x, _c3.z);
|
Vector2 c2(_c2.x, _c2.y);
|
||||||
Vector2 c4(_c4.x, _c4.z);
|
Vector2 c3(_c3.x, _c3.y);
|
||||||
|
Vector2 c4(_c4.x, _c4.y);
|
||||||
c1 = rotatePoint(c1, _center, mAngle);
|
c1 = rotatePoint(c1, _center, mAngle);
|
||||||
c2 = rotatePoint(c2, _center, mAngle);
|
c2 = rotatePoint(c2, _center, mAngle);
|
||||||
c3 = rotatePoint(c3, _center, mAngle);
|
c3 = rotatePoint(c3, _center, mAngle);
|
||||||
c4 = rotatePoint(c4, _center, mAngle);
|
c4 = rotatePoint(c4, _center, mAngle);
|
||||||
mBounds.merge(Vector3(c1.x, 0, c1.y));
|
mBounds.merge(Vector3(c1.x, c1.y, 0));
|
||||||
mBounds.merge(Vector3(c2.x, 0, c2.y));
|
mBounds.merge(Vector3(c2.x, c2.y, 0));
|
||||||
mBounds.merge(Vector3(c3.x, 0, c3.y));
|
mBounds.merge(Vector3(c3.x, c3.y, 0));
|
||||||
mBounds.merge(Vector3(c4.x, 0, c4.y));
|
mBounds.merge(Vector3(c4.x, c4.y, 0));
|
||||||
|
|
||||||
Vector2 center(mBounds.getCenter().x, mBounds.getCenter().z);
|
Vector2 center(mBounds.getCenter().x, mBounds.getCenter().y);
|
||||||
|
|
||||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y);
|
||||||
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z);
|
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().y);
|
||||||
|
|
||||||
Vector2 length = max-min;
|
Vector2 length = max-min;
|
||||||
|
|
||||||
mCameraPosNode->setPosition(Vector3(center.x, 0, center.y));
|
mCameraPosNode->setPosition(Vector3(center.x, center.y, 0));
|
||||||
|
|
||||||
// divide into segments
|
// divide into segments
|
||||||
const int segsX = std::ceil( length.x / sSize );
|
const int segsX = std::ceil( length.x / sSize );
|
||||||
|
@ -177,7 +179,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
|
||||||
Vector2 start = min + Vector2(sSize*x,sSize*y);
|
Vector2 start = min + Vector2(sSize*x,sSize*y);
|
||||||
Vector2 newcenter = start + 4096;
|
Vector2 newcenter = start + 4096;
|
||||||
|
|
||||||
render(newcenter.x - center.x, newcenter.y - center.y, z.y, z.x, sSize, sSize,
|
render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, sSize, sSize,
|
||||||
cell->mCell->mName + "_" + coordStr(x,y));
|
cell->mCell->mName + "_" + coordStr(x,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,7 @@ void LocalMap::render(const float x, const float y,
|
||||||
mCellCamera->setFarClipDistance(0); // infinite
|
mCellCamera->setFarClipDistance(0); // infinite
|
||||||
|
|
||||||
mCellCamera->setOrthoWindow(xw, yw);
|
mCellCamera->setOrthoWindow(xw, yw);
|
||||||
mCellCamera->setPosition(Vector3(x, zhigh+100000, y));
|
mCameraNode->setPosition(Vector3(x, y, zhigh+100000));
|
||||||
|
|
||||||
// disable fog (only necessary for fixed function, the shader based
|
// disable fog (only necessary for fixed function, the shader based
|
||||||
// materials already do this through local_map material configuration)
|
// materials already do this through local_map material configuration)
|
||||||
|
@ -279,15 +281,15 @@ void LocalMap::render(const float x, const float y,
|
||||||
|
|
||||||
void LocalMap::getInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y)
|
void LocalMap::getInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y)
|
||||||
{
|
{
|
||||||
pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().z), mAngle);
|
pos = rotatePoint(pos, Vector2(mBounds.getCenter().x, mBounds.getCenter().y), mAngle);
|
||||||
|
|
||||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y);
|
||||||
|
|
||||||
x = std::ceil((pos.x - min.x)/sSize)-1;
|
x = std::ceil((pos.x - min.x)/sSize)-1;
|
||||||
y = std::ceil((pos.y - min.y)/sSize)-1;
|
y = std::ceil((pos.y - min.y)/sSize)-1;
|
||||||
|
|
||||||
nX = (pos.x - min.x - sSize*x)/sSize;
|
nX = (pos.x - min.x - sSize*x)/sSize;
|
||||||
nY = (pos.y - min.y - sSize*y)/sSize;
|
nY = 1.0-(pos.y - min.y - sSize*y)/sSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interior)
|
bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interior)
|
||||||
|
@ -318,19 +320,19 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
||||||
int x,y;
|
int x,y;
|
||||||
float u,v;
|
float u,v;
|
||||||
|
|
||||||
Vector2 pos(position.x, position.z);
|
Vector2 pos(position.x, position.y);
|
||||||
|
|
||||||
if (mInterior)
|
if (mInterior)
|
||||||
getInteriorMapPosition(pos, u,v, x,y);
|
getInteriorMapPosition(pos, u,v, x,y);
|
||||||
|
|
||||||
Vector3 playerdirection = mCameraRotNode->convertWorldToLocalOrientation(orientation).zAxis();
|
Vector3 playerdirection = mCameraRotNode->convertWorldToLocalOrientation(orientation).yAxis();
|
||||||
|
|
||||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().y);
|
||||||
|
|
||||||
if (!mInterior)
|
if (!mInterior)
|
||||||
{
|
{
|
||||||
x = std::ceil(pos.x / sSize)-1;
|
x = std::ceil(pos.x / sSize)-1;
|
||||||
y = std::ceil(-pos.y / sSize)-1;
|
y = std::ceil(pos.y / sSize)-1;
|
||||||
mCellX = x;
|
mCellX = x;
|
||||||
mCellY = y;
|
mCellY = y;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +346,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
||||||
if (!mInterior)
|
if (!mInterior)
|
||||||
{
|
{
|
||||||
u = std::abs((pos.x - (sSize*x))/sSize);
|
u = std::abs((pos.x - (sSize*x))/sSize);
|
||||||
v = 1-std::abs((pos.y + (sSize*y))/sSize);
|
v = 1.0-std::abs((pos.y - (sSize*y))/sSize);
|
||||||
texBaseName = "Cell_";
|
texBaseName = "Cell_";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -353,15 +355,13 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->setPlayerPos(u, v);
|
MWBase::Environment::get().getWindowManager()->setPlayerPos(u, v);
|
||||||
MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, -playerdirection.z);
|
MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, playerdirection.y);
|
||||||
|
|
||||||
// explore radius (squared)
|
// explore radius (squared)
|
||||||
const float sqrExploreRadius = (mInterior ? 0.01 : 0.09) * sFogOfWarResolution*sFogOfWarResolution;
|
const float sqrExploreRadius = (mInterior ? 0.01 : 0.09) * sFogOfWarResolution*sFogOfWarResolution;
|
||||||
const float exploreRadius = (mInterior ? 0.1 : 0.3) * sFogOfWarResolution; // explore radius from 0 to sFogOfWarResolution
|
const float exploreRadius = (mInterior ? 0.1 : 0.3) * sFogOfWarResolution; // explore radius from 0 to sFogOfWarResolution
|
||||||
const float exploreRadiusUV = exploreRadius / sFogOfWarResolution; // explore radius from 0 to 1 (UV space)
|
const float exploreRadiusUV = exploreRadius / sFogOfWarResolution; // explore radius from 0 to 1 (UV space)
|
||||||
|
|
||||||
int intExtMult = mInterior ? 1 : -1; // interior and exterior have reversed Y coordinates (interior: top to bottom)
|
|
||||||
|
|
||||||
// change the affected fog of war textures (in a 3x3 grid around the player)
|
// change the affected fog of war textures (in a 3x3 grid around the player)
|
||||||
for (int mx = -1; mx<2; ++mx)
|
for (int mx = -1; mx<2; ++mx)
|
||||||
{
|
{
|
||||||
|
@ -382,7 +382,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
|
||||||
if (!affected)
|
if (!affected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string texName = texBaseName + coordStr(x+mx,y+my*intExtMult);
|
std::string texName = texBaseName + coordStr(x+mx,y+my*-1);
|
||||||
|
|
||||||
TexturePtr tex = TextureManager::getSingleton().getByName(texName+"_fog");
|
TexturePtr tex = TextureManager::getSingleton().getByName(texName+"_fog");
|
||||||
if (!tex.isNull())
|
if (!tex.isNull())
|
||||||
|
|
|
@ -57,14 +57,14 @@ void Objects::clearSceneNode (Ogre::SceneNode *node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Objects::setMwRoot(Ogre::SceneNode* root)
|
void Objects::setRootNode(Ogre::SceneNode* root)
|
||||||
{
|
{
|
||||||
mMwRoot = root;
|
mRootNode = root;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_)
|
void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_)
|
||||||
{
|
{
|
||||||
Ogre::SceneNode* root = mMwRoot;
|
Ogre::SceneNode* root = mRootNode;
|
||||||
Ogre::SceneNode* cellnode;
|
Ogre::SceneNode* cellnode;
|
||||||
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
|
if(mCellSceneNodes.find(ptr.getCell()) == mCellSceneNodes.end())
|
||||||
{
|
{
|
||||||
|
@ -389,9 +389,9 @@ void Objects::enableLights()
|
||||||
std::vector<LightInfo>::iterator it = mLights.begin();
|
std::vector<LightInfo>::iterator it = mLights.begin();
|
||||||
while (it != mLights.end())
|
while (it != mLights.end())
|
||||||
{
|
{
|
||||||
if (mMwRoot->getCreator()->hasLight(it->name))
|
if (mRootNode->getCreator()->hasLight(it->name))
|
||||||
{
|
{
|
||||||
mMwRoot->getCreator()->getLight(it->name)->setVisible(true);
|
mRootNode->getCreator()->getLight(it->name)->setVisible(true);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -404,9 +404,9 @@ void Objects::disableLights()
|
||||||
std::vector<LightInfo>::iterator it = mLights.begin();
|
std::vector<LightInfo>::iterator it = mLights.begin();
|
||||||
while (it != mLights.end())
|
while (it != mLights.end())
|
||||||
{
|
{
|
||||||
if (mMwRoot->getCreator()->hasLight(it->name))
|
if (mRootNode->getCreator()->hasLight(it->name))
|
||||||
{
|
{
|
||||||
mMwRoot->getCreator()->getLight(it->name)->setVisible(false);
|
mRootNode->getCreator()->getLight(it->name)->setVisible(false);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -459,9 +459,9 @@ void Objects::update(const float dt)
|
||||||
std::vector<LightInfo>::iterator it = mLights.begin();
|
std::vector<LightInfo>::iterator it = mLights.begin();
|
||||||
while (it != mLights.end())
|
while (it != mLights.end())
|
||||||
{
|
{
|
||||||
if (mMwRoot->getCreator()->hasLight(it->name))
|
if (mRootNode->getCreator()->hasLight(it->name))
|
||||||
{
|
{
|
||||||
Ogre::Light* light = mMwRoot->getCreator()->getLight(it->name);
|
Ogre::Light* light = mRootNode->getCreator()->getLight(it->name);
|
||||||
|
|
||||||
float brightness;
|
float brightness;
|
||||||
float cycle_time;
|
float cycle_time;
|
||||||
|
@ -549,7 +549,7 @@ void Objects::updateObjectCell(const MWWorld::Ptr &old, const MWWorld::Ptr &cur)
|
||||||
MWWorld::CellStore *newCell = cur.getCell();
|
MWWorld::CellStore *newCell = cur.getCell();
|
||||||
|
|
||||||
if(mCellSceneNodes.find(newCell) == mCellSceneNodes.end()) {
|
if(mCellSceneNodes.find(newCell) == mCellSceneNodes.end()) {
|
||||||
node = mMwRoot->createChildSceneNode();
|
node = mRootNode->createChildSceneNode();
|
||||||
mCellSceneNodes[newCell] = node;
|
mCellSceneNodes[newCell] = node;
|
||||||
} else {
|
} else {
|
||||||
node = mCellSceneNodes[newCell];
|
node = mCellSceneNodes[newCell];
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Objects{
|
||||||
std::map<MWWorld::CellStore *, Ogre::StaticGeometry*> mStaticGeometrySmall;
|
std::map<MWWorld::CellStore *, Ogre::StaticGeometry*> mStaticGeometrySmall;
|
||||||
std::map<MWWorld::CellStore *, Ogre::AxisAlignedBox> mBounds;
|
std::map<MWWorld::CellStore *, Ogre::AxisAlignedBox> mBounds;
|
||||||
std::vector<LightInfo> mLights;
|
std::vector<LightInfo> mLights;
|
||||||
Ogre::SceneNode* mMwRoot;
|
Ogre::SceneNode* mRootNode;
|
||||||
bool mIsStatic;
|
bool mIsStatic;
|
||||||
static int uniqueID;
|
static int uniqueID;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public:
|
||||||
|
|
||||||
void removeCell(MWWorld::CellStore* store);
|
void removeCell(MWWorld::CellStore* store);
|
||||||
void buildStaticGeometry(MWWorld::CellStore &cell);
|
void buildStaticGeometry(MWWorld::CellStore &cell);
|
||||||
void setMwRoot(Ogre::SceneNode* root);
|
void setRootNode(Ogre::SceneNode* root);
|
||||||
|
|
||||||
void rebuildStaticGeometry();
|
void rebuildStaticGeometry();
|
||||||
|
|
||||||
|
|
|
@ -113,11 +113,6 @@ namespace MWRender
|
||||||
Ogre::Vector3 dir = mCamera->getRealDirection();
|
Ogre::Vector3 dir = mCamera->getRealDirection();
|
||||||
Ogre::Vector3 up = mCamera->getRealUp();
|
Ogre::Vector3 up = mCamera->getRealUp();
|
||||||
|
|
||||||
Ogre::Real xch;
|
|
||||||
xch = pos.y, pos.y = -pos.z, pos.z = xch;
|
|
||||||
xch = dir.y, dir.y = -dir.z, dir.z = xch;
|
|
||||||
xch = up.y, up.y = -up.z, up.z = xch;
|
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir, up);
|
MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir, up);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,10 +318,8 @@ namespace MWRender
|
||||||
|
|
||||||
bool Player::getPosition(Ogre::Vector3 &player, Ogre::Vector3 &camera)
|
bool Player::getPosition(Ogre::Vector3 &player, Ogre::Vector3 &camera)
|
||||||
{
|
{
|
||||||
float xch;
|
|
||||||
mCamera->getParentSceneNode ()->needUpdate(true);
|
mCamera->getParentSceneNode ()->needUpdate(true);
|
||||||
camera = mCamera->getRealPosition();
|
camera = mCamera->getRealPosition();
|
||||||
xch = camera.z, camera.z = camera.y, camera.y = -xch;
|
|
||||||
player = mPlayerNode->getPosition();
|
player = mPlayerNode->getPosition();
|
||||||
|
|
||||||
return mFirstPersonView && !mVanity.enabled && !mPreviewMode;
|
return mFirstPersonView && !mVanity.enabled && !mPreviewMode;
|
||||||
|
|
|
@ -76,8 +76,8 @@ namespace MWRender
|
||||||
|
|
||||||
void Refraction::setHeight(float height)
|
void Refraction::setHeight(float height)
|
||||||
{
|
{
|
||||||
mNearClipPlane = Ogre::Plane( -Ogre::Vector3(0,1,0), -(height + 5));
|
mNearClipPlane = Ogre::Plane( -Ogre::Vector3(0,0,1), -(height + 5));
|
||||||
mNearClipPlaneUnderwater = Ogre::Plane( Ogre::Vector3(0,1,0), height - 5);
|
mNearClipPlaneUnderwater = Ogre::Plane( Ogre::Vector3(0,0,1), height - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Refraction::renderQueueStarted (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
|
void Refraction::renderQueueStarted (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
|
||||||
|
|
|
@ -148,26 +148,20 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
||||||
|
|
||||||
applyCompositors();
|
applyCompositors();
|
||||||
|
|
||||||
// Turn the entire scene (represented by the 'root' node) -90
|
|
||||||
// degrees around the x axis. This makes Z go upwards, and Y go into
|
|
||||||
// the screen (when x is to the right.) This is the orientation that
|
|
||||||
// Morrowind uses, and it automagically makes everything work as it
|
|
||||||
// should.
|
|
||||||
SceneNode *rt = mRendering.getScene()->getRootSceneNode();
|
SceneNode *rt = mRendering.getScene()->getRootSceneNode();
|
||||||
mMwRoot = rt->createChildSceneNode("mwRoot");
|
mRootNode = rt;
|
||||||
mMwRoot->pitch(Degree(-90));
|
|
||||||
|
|
||||||
mObjects.setMwRoot(mMwRoot);
|
mObjects.setRootNode(mRootNode);
|
||||||
mActors.setMwRoot(mMwRoot);
|
mActors.setRootNode(mRootNode);
|
||||||
|
|
||||||
Ogre::SceneNode *playerNode = mMwRoot->createChildSceneNode ("player");
|
Ogre::SceneNode *playerNode = mRootNode->createChildSceneNode ("player");
|
||||||
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
|
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
|
||||||
|
|
||||||
mShadows = new Shadows(&mRendering);
|
mShadows = new Shadows(&mRendering);
|
||||||
|
|
||||||
mTerrainManager = new TerrainManager(mRendering.getScene(), this);
|
mTerrainManager = new TerrainManager(mRendering.getScene(), this);
|
||||||
|
|
||||||
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera());
|
mSkyManager = new SkyManager(mRootNode, mRendering.getCamera());
|
||||||
|
|
||||||
mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode());
|
mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode());
|
||||||
|
|
||||||
|
@ -176,7 +170,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
||||||
|
|
||||||
mSun = 0;
|
mSun = 0;
|
||||||
|
|
||||||
mDebugging = new Debugging(mMwRoot, engine);
|
mDebugging = new Debugging(mRootNode, engine);
|
||||||
mLocalMap = new MWRender::LocalMap(&mRendering, this);
|
mLocalMap = new MWRender::LocalMap(&mRendering, this);
|
||||||
|
|
||||||
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
|
||||||
|
@ -330,7 +324,7 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
Ogre::Vector3 orig, dest;
|
Ogre::Vector3 orig, dest;
|
||||||
mPlayer->setCameraDistance();
|
mPlayer->setCameraDistance();
|
||||||
if (!mPlayer->getPosition(orig, dest)) {
|
if (!mPlayer->getPosition(orig, dest)) {
|
||||||
orig.z += mPlayer->getHeight() * mMwRoot->getScale().z;
|
orig.z += mPlayer->getHeight() * mRootNode->getScale().z;
|
||||||
|
|
||||||
btVector3 btOrig(orig.x, orig.y, orig.z);
|
btVector3 btOrig(orig.x, orig.y, orig.z);
|
||||||
btVector3 btDest(dest.x, dest.y, dest.z);
|
btVector3 btDest(dest.x, dest.y, dest.z);
|
||||||
|
@ -374,11 +368,13 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
float *fpos = data.getPosition().pos;
|
float *fpos = data.getPosition().pos;
|
||||||
|
|
||||||
// only for LocalMap::updatePlayer()
|
// only for LocalMap::updatePlayer()
|
||||||
Ogre::Vector3 pos(fpos[0], fpos[2], -fpos[1]);
|
Ogre::Vector3 pos(fpos[0], fpos[1], fpos[2]);
|
||||||
|
|
||||||
Ogre::SceneNode *node = data.getBaseNode();
|
Ogre::SceneNode *node = data.getBaseNode();
|
||||||
|
//Ogre::Quaternion orient =
|
||||||
|
//node->convertLocalToWorldOrientation(node->_getDerivedOrientation());
|
||||||
Ogre::Quaternion orient =
|
Ogre::Quaternion orient =
|
||||||
node->convertLocalToWorldOrientation(node->_getDerivedOrientation());
|
node->_getDerivedOrientation();
|
||||||
|
|
||||||
mLocalMap->updatePlayer(pos, orient);
|
mLocalMap->updatePlayer(pos, orient);
|
||||||
|
|
||||||
|
@ -390,7 +386,7 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
mWater->updateUnderwater(
|
mWater->updateUnderwater(
|
||||||
world->isUnderwater(
|
world->isUnderwater(
|
||||||
world->getPlayer().getPlayer().getCell(),
|
world->getPlayer().getPlayer().getCell(),
|
||||||
Ogre::Vector3(cam.x, -cam.z, cam.y))
|
cam)
|
||||||
);
|
);
|
||||||
|
|
||||||
// MW to ogre coordinates
|
// MW to ogre coordinates
|
||||||
|
@ -643,8 +639,7 @@ void RenderingManager::sunDisable(bool real)
|
||||||
void RenderingManager::setSunDirection(const Ogre::Vector3& direction)
|
void RenderingManager::setSunDirection(const Ogre::Vector3& direction)
|
||||||
{
|
{
|
||||||
// direction * -1 (because 'direction' is camera to sun vector and not sun to camera),
|
// direction * -1 (because 'direction' is camera to sun vector and not sun to camera),
|
||||||
// then convert from MW to ogre coordinates (swap y,z and make y negative)
|
if (mSun) mSun->setDirection(Vector3(-direction.x, -direction.y, -direction.z));
|
||||||
if (mSun) mSun->setDirection(Vector3(-direction.x, -direction.z, direction.y));
|
|
||||||
|
|
||||||
mSkyManager->setSunDirection(direction);
|
mSkyManager->setSunDirection(direction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,10 +232,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
||||||
Ogre::ColourValue mAmbientColor;
|
Ogre::ColourValue mAmbientColor;
|
||||||
Ogre::Light* mSun;
|
Ogre::Light* mSun;
|
||||||
|
|
||||||
/// Root node for all objects added to the scene. This is rotated so
|
Ogre::SceneNode *mRootNode;
|
||||||
/// that the OGRE coordinate system matches that used internally in
|
|
||||||
/// Morrowind.
|
|
||||||
Ogre::SceneNode *mMwRoot;
|
|
||||||
|
|
||||||
OEngine::Physic::PhysicEngine* mPhysicsEngine;
|
OEngine::Physic::PhysicEngine* mPhysicsEngine;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ void BillboardObject::setPosition(const Vector3& pPosition)
|
||||||
Vector3 BillboardObject::getPosition() const
|
Vector3 BillboardObject::getPosition() const
|
||||||
{
|
{
|
||||||
Vector3 p = mNode->_getDerivedPosition() - mNode->getParentSceneNode()->_getDerivedPosition();
|
Vector3 p = mNode->_getDerivedPosition() - mNode->getParentSceneNode()->_getDerivedPosition();
|
||||||
return Vector3(p.x, -p.z, p.y);
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BillboardObject::setVisibilityFlags(int flags)
|
void BillboardObject::setVisibilityFlags(int flags)
|
||||||
|
@ -203,7 +203,7 @@ unsigned int Moon::getPhaseInt() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
SkyManager::SkyManager (SceneNode* root, Camera* pCamera)
|
||||||
: mHour(0.0f)
|
: mHour(0.0f)
|
||||||
, mDay(0)
|
, mDay(0)
|
||||||
, mMonth(0)
|
, mMonth(0)
|
||||||
|
@ -234,9 +234,8 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera)
|
||||||
, mCloudAnimationTimer(0.f)
|
, mCloudAnimationTimer(0.f)
|
||||||
, mMoonRed(false)
|
, mMoonRed(false)
|
||||||
{
|
{
|
||||||
mSceneMgr = pMwRoot->getCreator();
|
mSceneMgr = root->getCreator();
|
||||||
mRootNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
mRootNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
||||||
mRootNode->pitch(Degree(-90)); // convert MW to ogre coordinates
|
|
||||||
mRootNode->setInheritOrientation(false);
|
mRootNode->setInheritOrientation(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +401,6 @@ void SkyManager::update(float duration)
|
||||||
// increase the strength of the sun glare effect depending
|
// increase the strength of the sun glare effect depending
|
||||||
// on how directly the player is looking at the sun
|
// on how directly the player is looking at the sun
|
||||||
Vector3 sun = mSunGlare->getPosition();
|
Vector3 sun = mSunGlare->getPosition();
|
||||||
sun = Vector3(sun.x, sun.z, -sun.y);
|
|
||||||
Vector3 cam = mCamera->getRealDirection();
|
Vector3 cam = mCamera->getRealDirection();
|
||||||
const Degree angle = sun.angleBetween( cam );
|
const Degree angle = sun.angleBetween( cam );
|
||||||
float val = 1- (angle.valueDegrees() / 180.f);
|
float val = 1- (angle.valueDegrees() / 180.f);
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace MWRender
|
||||||
class SkyManager
|
class SkyManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera);
|
SkyManager(Ogre::SceneNode* root, Ogre::Camera* pCamera);
|
||||||
~SkyManager();
|
~SkyManager();
|
||||||
|
|
||||||
void update(float duration);
|
void update(float duration);
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace MWRender
|
||||||
//----------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend) :
|
TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend) :
|
||||||
mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend)
|
mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Y, mLandSize, mWorldSize)), mRendering(rend)
|
||||||
{
|
{
|
||||||
mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
|
mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ namespace MWRender
|
||||||
mTerrainGlobals->setCompositeMapDistance(mWorldSize*2);
|
mTerrainGlobals->setCompositeMapDistance(mWorldSize*2);
|
||||||
|
|
||||||
mTerrainGroup.setOrigin(Vector3(mWorldSize/2,
|
mTerrainGroup.setOrigin(Vector3(mWorldSize/2,
|
||||||
0,
|
mWorldSize/2,
|
||||||
-mWorldSize/2));
|
0));
|
||||||
|
|
||||||
Terrain::ImportData& importSettings = mTerrainGroup.getDefaultImportSettings();
|
Terrain::ImportData& importSettings = mTerrainGroup.getDefaultImportSettings();
|
||||||
|
|
||||||
|
|
|
@ -164,9 +164,9 @@ void PlaneReflection::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
|
||||||
|
|
||||||
void PlaneReflection::setHeight (float height)
|
void PlaneReflection::setHeight (float height)
|
||||||
{
|
{
|
||||||
mWaterPlane = Plane(Ogre::Vector3(0,1,0), height);
|
mWaterPlane = Plane(Ogre::Vector3(0,0,1), height);
|
||||||
mErrorPlane = Plane(Ogre::Vector3(0,1,0), height - 5);
|
mErrorPlane = Plane(Ogre::Vector3(0,0,1), height - 5);
|
||||||
mErrorPlaneUnderwater = Plane(Ogre::Vector3(0,-1,0), -height - 5);
|
mErrorPlaneUnderwater = Plane(Ogre::Vector3(0,0,-1), -height - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaneReflection::setActive (bool active)
|
void PlaneReflection::setActive (bool active)
|
||||||
|
@ -206,9 +206,9 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend, const ESM::Cell* cel
|
||||||
|
|
||||||
mIsUnderwater = false;
|
mIsUnderwater = false;
|
||||||
|
|
||||||
mWaterPlane = Plane(Vector3::UNIT_Y, 0);
|
mWaterPlane = Plane(Vector3::UNIT_Z, 0);
|
||||||
|
|
||||||
MeshManager::getSingleton().createPlane("water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, CELL_SIZE*5, CELL_SIZE * 5, 10, 10, true, 1, 3,3, Vector3::UNIT_Z);
|
MeshManager::getSingleton().createPlane("water", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, mWaterPlane, CELL_SIZE*5, CELL_SIZE * 5, 10, 10, true, 1, 3,3, Vector3::UNIT_Y);
|
||||||
|
|
||||||
mWater = mSceneMgr->createEntity("water");
|
mWater = mSceneMgr->createEntity("water");
|
||||||
mWater->setVisibilityFlags(RV_Water);
|
mWater->setVisibilityFlags(RV_Water);
|
||||||
|
@ -324,14 +324,14 @@ void Water::setHeight(const float height)
|
||||||
{
|
{
|
||||||
mTop = height;
|
mTop = height;
|
||||||
|
|
||||||
mWaterPlane = Plane(Vector3::UNIT_Y, -height);
|
mWaterPlane = Plane(Vector3::UNIT_Z, -height);
|
||||||
|
|
||||||
if (mReflection)
|
if (mReflection)
|
||||||
mReflection->setHeight(height);
|
mReflection->setHeight(height);
|
||||||
if (mRefraction)
|
if (mRefraction)
|
||||||
mRefraction->setHeight(height);
|
mRefraction->setHeight(height);
|
||||||
|
|
||||||
mWaterNode->setPosition(0, height, 0);
|
mWaterNode->setPosition(0, 0, height);
|
||||||
sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(height)));
|
sh::Factory::getInstance ().setSharedParameter ("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ Water::updateUnderwater(bool underwater)
|
||||||
|
|
||||||
Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY)
|
Vector3 Water::getSceneNodeCoordinates(int gridX, int gridY)
|
||||||
{
|
{
|
||||||
return Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), mTop, -gridY * CELL_SIZE - (CELL_SIZE / 2));
|
return Vector3(gridX * CELL_SIZE + (CELL_SIZE / 2), gridY * CELL_SIZE + (CELL_SIZE / 2), mTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Water::setViewportBackground(const ColourValue& bg)
|
void Water::setViewportBackground(const ColourValue& bg)
|
||||||
|
|
|
@ -264,9 +264,8 @@ namespace MWWorld
|
||||||
Ogre::Vector3 to = ray.getPoint(queryDistance);
|
Ogre::Vector3 to = ray.getPoint(queryDistance);
|
||||||
|
|
||||||
btVector3 _from, _to;
|
btVector3 _from, _to;
|
||||||
// OGRE to MW coordinates
|
_from = btVector3(from.x, from.y, from.z);
|
||||||
_from = btVector3(from.x, -from.z, from.y);
|
_to = btVector3(to.x, to.y, to.z);
|
||||||
_to = btVector3(to.x, -to.z, to.y);
|
|
||||||
|
|
||||||
std::vector < std::pair <float, std::string> > results;
|
std::vector < std::pair <float, std::string> > results;
|
||||||
/* auto */ results = mEngine->rayTest2(_from,_to);
|
/* auto */ results = mEngine->rayTest2(_from,_to);
|
||||||
|
@ -287,7 +286,7 @@ namespace MWWorld
|
||||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||||
mRender.getViewport()->getWidth()/2,
|
mRender.getViewport()->getWidth()/2,
|
||||||
mRender.getViewport()->getHeight()/2);
|
mRender.getViewport()->getHeight()/2);
|
||||||
btVector3 result(centerRay.getPoint(extent).x,-centerRay.getPoint(extent).z,centerRay.getPoint(extent).y);
|
btVector3 result(centerRay.getPoint(extent).x,centerRay.getPoint(extent).y,centerRay.getPoint(extent).z);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +294,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
//get a ray pointing to the center of the viewport
|
//get a ray pointing to the center of the viewport
|
||||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
|
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(mouseX, mouseY);
|
||||||
btVector3 result(centerRay.getPoint(extent).x,-centerRay.getPoint(extent).z,centerRay.getPoint(extent).y);
|
btVector3 result(centerRay.getPoint(extent).x,centerRay.getPoint(extent).y,centerRay.getPoint(extent).z);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,9 +334,8 @@ namespace MWWorld
|
||||||
Ogre::Vector3 to = ray.getPoint(200); /// \todo make this distance (ray length) configurable
|
Ogre::Vector3 to = ray.getPoint(200); /// \todo make this distance (ray length) configurable
|
||||||
|
|
||||||
btVector3 _from, _to;
|
btVector3 _from, _to;
|
||||||
// OGRE to MW coordinates
|
_from = btVector3(from.x, from.y, from.z);
|
||||||
_from = btVector3(from.x, -from.z, from.y);
|
_to = btVector3(to.x, to.y, to.z);
|
||||||
_to = btVector3(to.x, -to.z, to.y);
|
|
||||||
|
|
||||||
std::pair<std::string, float> result = mEngine->rayTest(_from, _to);
|
std::pair<std::string, float> result = mEngine->rayTest(_from, _to);
|
||||||
|
|
||||||
|
|
|
@ -1024,7 +1024,6 @@ namespace MWWorld
|
||||||
// currently its here because we need to access the physics system
|
// currently its here because we need to access the physics system
|
||||||
float* p = mPlayer->getPlayer().getRefData().getPosition().pos;
|
float* p = mPlayer->getPlayer().getRefData().getPosition().pos;
|
||||||
Vector3 sun = mRendering->getSkyManager()->getRealSunPos();
|
Vector3 sun = mRendering->getSkyManager()->getRealSunPos();
|
||||||
sun = Vector3(sun.x, -sun.z, sun.y);
|
|
||||||
mRendering->getSkyManager()->setGlare(!mPhysics->castRay(Ogre::Vector3(p[0], p[1], p[2]), sun));
|
mRendering->getSkyManager()->setGlare(!mPhysics->castRay(Ogre::Vector3(p[0], p[1], p[2]), sun));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,7 +1121,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
p = mPhysics->getRayPoint(results.front().first);
|
p = mPhysics->getRayPoint(results.front().first);
|
||||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
Ogre::Vector3 pos(p.x(), p.y(), p.z());
|
||||||
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode();
|
||||||
|
|
||||||
//std::cout << "Num facing 1 : " << mFaced1Name << std::endl;
|
//std::cout << "Num facing 1 : " << mFaced1Name << std::endl;
|
||||||
|
@ -1150,7 +1149,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
p = mPhysics->getRayPoint(results.at (1).first);
|
p = mPhysics->getRayPoint(results.at (1).first);
|
||||||
Ogre::Vector3 pos(p.x(), p.z(), -p.y());
|
Ogre::Vector3 pos(p.x(), p.y(), p.z());
|
||||||
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode();
|
||||||
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode();
|
||||||
|
|
||||||
|
@ -1228,8 +1227,8 @@ namespace MWWorld
|
||||||
if (!ref)
|
if (!ref)
|
||||||
return Vector2(0, 1);
|
return Vector2(0, 1);
|
||||||
Ogre::SceneNode* node = ref->mData.getBaseNode();
|
Ogre::SceneNode* node = ref->mData.getBaseNode();
|
||||||
Vector3 dir = node->_getDerivedOrientation().yAxis();
|
Vector3 dir = node->_getDerivedOrientation() * Ogre::Vector3(0,1,0);
|
||||||
Vector2 d = Vector2(dir.x, dir.z);
|
Vector2 d = Vector2(dir.x, dir.y);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,7 +1298,7 @@ namespace MWWorld
|
||||||
if (isCellExterior())
|
if (isCellExterior())
|
||||||
{
|
{
|
||||||
int cellX, cellY;
|
int cellX, cellY;
|
||||||
positionToIndex(result.second[0], -result.second[2], cellX, cellY);
|
positionToIndex(result.second[0], result.second[1], cellX, cellY);
|
||||||
cell = mCells.getExterior(cellX, cellY);
|
cell = mCells.getExterior(cellX, cellY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1307,8 +1306,8 @@ namespace MWWorld
|
||||||
|
|
||||||
ESM::Position pos = getPlayer().getPlayer().getRefData().getPosition();
|
ESM::Position pos = getPlayer().getPlayer().getRefData().getPosition();
|
||||||
pos.pos[0] = result.second[0];
|
pos.pos[0] = result.second[0];
|
||||||
pos.pos[1] = -result.second[2];
|
pos.pos[1] = result.second[1];
|
||||||
pos.pos[2] = result.second[1];
|
pos.pos[2] = result.second[2];
|
||||||
|
|
||||||
Ptr dropped = copyObjectToCell(object, *cell, pos);
|
Ptr dropped = copyObjectToCell(object, *cell, pos);
|
||||||
PCDropped(dropped);
|
PCDropped(dropped);
|
||||||
|
|
|
@ -305,9 +305,9 @@
|
||||||
float3 waterEyePos = float3(1,1,1);
|
float3 waterEyePos = float3(1,1,1);
|
||||||
// NOTE: this calculation would be wrong for non-uniform scaling
|
// NOTE: this calculation would be wrong for non-uniform scaling
|
||||||
float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0));
|
float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0));
|
||||||
waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,1,0), waterLevel);
|
waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,0,1), waterLevel);
|
||||||
caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed);
|
caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed);
|
||||||
if (worldPos.y >= waterLevel || waterEnabled != 1.f)
|
if (worldPos.z >= waterLevel || waterEnabled != 1.f)
|
||||||
caustics = float3(1,1,1);
|
caustics = float3(1,1,1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@
|
||||||
|
|
||||||
#if UNDERWATER
|
#if UNDERWATER
|
||||||
// regular fog only if fragment is above water
|
// regular fog only if fragment is above water
|
||||||
if (worldPos.y > waterLevel || waterEnabled != 1.f)
|
if (worldPos.z > waterLevel || waterEnabled != 1.f)
|
||||||
#endif
|
#endif
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
||||||
#endif
|
#endif
|
||||||
|
@ -366,7 +366,7 @@
|
||||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
||||||
|
|
||||||
#if UNDERWATER
|
#if UNDERWATER
|
||||||
float fogAmount = (cameraPos.y > waterLevel)
|
float fogAmount = (cameraPos.z > waterLevel)
|
||||||
? shSaturate(length(waterEyePos-worldPos) / VISIBILITY)
|
? shSaturate(length(waterEyePos-worldPos) / VISIBILITY)
|
||||||
: shSaturate(length(cameraPos.xyz-worldPos)/ VISIBILITY);
|
: shSaturate(length(cameraPos.xyz-worldPos)/ VISIBILITY);
|
||||||
|
|
||||||
|
@ -380,14 +380,14 @@
|
||||||
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
waterGradient = clamp((waterGradient*0.5+0.5),0.2,1.0);
|
||||||
float3 watercolour = ( float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
float3 watercolour = ( float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
||||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||||
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
watercolour = (cameraPos.z <= waterLevel) ? watercolour : watercolour*0.3;
|
||||||
|
|
||||||
|
|
||||||
float darkness = VISIBILITY*2.0;
|
float darkness = VISIBILITY*2.0;
|
||||||
darkness = clamp((waterEyePos.y - waterLevel + darkness)/darkness,0.2,1.0);
|
darkness = clamp((waterEyePos.z - waterLevel + darkness)/darkness,0.2,1.0);
|
||||||
watercolour *= darkness;
|
watercolour *= darkness;
|
||||||
|
|
||||||
float isUnderwater = (worldPos.y < waterLevel) ? 1.0 : 0.0;
|
float isUnderwater = (worldPos.z < waterLevel) ? 1.0 : 0.0;
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater * waterEnabled);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater * waterEnabled);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,8 @@
|
||||||
float toMorph = -min(0, sign(uv1.y - lodMorph.y));
|
float toMorph = -min(0, sign(uv1.y - lodMorph.y));
|
||||||
|
|
||||||
// morph
|
// morph
|
||||||
// this assumes XZ terrain alignment
|
// this assumes XY terrain alignment
|
||||||
worldPos.y += uv1.x * toMorph * lodMorph.x;
|
worldPos.z += uv1.x * toMorph * lodMorph.x;
|
||||||
|
|
||||||
|
|
||||||
shOutputPosition = shMatrixMult(viewProjMatrix, worldPos);
|
shOutputPosition = shMatrixMult(viewProjMatrix, worldPos);
|
||||||
|
@ -246,9 +246,9 @@
|
||||||
float3 waterEyePos = float3(1,1,1);
|
float3 waterEyePos = float3(1,1,1);
|
||||||
// NOTE: this calculation would be wrong for non-uniform scaling
|
// NOTE: this calculation would be wrong for non-uniform scaling
|
||||||
float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0));
|
float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0));
|
||||||
waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,1,0), waterLevel);
|
waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,0,1), waterLevel);
|
||||||
caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed);
|
caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed);
|
||||||
if (worldPos.y >= waterLevel)
|
if (worldPos.z >= waterLevel)
|
||||||
caustics = float3(1,1,1);
|
caustics = float3(1,1,1);
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@
|
||||||
|
|
||||||
#if UNDERWATER
|
#if UNDERWATER
|
||||||
// regular fog only if fragment is above water
|
// regular fog only if fragment is above water
|
||||||
if (worldPos.y > waterLevel)
|
if (worldPos.z > waterLevel)
|
||||||
#endif
|
#endif
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
||||||
#endif
|
#endif
|
||||||
|
@ -363,7 +363,7 @@
|
||||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
||||||
|
|
||||||
#if UNDERWATER
|
#if UNDERWATER
|
||||||
float fogAmount = (cameraPos.y > waterLevel)
|
float fogAmount = (cameraPos.z > waterLevel)
|
||||||
? shSaturate(length(waterEyePos-worldPos) / VISIBILITY)
|
? shSaturate(length(waterEyePos-worldPos) / VISIBILITY)
|
||||||
: shSaturate(length(cameraPos.xyz-worldPos)/ VISIBILITY);
|
: shSaturate(length(cameraPos.xyz-worldPos)/ VISIBILITY);
|
||||||
|
|
||||||
|
@ -378,14 +378,14 @@
|
||||||
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
float3 watercolour = (float3(0.0078, 0.5176, 0.700)+waterSunColour)*waterGradient*2.0;
|
||||||
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
float3 waterext = float3(0.6, 0.9, 1.0);//water extinction
|
||||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||||
watercolour = (cameraPos.y <= waterLevel) ? watercolour : watercolour*0.3;
|
watercolour = (cameraPos.z <= waterLevel) ? watercolour : watercolour*0.3;
|
||||||
|
|
||||||
|
|
||||||
float darkness = VISIBILITY*2.0;
|
float darkness = VISIBILITY*2.0;
|
||||||
darkness = clamp((waterEyePos.y - waterLevel + darkness)/darkness,0.2,1.0);
|
darkness = clamp((waterEyePos.z - waterLevel + darkness)/darkness,0.2,1.0);
|
||||||
watercolour *= darkness;
|
watercolour *= darkness;
|
||||||
|
|
||||||
float isUnderwater = (worldPos.y < waterLevel) ? 1.0 : 0.0;
|
float isUnderwater = (worldPos.z < waterLevel) ? 1.0 : 0.0;
|
||||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater);
|
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, watercolour, fogAmount * isUnderwater);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,9 +79,9 @@ float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float
|
||||||
|
|
||||||
float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos, float3 worldNormal, float3 lightDirectionWS0, float waterLevel, float waterTimer, float3 windDir_windSpeed)
|
float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos, float3 worldNormal, float3 lightDirectionWS0, float waterLevel, float waterTimer, float3 windDir_windSpeed)
|
||||||
{
|
{
|
||||||
float waterDepth = shSaturate((waterEyePos.y - worldPos.y) / 50.0);
|
float waterDepth = shSaturate((waterEyePos.z - worldPos.z) / 50.0);
|
||||||
|
|
||||||
float3 causticPos = intercept(worldPos.xyz, lightDirectionWS0.xyz, float3(0,1,0), waterLevel);
|
float3 causticPos = intercept(worldPos.xyz, lightDirectionWS0.xyz, float3(0,0,1), waterLevel);
|
||||||
|
|
||||||
///\ todo clean this up
|
///\ todo clean this up
|
||||||
float causticdepth = length(causticPos-worldPos.xyz);
|
float causticdepth = length(causticPos-worldPos.xyz);
|
||||||
|
@ -91,20 +91,21 @@ float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos,
|
||||||
// NOTE: the original shader calculated a tangent space basis here,
|
// NOTE: the original shader calculated a tangent space basis here,
|
||||||
// but using only the world normal is cheaper and i couldn't see a visual difference
|
// but using only the world normal is cheaper and i couldn't see a visual difference
|
||||||
// also, if this effect gets moved to screen-space some day, it's unlikely to have tangent information
|
// also, if this effect gets moved to screen-space some day, it's unlikely to have tangent information
|
||||||
float3 causticNorm = worldNormal.xyz * perturb(causticMap, causticPos.xz, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).xzy * 2 - 1;
|
float3 causticNorm = worldNormal.xyz * perturb(causticMap, causticPos.xy, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).xyz * 2 - 1;
|
||||||
|
causticNorm = float3(causticNorm.x, causticNorm.y, -causticNorm.z);
|
||||||
|
|
||||||
//float fresnel = pow(clamp(dot(LV,causticnorm),0.0,1.0),2.0);
|
//float fresnel = pow(clamp(dot(LV,causticnorm),0.0,1.0),2.0);
|
||||||
|
|
||||||
float NdotL = max(dot(worldNormal.xyz, lightDirectionWS0.xyz),0.0);
|
float NdotL = max(dot(worldNormal.xyz, lightDirectionWS0.xyz),0.0);
|
||||||
|
|
||||||
float causticR = 1.0-perturb(causticMap, causticPos.xz, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
float causticR = 1.0-perturb(causticMap, causticPos.xy, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||||
|
|
||||||
/// \todo sunFade
|
/// \todo sunFade
|
||||||
|
|
||||||
// float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth;
|
// float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth;
|
||||||
float3 caustics = clamp(pow(float3(causticR,causticR,causticR)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth;
|
float3 caustics = clamp(pow(float3(causticR,causticR,causticR)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth;
|
||||||
float causticG = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
float causticG = 1.0-perturb(causticMap,causticPos.xy+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||||
float causticB = 1.0-perturb(causticMap,causticPos.xz+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
float causticB = 1.0-perturb(causticMap,causticPos.xy+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||||
//caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth;
|
//caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth;
|
||||||
caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)))*NdotL*causticdepth;
|
caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)))*NdotL*causticdepth;
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
#define REFL_BUMP 0.08 // reflection distortion amount
|
#define REFL_BUMP 0.08 // reflection distortion amount
|
||||||
#define REFR_BUMP 0.06 // refraction distortion amount
|
#define REFR_BUMP 0.06 // refraction distortion amount
|
||||||
|
|
||||||
#define SCATTER_AMOUNT 3.0 // amount of sunlight scattering
|
#define SCATTER_AMOUNT 0.3 // amount of sunlight scattering
|
||||||
#define SCATTER_COLOUR float3(0.0,1.0,0.95) // colour of sunlight scattering
|
#define SCATTER_COLOUR float3(0.0,1.0,0.95) // colour of sunlight scattering
|
||||||
|
|
||||||
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
|
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
|
||||||
|
@ -214,32 +214,32 @@
|
||||||
|
|
||||||
float3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
float3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
||||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y).xzy;
|
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y);
|
||||||
|
|
||||||
float4 worldPosition = shMatrixMult(wMat, float4(position.xyz, 1));
|
float4 worldPosition = shMatrixMult(wMat, float4(position.xyz, 1));
|
||||||
float2 relPos = (worldPosition.xz - rippleCenter.xy) / rippleAreaLength + 0.5;
|
float2 relPos = (worldPosition.xy - rippleCenter.xy) / rippleAreaLength + 0.5;
|
||||||
float3 normal_ripple = normalize(shSample(rippleNormalMap, relPos.xy).xyz * 2 - 1);
|
float3 normal_ripple = normalize(shSample(rippleNormalMap, relPos.xy).xyz * 2 - 1);
|
||||||
normal_ripple = normal_ripple.xzy;
|
|
||||||
|
|
||||||
//normal = normalize(normal + normal_ripple);
|
//normal = normalize(normal + normal_ripple);
|
||||||
normal = normalize(float3(normal.x + normal_ripple.x, normal.y, normal.z + normal_ripple.z));
|
normal = normalize(float3(normal.x * BUMP + normal_ripple.x, normal.y * BUMP + normal_ripple.y, normal.z));
|
||||||
|
normal = float3(normal.x, normal.y, -normal.z);
|
||||||
|
|
||||||
|
|
||||||
// normal for sunlight scattering
|
// normal for sunlight scattering
|
||||||
float3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 +
|
float3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 +
|
||||||
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
|
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
|
||||||
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1).xzy;
|
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1).xyz;
|
||||||
lNormal = normalize(float3(lNormal.x * BUMP, lNormal.y, lNormal.z * BUMP));
|
lNormal = normalize(float3(lNormal.x * BUMP, lNormal.y * BUMP, lNormal.z));
|
||||||
|
lNormal = float3(lNormal.x, lNormal.y, -lNormal.z);
|
||||||
|
|
||||||
|
|
||||||
float3 lVec = normalize(sunPosition.xyz);
|
float3 lVec = normalize(sunPosition.xyz);
|
||||||
float3 vVec = normalize(position.xyz - cameraPos.xyz);
|
float3 vVec = normalize(position.xyz - cameraPos.xyz);
|
||||||
|
|
||||||
|
|
||||||
float isUnderwater = (cameraPos.y > 0) ? 0.0 : 1.0;
|
float isUnderwater = (cameraPos.z > 0) ? 0.0 : 1.0;
|
||||||
|
|
||||||
// sunlight scattering
|
// sunlight scattering
|
||||||
float3 pNormal = float3(0,1,0);
|
float3 pNormal = float3(0,0,1);
|
||||||
float3 lR = reflect(lVec, lNormal);
|
float3 lR = reflect(lVec, lNormal);
|
||||||
float3 llR = reflect(lVec, pNormal);
|
float3 llR = reflect(lVec, pNormal);
|
||||||
|
|
||||||
|
@ -248,23 +248,24 @@
|
||||||
float3 scatterColour = shLerp(float3(SCATTER_COLOUR)*float3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
float3 scatterColour = shLerp(float3(SCATTER_COLOUR)*float3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||||
|
|
||||||
// fresnel
|
// fresnel
|
||||||
float ior = (cameraPos.y>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
|
float ior = (cameraPos.z>0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
|
||||||
float fresnel = fresnel_dielectric(-vVec, normal, ior);
|
float fresnel = fresnel_dielectric(-vVec, normal, ior);
|
||||||
|
|
||||||
fresnel = shSaturate(fresnel);
|
fresnel = shSaturate(fresnel);
|
||||||
|
|
||||||
// reflection
|
// reflection
|
||||||
float3 reflection = shSample(reflectionMap, screenCoords+(normal.xz*REFL_BUMP)).rgb;
|
float3 reflection = shSample(reflectionMap, screenCoords+(normal.xy*REFL_BUMP)).rgb;
|
||||||
|
|
||||||
// refraction
|
// refraction
|
||||||
float3 R = reflect(vVec, normal);
|
float3 R = reflect(vVec, normal);
|
||||||
|
|
||||||
#if REFRACTION
|
#if REFRACTION
|
||||||
float3 refraction = shSample(refractionMap, (screenCoords-(normal.xz*REFR_BUMP))*1.0).rgb;
|
float3 refraction = shSample(refractionMap, (screenCoords-(normal.xy*REFR_BUMP))*1.0).rgb;
|
||||||
|
|
||||||
// brighten up the refraction underwater
|
// brighten up the refraction underwater
|
||||||
refraction = (cameraPos.y < 0) ? shSaturate(refraction * 1.5) : refraction;
|
refraction = (cameraPos.z < 0) ? shSaturate(refraction * 1.5) : refraction;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// specular
|
// specular
|
||||||
float specular = pow(max(dot(R, lVec), 0.0),SPEC_HARDNESS);
|
float specular = pow(max(dot(R, lVec), 0.0),SPEC_HARDNESS);
|
||||||
|
|
||||||
|
@ -287,7 +288,7 @@
|
||||||
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
watercolour = shLerp(watercolour*0.3*waterSunFade_sunHeight.x, watercolour, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||||
|
|
||||||
float darkness = VISIBILITY*2.0;
|
float darkness = VISIBILITY*2.0;
|
||||||
darkness = clamp((cameraPos.y+darkness)/darkness,0.2,1.0);
|
darkness = clamp((cameraPos.z+darkness)/darkness,0.2,1.0);
|
||||||
|
|
||||||
|
|
||||||
float fog = shSaturate(length(cameraPos.xyz-position.xyz) / VISIBILITY);
|
float fog = shSaturate(length(cameraPos.xyz-position.xyz) / VISIBILITY);
|
||||||
|
|
|
@ -193,7 +193,6 @@ namespace Physic
|
||||||
if(!isDebugCreated)
|
if(!isDebugCreated)
|
||||||
{
|
{
|
||||||
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
|
||||||
node->pitch(Ogre::Degree(-90));
|
|
||||||
mDebugDrawer = new BtOgre::DebugDrawer(node, dynamicsWorld);
|
mDebugDrawer = new BtOgre::DebugDrawer(node, dynamicsWorld);
|
||||||
dynamicsWorld->setDebugDrawer(mDebugDrawer);
|
dynamicsWorld->setDebugDrawer(mDebugDrawer);
|
||||||
isDebugCreated = true;
|
isDebugCreated = true;
|
||||||
|
|
Loading…
Reference in a new issue