mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Fix duplicate calls to OEngine. Use correct position, rotation and scale. Debug draw not working.
This commit is contained in:
parent
03a30c3f1d
commit
8bcd415cca
5 changed files with 59 additions and 33 deletions
|
@ -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<std::string, bool>::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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue