From: <es...@us...> - 2010-08-04 22:01:44
|
Revision: 2956 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2956&view=rev Author: esuvs Date: 2010-08-04 22:01:38 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Tidying. 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-03 20:31:01 UTC (rev 2955) +++ trunk/QtOgreFramework/EngineTest/include/Object.h 2010-08-04 22:01:38 UTC (rev 2956) @@ -15,11 +15,15 @@ Object(QObject* parent = 0); Q_PROPERTY(QVector3D position READ position WRITE setPosition) + Q_PROPERTY(QQuaternion orientation READ orientation WRITE setOrientation) Q_PROPERTY(QVector3D xAxis READ xAxis) Q_PROPERTY(QVector3D yAxis READ yAxis) Q_PROPERTY(QVector3D zAxis READ zAxis) + const QQuaternion& orientation(void) const; + void setOrientation(const QQuaternion& orientation); + const QVector3D& position(void) const; void setPosition(const QVector3D& position); @@ -35,7 +39,7 @@ void yaw(qreal angleInDegrees); void roll(qreal angleInDegrees); -public: +private: QVector3D mPosition; QQuaternion mOrientation; }; Modified: trunk/QtOgreFramework/EngineTest/media/scripts/update.js =================================================================== --- trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-08-03 20:31:01 UTC (rev 2955) +++ trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-08-04 22:01:38 UTC (rev 2956) @@ -22,23 +22,23 @@ function processInput() { var pos = camera.position; - var dir = -camera.zAxis; + var dir = camera.zAxis; var right = camera.xAxis; if(keyboard.isPressed(Qt.Key_W)) { - camera.translate(dir); + camera.translate(-dir.x(), -dir.y(), -dir.z()); } if(keyboard.isPressed(Qt.Key_S)) { - camera.translate(-dir.x(), -dir.y(), -dir.z()); + camera.translate(dir.x(), dir.y(), dir.z()); } if(keyboard.isPressed(Qt.Key_A)) { - camera.translate(right); + camera.translate(-right.x(), -right.y(), -right.z()); } if(keyboard.isPressed(Qt.Key_D)) { - camera.translate(-right.x(), -right.y(), -right.z()); + camera.translate(right); } var milliSecondsElapsed = globals.currentFrameTime - globals.previousFrameTime; Modified: trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-08-03 20:31:01 UTC (rev 2955) +++ trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-08-04 22:01:38 UTC (rev 2956) @@ -187,7 +187,7 @@ //QVector3D target = camera->position() - camera->zAxis(); //mCamera->lookAt(target.x(), target.y(), target.z()); - mCamera->setOrientation(Ogre::Quaternion(camera->mOrientation.scalar(), camera->mOrientation.x(), camera->mOrientation.y(), camera->mOrientation.z())); + mCamera->setOrientation(Ogre::Quaternion(camera->orientation().scalar(), camera->orientation().x(), camera->orientation().y(), camera->orientation().z())); mCamera->setFOVy(Ogre::Radian(camera->fieldOfView())); } Modified: trunk/QtOgreFramework/EngineTest/source/Object.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/Object.cpp 2010-08-03 20:31:01 UTC (rev 2955) +++ trunk/QtOgreFramework/EngineTest/source/Object.cpp 2010-08-04 22:01:38 UTC (rev 2956) @@ -5,7 +5,16 @@ { } +const QQuaternion& Object::orientation(void) const +{ + return mOrientation; +} +void Object::setOrientation(const QQuaternion& orientation) +{ + mOrientation = orientation; +} + const QVector3D& Object::position(void) const { return mPosition; @@ -16,11 +25,29 @@ mPosition = position; } +const QVector3D Object::xAxis(void) const +{ + QVector3D axis(1,0,0); + return mOrientation.rotatedVector(axis); +} +const QVector3D Object::yAxis(void) const +{ + QVector3D axis(0,1,0); + return mOrientation.rotatedVector(axis); +} + +const QVector3D Object::zAxis(void) const +{ + QVector3D axis(0,0,1); + return mOrientation.rotatedVector(axis); +} + void Object::translate(const QVector3D & vector) { mPosition += vector; } + void Object::translate(qreal x, qreal y, qreal z) { mPosition += QVector3D(x,y,z); @@ -43,22 +70,4 @@ { QQuaternion rotation = QQuaternion::fromAxisAndAngle(QVector3D(0,0,1), angleInDegrees); mOrientation *= rotation; -} - -const QVector3D Object::xAxis(void) const -{ - QVector3D axis(1,0,0); - return mOrientation.rotatedVector(axis); -} - -const QVector3D Object::yAxis(void) const -{ - QVector3D axis(0,1,0); - return mOrientation.rotatedVector(axis); -} - -const QVector3D Object::zAxis(void) const -{ - QVector3D axis(0,0,1); - return mOrientation.rotatedVector(axis); } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |