From: <es...@us...> - 2010-08-07 08:19:19
|
Revision: 2960 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2960&view=rev Author: esuvs Date: 2010-08-07 08:19:12 +0000 (Sat, 07 Aug 2010) Log Message: ----------- Added scaling support. Modified Paths: -------------- trunk/QtOgreFramework/EngineTest/include/Object.h trunk/QtOgreFramework/EngineTest/media/scripts/update.js trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp trunk/QtOgreFramework/EngineTest/source/Object.cpp Modified: trunk/QtOgreFramework/EngineTest/include/Object.h =================================================================== --- trunk/QtOgreFramework/EngineTest/include/Object.h 2010-08-05 21:22:58 UTC (rev 2959) +++ trunk/QtOgreFramework/EngineTest/include/Object.h 2010-08-07 08:19:12 UTC (rev 2960) @@ -16,16 +16,20 @@ Q_PROPERTY(QVector3D position READ position WRITE setPosition) Q_PROPERTY(QQuaternion orientation READ orientation WRITE setOrientation) + Q_PROPERTY(QVector3D size READ size WRITE setSize) Q_PROPERTY(QVector3D xAxis READ xAxis) Q_PROPERTY(QVector3D yAxis READ yAxis) Q_PROPERTY(QVector3D zAxis READ zAxis) + const QVector3D& position(void) const; + void setPosition(const QVector3D& position); + const QQuaternion& orientation(void) const; void setOrientation(const QQuaternion& orientation); - const QVector3D& position(void) const; - void setPosition(const QVector3D& position); + const QVector3D& size(void) const; + void setSize(const QVector3D& size); const QVector3D xAxis(void) const; const QVector3D yAxis(void) const; @@ -39,9 +43,14 @@ void yaw(qreal angleInDegrees); void roll(qreal angleInDegrees); + void scale(qreal factor); + void scale(const QVector3D & vector); + void scale(qreal x, qreal y, qreal z); + private: QVector3D mPosition; QQuaternion mOrientation; + QVector3D mScale; }; #endif //OBJECT_H_ \ No newline at end of file Modified: trunk/QtOgreFramework/EngineTest/media/scripts/update.js =================================================================== --- trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-08-05 21:22:58 UTC (rev 2959) +++ trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-08-07 08:19:12 UTC (rev 2960) @@ -66,4 +66,6 @@ tempFOV = -wheelDelta * 0.001; fov = fov + tempFOV; camera.fieldOfView = fov; + + objectStore.getObject('Robot').yaw(1); } \ No newline at end of file Modified: trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-08-05 21:22:58 UTC (rev 2959) +++ trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-08-07 08:19:12 UTC (rev 2960) @@ -187,11 +187,29 @@ Entity* entity = dynamic_cast<Entity*>(pObj); if(entity) { - if(mSceneManager->hasEntity(objectIter.key().toStdString()) == false) + Ogre::Entity* ogreEntity; + Ogre::SceneNode* sceneNode; + + if(mSceneManager->hasEntity(objectIter.key().toStdString())) { - Ogre::Entity* ogreEntity = mSceneManager->createEntity(objectIter.key().toStdString(), entity->meshName().toStdString()); - mSceneManager->getRootSceneNode()->attachObject(ogreEntity); + ogreEntity = mSceneManager->getEntity(objectIter.key().toStdString()); + sceneNode = dynamic_cast<Ogre::SceneNode*>(ogreEntity->getParentNode()); } + else + { + sceneNode = mSceneManager->getRootSceneNode()->createChildSceneNode(); + ogreEntity = mSceneManager->createEntity(objectIter.key().toStdString(), entity->meshName().toStdString()); + sceneNode->attachObject(ogreEntity); + } + + QVector3D pos = entity->position(); + sceneNode->setPosition(Ogre::Vector3(pos.x(), pos.y(), pos.z())); + + QQuaternion orientation = entity->orientation(); + sceneNode->setOrientation(Ogre::Quaternion(orientation.scalar(), orientation.x(), orientation.y(), orientation.z())); + + QVector3D scale = entity->size(); + sceneNode->setScale(Ogre::Vector3(scale.x(), scale.y(), scale.z())); } } Modified: trunk/QtOgreFramework/EngineTest/source/Object.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/Object.cpp 2010-08-05 21:22:58 UTC (rev 2959) +++ trunk/QtOgreFramework/EngineTest/source/Object.cpp 2010-08-07 08:19:12 UTC (rev 2960) @@ -3,8 +3,19 @@ Object::Object(QObject * parent) :QObject(parent) { + mScale = QVector3D(1,1,1); } +const QVector3D& Object::position(void) const +{ + return mPosition; +} + +void Object::setPosition(const QVector3D& position) +{ + mPosition = position; +} + const QQuaternion& Object::orientation(void) const { return mOrientation; @@ -15,14 +26,14 @@ mOrientation = orientation; } -const QVector3D& Object::position(void) const +const QVector3D& Object::size(void) const { - return mPosition; + return mScale; } -void Object::setPosition(const QVector3D& position) +void Object::setSize(const QVector3D& scale) { - mPosition = position; + mScale = scale; } const QVector3D Object::xAxis(void) const @@ -70,4 +81,19 @@ { QQuaternion rotation = QQuaternion::fromAxisAndAngle(QVector3D(0,0,1), angleInDegrees); mOrientation *= rotation; +} + +void Object::scale(qreal factor) +{ + mScale *= QVector3D(factor,factor,factor); +} + +void Object::scale(const QVector3D & vector) +{ + mScale *= vector; +} + +void Object::scale(qreal x, qreal y, qreal z) +{ + mScale *= QVector3D(x,y,z); } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |