consider scale and orientation when previewing reference

actorid
Marc Zinnschlag 11 years ago
parent 48ea93d890
commit 6b11265fbc

@ -23,15 +23,42 @@ void CSVRender::PreviewWidget::setup (const std::string& id)
if (model.empty())
return;
Ogre::SceneNode* node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->setPosition (Ogre::Vector3 (0, 0, 0));
mNode = getSceneManager()->getRootSceneNode()->createChildSceneNode();
mNode->setPosition (Ogre::Vector3 (0, 0, 0));
mObject = NifOgre::Loader::createObjects (node, "Meshes\\" + model);
mObject = NifOgre::Loader::createObjects (mNode, "Meshes\\" + model);
}
void CSVRender::PreviewWidget::adjust (const std::string& id)
{
if (mNode)
{
int row = mData.getReferences().getIndex (id);
float scale = mData.getReferences().getData (row, mData.getReferences().
findColumnIndex (CSMWorld::Columns::ColumnId_Scale)).toFloat();
float rotX = mData.getReferences().getData (row, mData.getReferences().
findColumnIndex (CSMWorld::Columns::ColumnId_PositionXRot)).toFloat();
float rotY = mData.getReferences().getData (row, mData.getReferences().
findColumnIndex (CSMWorld::Columns::ColumnId_PositionYRot)).toFloat();
float rotZ = mData.getReferences().getData (row, mData.getReferences().
findColumnIndex (CSMWorld::Columns::ColumnId_PositionZRot)).toFloat();
mNode->setScale (scale, scale, scale);
Ogre::Quaternion xr (Ogre::Radian(-rotX), Ogre::Vector3::UNIT_X);
Ogre::Quaternion yr (Ogre::Radian(-rotY), Ogre::Vector3::UNIT_Y);
Ogre::Quaternion zr (Ogre::Radian(-rotZ), Ogre::Vector3::UNIT_Z);
mNode->setOrientation (xr*yr*zr);
}
}
CSVRender::PreviewWidget::PreviewWidget (const CSMWorld::Data& data,
const std::string& referenceableId, QWidget *parent)
: SceneWidget (parent), mData (data)
: SceneWidget (parent), mData (data), mNode (0)
{
setup (referenceableId);
}
@ -41,5 +68,5 @@ CSVRender::PreviewWidget::PreviewWidget (const CSMWorld::Data& data,
: SceneWidget (parent), mData (data)
{
setup (referenceableId);
/// \todo apply reference modifications (scale, rotation)
adjust (referenceId);
}

@ -21,10 +21,14 @@ namespace CSVRender
const CSMWorld::Data& mData;
CSVRender::NavigationOrbit mOrbit;
NifOgre::ObjectScenePtr mObject;
Ogre::SceneNode *mNode;
void setup (const std::string& id);
///< \param id ID of the referenceable to be viewed
void adjust (const std::string& id);
///< \param id ID of the reference to be viewed
public:
PreviewWidget (const CSMWorld::Data& data, const std::string& referenceableId,

Loading…
Cancel
Save