diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 0b24da1ba0..827e266530 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -84,9 +84,6 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, mTerrain->loadCell(esmLand->mX, esmLand->mY); } - std::cout << "cell pos" + std::to_string(mCellNode->getPosition().x) - + ", " + std::to_string(mCellNode->getPosition().y) - + ", " + std::to_string(mCellNode->getPosition().z) << std::endl; } CSVRender::Cell::~Cell() @@ -183,7 +180,7 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft, for (std::map::iterator iter (ids.begin()); iter!=ids.end(); ++iter) { mObjects.insert (std::make_pair ( - iter->first, new Object (mData, mCellNode, iter->first, false))); + iter->first, new Object (mData, mCellNode, iter->first, false, mPhysics))); modified = true; } diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index ede73da16d..fcdfc05e15 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -76,11 +76,48 @@ void CSVRender::Object::update() mObject = NifOgre::Loader::createObjects (mBase, "Meshes\\" + model); mObject->setVisibilityFlags (Element_Reference); - bool placeable = true; // FIXME - mPhysics->addObject("meshes\\" + model, mBase->getName(), /*scale*/1, - mBase->getPosition(), mBase->getOrientation(), 0, 0, false, placeable); - mPhysics->addObject("meshes\\" + model, mBase->getName(), /*scale*/1, - mBase->getPosition(), mBase->getOrientation(), 0, 0, true, placeable); // FIXME: why again with raycasting? + // mwrender/objects.cpp: insertBegin() + // + // creates a ChildSceneNode from root if one doesn't exist for that cell (CellStore*) + // creates a ChildSceneNode for that cell scene node + // set the position & scale of the new node (for the object) + // set the orientation of the new node + // set the new node as the basenode (for the object) + // + // render/cell.cpp: Cell() + // + // creates a ChildSceneNode from root + // set the position to origin <---- each object adjusts its position later + // pass the node when creating an Object + // + // render/object.cpp: Object() + // creates a ChildSceneNode from the cell scene node + // + if (!mReferenceId.empty()) + { + const CSMWorld::CellRef& reference = getReference(); + Ogre::Quaternion xr (Ogre::Radian (-reference.mPos.rot[0]), Ogre::Vector3::UNIT_X); + Ogre::Quaternion yr (Ogre::Radian (-reference.mPos.rot[1]), Ogre::Vector3::UNIT_Y); + Ogre::Quaternion zr (Ogre::Radian (-reference.mPos.rot[2]), Ogre::Vector3::UNIT_Z); + + bool placeable = false; // FIXME + mPhysics->addObject("meshes\\" + model, + mBase->getName(), + reference.mScale, + Ogre::Vector3(reference.mPos.pos[0], + reference.mPos.pos[1], + reference.mPos.pos[2]), + xr*yr*zr, + 0, 0, false, placeable); + mPhysics->addObject("meshes\\" + model, + mBase->getName(), + reference.mScale, + Ogre::Vector3(reference.mPos.pos[0], + reference.mPos.pos[1], + reference.mPos.pos[2]), + xr*yr*zr, + 0, 0, true, placeable); // FIXME: why again with raycasting? + } } } @@ -136,6 +173,10 @@ CSVRender::Object::Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode update(); adjust(); + std::cout << "obj pos" + std::to_string(mBase->getPosition().x) + + ", " + std::to_string(mBase->getPosition().y) + + ", " + std::to_string(mBase->getPosition().z) << std::endl; + } CSVRender::Object::~Object() diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 28c8192a40..c7d8663606 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -147,7 +147,11 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells() ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2, height+200)); getSceneManager()->getRootSceneNode()->createChildSceneNode()->attachObject(manual); - manual->setVisible(false); + manual->setVisible(true); + + std::cout << "cell pos" + std::to_string(ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2) + + ", " + std::to_string(ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2) + + ", " + std::to_string(height) << std::endl; CSVRender::TextOverlay *textDisp = new CSVRender::TextOverlay(manual, getCamera(), iter->getId(mWorldspace)); @@ -193,6 +197,8 @@ void CSVRender::PagedWorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event if(event->button() == Qt::RightButton) { std::cout << "double clicked" << std::endl; + //getSceneManager()->setVisibilityMask (4294967295); + getPhysics()->toggleDebugRendering(); } } diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 9ab061ca4f..bb7102f34d 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -66,6 +66,7 @@ namespace CSVRender mOverlaySystem = OverlaySystem::instance().get(); mSceneMgr->addRenderQueueListener(mOverlaySystem); + // FIXME: singleton probably needed mPhysics = new CSVWorld::PhysicsSystem(mSceneMgr); QTimer *timer = new QTimer (this); diff --git a/apps/opencs/view/world/physicssystem.cpp b/apps/opencs/view/world/physicssystem.cpp index c9f7888998..620b92980f 100644 --- a/apps/opencs/view/world/physicssystem.cpp +++ b/apps/opencs/view/world/physicssystem.cpp @@ -22,15 +22,6 @@ namespace CSVWorld delete mEngine; } - // OpenMW | OpenCS - // Ptr | ? - // ptr.getClass().getModel(ptr) | ? // see Object::update() - // ptr.getRefData().getBaseNode() | ? - // ptr.getCellRef().getScale() | ? - // - // getModel() returns the mesh; each class has its own implementation - // - //void PhysicsSystem::addObject (const Ptr& ptr, bool placeable) void PhysicsSystem::addObject(const std::string &mesh, const std::string &name, float scale, @@ -41,24 +32,14 @@ namespace CSVWorld bool raycasting, bool placeable) { -#if 0 - std::string mesh = ptr.getClass().getModel(ptr); - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - handleToMesh[node->getName()] = mesh; - mEngine->createAndAdjustRigidBody( - mesh, node->getName(), ptr.getCellRef().getScale(), node->getPosition(), node->getOrientation(), 0, 0, false, placeable); - mEngine->createAndAdjustRigidBody( - mesh, node->getName(), ptr.getCellRef().getScale(), node->getPosition(), node->getOrientation(), 0, 0, true, placeable); -#endif + //handleToMesh[node->getName()] = mesh; mEngine->createAndAdjustRigidBody(mesh, name, scale, position, rotation, - 0, 0, false, placeable); - mEngine->createAndAdjustRigidBody(mesh, name, scale, position, rotation, - 0, 0, true, placeable); + scaledBoxTranslation, boxRotation, raycasting, placeable); } void PhysicsSystem::toggleDebugRendering() { - //mEngine->toggleDebugRendering(); - mEngine->setDebugRenderingMode(1); + mEngine->toggleDebugRendering(); + //mEngine->setDebugRenderingMode(1); } }