From: <es...@us...> - 2010-07-17 08:33:34
|
Revision: 2942 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2942&view=rev Author: esuvs Date: 2010-07-17 08:33:28 +0000 (Sat, 17 Jul 2010) Log Message: ----------- Scripting now moves blue light round in circles. Modified Paths: -------------- trunk/QtOgreFramework/EngineTest/include/EngineTestGameLogic.h trunk/QtOgreFramework/EngineTest/media/scripts/update.js trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp trunk/QtOgreFramework/EngineTest/ui/ScriptEditorWidget.ui Modified: trunk/QtOgreFramework/EngineTest/include/EngineTestGameLogic.h =================================================================== --- trunk/QtOgreFramework/EngineTest/include/EngineTestGameLogic.h 2010-07-16 02:04:19 UTC (rev 2941) +++ trunk/QtOgreFramework/EngineTest/include/EngineTestGameLogic.h 2010-07-17 08:33:28 UTC (rev 2942) @@ -64,9 +64,12 @@ int mLastFrameTime; int mCurrentTime; + QVariant mCurrentTimeVariant; bool mIsFirstFrame; + quint32 m_uTimeSinceStart; + float mCameraSpeed; StyleSettingsWidget* mStyleSettingsWidget; Modified: trunk/QtOgreFramework/EngineTest/media/scripts/update.js =================================================================== --- trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-07-16 02:04:19 UTC (rev 2941) +++ trunk/QtOgreFramework/EngineTest/media/scripts/update.js 2010-07-17 08:33:28 UTC (rev 2942) @@ -1,49 +1,61 @@ -var pos = camera.position; -var dir = camera.direction; -var right = camera.right; -if(keyboard.isPressed(Qt.Key_W)) +processInput(); +updateLights(); + +function updateLights() { -// pos += dir; - pos.setX(pos.x() + dir.x()); - pos.setY(pos.y() + dir.y()); - pos.setZ(pos.z() + dir.z()); + var x = Math.sin(currentTime / 1000); + var y = Math.cos(currentTime / 1000); + + objectStore.getObject('BlueLight').position = new QVector3D(x * 100,y * 100, 0); } -if(keyboard.isPressed(Qt.Key_S)) + +function processInput() { - pos.setX(pos.x() - dir.x()); - pos.setY(pos.y() - dir.y()); - pos.setZ(pos.z() - dir.z()); -} -if(keyboard.isPressed(Qt.Key_A)) -{ - pos.setX(pos.x() - right.x()); - pos.setY(pos.y() - right.y()); - pos.setZ(pos.z() - right.z()); -} -if(keyboard.isPressed(Qt.Key_D)) -{ - pos.setX(pos.x() + right.x()); - pos.setY(pos.y() + right.y()); - pos.setZ(pos.z() + right.z()); -} -camera.position = pos; -if(mouse.isPressed(Qt.RightButton)) -{ - mouseDelta = mouse.computeDelta(); - camera.yaw(new OgreRadian(-mouseDelta.x * 0.01)); -} -if(mouse.isPressed(Qt.RightButton)) -{ - mouseDelta = mouse.computeDelta(); - camera.pitch(new OgreRadian(-mouseDelta.y * 0.01)); -} -wheelDelta = mouse.getWheelDelta(); -//print('wheelDelta = ', wheelDelta); -fov = camera.getFOVy(); -//print('old fov = ', fov.valueRadians); -tempFOV = new OgreRadian(-wheelDelta * 0.001); -fov.valueRadians = fov.valueRadians + tempFOV.valueRadians; -//print('new fov = ', fov.valueRadians); -camera.setFOVy(fov); - -print('Colour = ', objectStore.getObject('BlueLight').Colour); \ No newline at end of file + var pos = camera.position; + var dir = camera.direction; + var right = camera.right; + if(keyboard.isPressed(Qt.Key_W)) + { + // pos += dir; + pos.setX(pos.x() + dir.x()); + pos.setY(pos.y() + dir.y()); + pos.setZ(pos.z() + dir.z()); + } + if(keyboard.isPressed(Qt.Key_S)) + { + pos.setX(pos.x() - dir.x()); + pos.setY(pos.y() - dir.y()); + pos.setZ(pos.z() - dir.z()); + } + if(keyboard.isPressed(Qt.Key_A)) + { + pos.setX(pos.x() - right.x()); + pos.setY(pos.y() - right.y()); + pos.setZ(pos.z() - right.z()); + } + if(keyboard.isPressed(Qt.Key_D)) + { + pos.setX(pos.x() + right.x()); + pos.setY(pos.y() + right.y()); + pos.setZ(pos.z() + right.z()); + } + camera.position = pos; + if(mouse.isPressed(Qt.RightButton)) + { + mouseDelta = mouse.computeDelta(); + camera.yaw(new OgreRadian(-mouseDelta.x * 0.01)); + } + if(mouse.isPressed(Qt.RightButton)) + { + mouseDelta = mouse.computeDelta(); + camera.pitch(new OgreRadian(-mouseDelta.y * 0.01)); + } + wheelDelta = mouse.getWheelDelta(); + //print('wheelDelta = ', wheelDelta); + fov = camera.getFOVy(); + //print('old fov = ', fov.valueRadians); + tempFOV = new OgreRadian(-wheelDelta * 0.001); + fov.valueRadians = fov.valueRadians + tempFOV.valueRadians; + //print('new fov = ', fov.valueRadians); + camera.setFOVy(fov); +} \ No newline at end of file Modified: trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp =================================================================== --- trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-07-16 02:04:19 UTC (rev 2941) +++ trunk/QtOgreFramework/EngineTest/source/EngineTestGameLogic.cpp 2010-07-17 08:33:28 UTC (rev 2942) @@ -53,6 +53,9 @@ { initScriptEngine(); + /*QScriptValue currentTimeScriptValue = scriptEngine->newVariant(mCurrentTimeVariant); + scriptEngine->globalObject().setProperty("currentTime", currentTimeScriptValue);*/ + QScriptValue keyboardScriptValue = scriptEngine->newQObject(&keyboard); scriptEngine->globalObject().setProperty("keyboard", keyboardScriptValue); @@ -159,6 +162,11 @@ mLastFrameTime = mCurrentTime; mCurrentTime = mTime->elapsed(); + mCurrentTimeVariant = mCurrentTime; + + QScriptValue currentTimeScriptValue = scriptEngine->newVariant(mCurrentTimeVariant); + scriptEngine->globalObject().setProperty("currentTime", currentTimeScriptValue); + float timeElapsedInSeconds = (mCurrentTime - mLastFrameTime) / 1000.0f; for (Ogre::SceneManager::MovableObjectIterator moi = mSceneManager->getMovableObjectIterator("Entity"); moi.hasMoreElements(); moi.moveNext()) Modified: trunk/QtOgreFramework/EngineTest/ui/ScriptEditorWidget.ui =================================================================== --- trunk/QtOgreFramework/EngineTest/ui/ScriptEditorWidget.ui 2010-07-16 02:04:19 UTC (rev 2941) +++ trunk/QtOgreFramework/EngineTest/ui/ScriptEditorWidget.ui 2010-07-17 08:33:28 UTC (rev 2942) @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>508</width> + <width>714</width> <height>425</height> </rect> </property> @@ -50,7 +50,14 @@ </widget> </item> <item row="1" column="0" colspan="5"> - <widget class="QPlainTextEdit" name="m_pTextEdit"/> + <widget class="QPlainTextEdit" name="m_pTextEdit"> + <property name="font"> + <font> + <family>Courier New</family> + <pointsize>12</pointsize> + </font> + </property> + </widget> </item> </layout> </widget> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |