From: <es...@us...> - 2010-08-01 17:25:38
|
Revision: 2954 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2954&view=rev Author: esuvs Date: 2010-08-01 17:25:31 +0000 (Sun, 01 Aug 2010) Log Message: ----------- Added base Object class. Modified Paths: -------------- trunk/QtOgreFramework/EngineTest/CMakeLists.txt trunk/QtOgreFramework/EngineTest/include/Camera.h trunk/QtOgreFramework/EngineTest/media/scripts/update.js trunk/QtOgreFramework/EngineTest/source/Camera.cpp trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp Added Paths: ----------- trunk/QtOgreFramework/EngineTest/include/Object.h trunk/QtOgreFramework/EngineTest/source/Object.cpp Modified: trunk/QtOgreFramework/EngineTest/CMakeLists.txt =================================================================== --- trunk/QtOgreFramework/EngineTest/CMakeLists.txt 2010-07-30 16:30:15 UTC (rev 2953) +++ trunk/QtOgreFramework/EngineTest/CMakeLists.txt 2010-08-01 17:25:31 UTC (rev 2954) @@ -4,12 +4,13 @@ SET(SRC_FILES source/Camera.cpp + source/EngineTestGameLogic.cpp source/Globals.cpp + source/Keyboard.cpp source/Light.cpp source/main.cpp source/Mouse.cpp - source/EngineTestGameLogic.cpp - source/Keyboard.cpp + source/Object.cpp source/ObjectStore.cpp source/ScriptEditorWidget.cpp ) @@ -21,6 +22,7 @@ include/Keyboard.h include/Light.h include/Mouse.h + include/Object.h include/ObjectStore.h include/ScriptEditorWidget.h ) Modified: trunk/QtOgreFramework/EngineTest/include/Camera.h =================================================================== --- trunk/QtOgreFramework/EngineTest/include/Camera.h 2010-07-30 16:30:15 UTC (rev 2953) +++ trunk/QtOgreFramework/EngineTest/include/Camera.h 2010-08-01 17:25:31 UTC (rev 2954) @@ -1,42 +1,25 @@ #ifndef CAMERA_H_ #define CAMERA_H_ -#include <QObject> +#include "Object.h" + #include <QScriptEngine> #include <QVector3D> -class Camera : public QObject +class Camera : public Object { Q_OBJECT public: - Camera(QObject * parent = 0); + Camera(QObject* parent = 0); - Q_PROPERTY(QVector3D direction READ direction WRITE setDirection) Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView) - Q_PROPERTY(QVector3D position READ position WRITE setPosition) - Q_PROPERTY(QVector3D right READ right WRITE setRight) - const QVector3D& direction(void) const; - void setDirection(const QVector3D& direction); - float fieldOfView(void) const; void setFieldOfView(float fieldOfView); - const QVector3D& position(void) const; - void setPosition(const QVector3D& position); - - const QVector3D& right(void) const; - void setRight(const QVector3D& right); - -public slots: - void pitch(float angleInDegrees); - -private: - QVector3D mDirection; +protected: float mFieldOfView; - QVector3D mPosition; - QVector3D mRight; }; #endif //CAMERA_H_ \ No newline at end of file Added: trunk/QtOgreFramework/EngineTest/include/Object.h =================================================================== --- trunk/QtOgreFramework/EngineTest/include/Object.h (rev 0) +++ trunk/QtOgreFramework/EngineTest/include/Object.h 2010-08-01 17:25:31 UTC (rev 2954) @@ -0,0 +1,40 @@ +#ifndef OBJECT_H_ +#define OBJECT_H_ + +#include <QMatrix4x4.h> +#include <QObject> +#include <QScriptEngine> +#include <QVector3D> + +class Object : public QObject +{ + Q_OBJECT + +public: + Object(QObject* parent = 0); + + Q_PROPERTY(QVector3D direction READ direction) + Q_PROPERTY(QVector3D position READ position WRITE setPosition) + Q_PROPERTY(QVector3D right READ right) + + const QVector3D direction(void) const; + + const QVector3D& position(void) const; + void setPosition(const QVector3D& position); + + const QVector3D right(void) const; + + const QVector3D up(void) const; + +public slots: + void pitch(float angleInDegrees); + void yaw(float angleInDegrees); + +private: + QVector3D mDirection; + QVector3D mPosition; + QVector3D mRight; + QMatrix4x4 mRotation; +}; + +#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-07-30 16:30:15 UTC (rev 2953) +++ trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-08-01 17:25:31 UTC (rev 2954) @@ -62,9 +62,15 @@ }*/ if(mouse.isPressed(Qt.RightButton)) { + mouseDeltaX = mouse.position.x() - mouse.previousPosition.x(); + camera.yaw(-mouseDeltaX * secondsElapsed * 10); + } + if(mouse.isPressed(Qt.RightButton)) + { mouseDeltaY = mouse.position.y() - mouse.previousPosition.y(); - camera.pitch(-mouseDeltaY * secondsElapsed); + camera.pitch(-mouseDeltaY * secondsElapsed * 10); } + wheelDelta = mouse.getWheelDelta(); fov = camera.fieldOfView; tempFOV = -wheelDelta * 0.001; Modified: trunk/QtOgreFramework/EngineTest/source/Camera.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/Camera.cpp 2010-07-30 16:30:15 UTC (rev 2953) +++ trunk/QtOgreFramework/EngineTest/source/Camera.cpp 2010-08-01 17:25:31 UTC (rev 2954) @@ -1,26 +1,11 @@ #include "Camera.h" -#include <QMatrix4x4> - Camera::Camera(QObject * parent) - :QObject(parent) + :Object(parent) { - mPosition = QVector3D(0,0,0); - mDirection = QVector3D(0,0,-1); - mRight = QVector3D(1,0,0); mFieldOfView = 1.0; } -const QVector3D& Camera::direction(void) const -{ - return mDirection; -} - -void Camera::setDirection(const QVector3D& direction) -{ - mDirection = direction; -} - float Camera::fieldOfView(void) const { return mFieldOfView; @@ -29,32 +14,4 @@ void Camera::setFieldOfView(float fieldOfView) { mFieldOfView = fieldOfView; -} - -const QVector3D& Camera::position(void) const -{ - return mPosition; -} - -void Camera::setPosition(const QVector3D& position) -{ - mPosition = position; -} - -const QVector3D& Camera::right(void) const -{ - return mRight; -} - -void Camera::setRight(const QVector3D& right) -{ - mRight = right; -} - -void Camera::pitch(float angleInDegrees) -{ - QMatrix4x4 transform; - transform.rotate(angleInDegrees, mRight); - - mDirection = mDirection * transform; } \ No newline at end of file Modified: trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-07-30 16:30:15 UTC (rev 2953) +++ trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-08-01 17:25:31 UTC (rev 2954) @@ -59,7 +59,7 @@ //mApplication->ogreRenderWindow()->addViewport(mCamera)->setBackgroundColour(Ogre::ColourValue::Black); - mSceneManager->setAmbientLight( Ogre::ColourValue( 0.3, 0.3, 0.3 ) ); + mSceneManager->setAmbientLight( Ogre::ColourValue( 0.3f, 0.3f, 0.3f ) ); mTime = new QTime; mTime->start(); Added: trunk/QtOgreFramework/EngineTest/source/Object.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/Object.cpp (rev 0) +++ trunk/QtOgreFramework/EngineTest/source/Object.cpp 2010-08-01 17:25:31 UTC (rev 2954) @@ -0,0 +1,82 @@ +#include "Object.h" + +#include <QMatrix4x4> + +Object::Object(QObject * parent) + :QObject(parent) +{ + mPosition = QVector3D(0,0,0); + + + mDirection = QVector3D(0,0,-1); + mRight = QVector3D(1,0,0); + + mRotation.setToIdentity(); + + //mTransformation.setToIdentity(); +} + +const QVector3D Object::direction(void) const +{ + QVector4D z(0,0,1,0); + return (mRotation * z).toVector3D(); + //return mDirection; +} + +/*void Object::setDirection(const QVector3D& direction) +{ + mDirection = direction; +}*/ + +const QVector3D& Object::position(void) const +{ + return mPosition; + //return mTransformation.row(3).toVector3DAffine(); +} + +void Object::setPosition(const QVector3D& position) +{ + mPosition = position; + /*QVector4D posTemp = position.toVector4D(); + posTemp.setW(mTransformation.row(3).w()); + mTransformation.setRow(3, posTemp);*/ +} + +const QVector3D Object::right(void) const +{ + QVector4D x(1,0,0,0); + return (mRotation * x).toVector3D(); + //return mRight; +} + +/*void Object::setRight(const QVector3D& right) +{ + mRight = right; +}*/ + +void Object::pitch(float angleInDegrees) +{ + /*QMatrix4x4 transform; + transform.rotate(angleInDegrees, mRight); + + mDirection = mDirection * transform;*/ + + mRotation.rotate(angleInDegrees, right()); +} + +void Object::yaw(float angleInDegrees) +{ + /*QMatrix4x4 transform; + transform.rotate(angleInDegrees, mRight); + + mDirection = mDirection * transform;*/ + + mRotation.rotate(angleInDegrees, up()); +} + +const QVector3D Object::up(void) const +{ + QVector4D y(0,1,0,0); + return (mRotation * y).toVector3D(); + //return mRight; +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |