[Opal-commits] opal/samples/playpen main.cpp,1.3,1.4 playpen.vcproj,1.2,1.3
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-03 00:11:53
|
Update of /cvsroot/opal/opal/samples/playpen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12604/samples/playpen Modified Files: main.cpp playpen.vcproj Log Message: minor changes to opal src; added more to playpen sample app Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/main.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.cpp 1 Apr 2005 23:13:49 -0000 1.3 --- main.cpp 3 Apr 2005 00:11:41 -0000 1.4 *************** *** 22,32 **** /// Builds a wall of boxes centered at the origin. void createWall(unsigned int length, unsigned height, ! opal::Vec3r boxDim, ! opal::Matrix44r baseTransform = opal::Matrix44r()); ! /// Builds a tower of boxes centered at the origin. ! void createTower(unsigned int length, unsigned int width, ! unsigned height, opal::Vec3r boxDim, ! opal::Matrix44r baseTransform = opal::Matrix44r()); private: --- 22,34 ---- /// Builds a wall of boxes centered at the origin. void createWall(unsigned int length, unsigned height, ! const opal::Vec3r& boxDim, ! const opal::Matrix44r& baseTransform = opal::Matrix44r()); ! /// Builds a tower of boxes centered at the origin. For best ! /// results, make box length = 2 * box width to helps the ! /// corners line up correctly. ! void createTower(unsigned int width, unsigned int depth, ! unsigned height, const opal::Vec3r& boxDim, ! const opal::Matrix44r& baseTransform = opal::Matrix44r()); private: *************** *** 42,46 **** { mUseShadows = true; ! mCreationPoint.set(0, 20, 0); } --- 44,48 ---- { mUseShadows = true; ! mCreationPoint.set(0, 30, 0); } *************** *** 74,80 **** // Setup the initial camera position. ! ExampleApplication::mCamera->setPosition( ! Ogre::Vector3(0, 30, 50)); ! ExampleApplication::mCamera->lookAt(0, 0, 0); // Create a skybox. --- 76,81 ---- // Setup the initial camera position. ! mPhysicalCamera->setPosition(opal::Point3r(0, 30, 50)); ! mPhysicalCamera->lookAt(opal::Point3r(0, 0, 0)); // Create a skybox. *************** *** 162,166 **** if(mInputDevice->isKeyDown(KC_1) && mTimeUntilNextToggle <= 0) { ! Ogre::Vector3 boxDim(1, 1, 1); opal::Solid* s = mSimulator->createSolid(); s->setPosition(mCreationPoint); --- 163,167 ---- if(mInputDevice->isKeyDown(KC_1) && mTimeUntilNextToggle <= 0) { ! Ogre::Vector3 boxDim(0.5, 0.5, 0.5); opal::Solid* s = mSimulator->createSolid(); s->setPosition(mCreationPoint); *************** *** 177,181 **** if(mInputDevice->isKeyDown(KC_2) && mTimeUntilNextToggle <= 0) { ! Ogre::Real radius = 0.5; opal::Solid* s = mSimulator->createSolid(); s->setPosition(mCreationPoint); --- 178,182 ---- if(mInputDevice->isKeyDown(KC_2) && mTimeUntilNextToggle <= 0) { ! Ogre::Real radius = 0.25; opal::Solid* s = mSimulator->createSolid(); s->setPosition(mCreationPoint); *************** *** 189,194 **** } ! // Create a large box. ! if(mInputDevice->isKeyDown(KC_1) && mTimeUntilNextToggle <= 0) { Ogre::Vector3 boxDim(3, 3, 3); --- 190,195 ---- } ! // Create a medium box. ! if(mInputDevice->isKeyDown(KC_3) && mTimeUntilNextToggle <= 0) { Ogre::Vector3 boxDim(3, 3, 3); *************** *** 204,209 **** } ! // Create a large sphere. ! if(mInputDevice->isKeyDown(KC_2) && mTimeUntilNextToggle <= 0) { Ogre::Real radius = 1.5; --- 205,210 ---- } ! // Create a medium sphere. ! if(mInputDevice->isKeyDown(KC_4) && mTimeUntilNextToggle <= 0) { Ogre::Real radius = 1.5; *************** *** 219,226 **** } ! // Create a wall. if(mInputDevice->isKeyDown(KC_5) && mTimeUntilNextToggle <= 0) { ! createWall(5, 5, opal::Vec3r(2, 1, 1)); // Reset the timer for toggle keys. --- 220,266 ---- } ! // Create a large box. if(mInputDevice->isKeyDown(KC_5) && mTimeUntilNextToggle <= 0) { ! Ogre::Vector3 boxDim(16, 16, 16); ! opal::Solid* s = mSimulator->createSolid(); ! s->setPosition(mCreationPoint); ! opal::BoxShapeData data; ! data.dimensions.set(boxDim[0], boxDim[1], boxDim[2]); ! s->addShape(data); ! createPhysicalEntityBox("", "Plastic/Red", boxDim, s); ! ! // Reset the timer for toggle keys. ! mTimeUntilNextToggle = 0.3; ! } ! ! // Create a large sphere. ! if(mInputDevice->isKeyDown(KC_6) && mTimeUntilNextToggle <= 0) ! { ! Ogre::Real radius = 8; ! opal::Solid* s = mSimulator->createSolid(); ! s->setPosition(mCreationPoint); ! opal::SphereShapeData data; ! data.radius = radius; ! s->addShape(data); ! createPhysicalEntitySphere("", "Plastic/Blue", radius, s); ! ! // Reset the timer for toggle keys. ! mTimeUntilNextToggle = 0.3; ! } ! ! // Create a wall. ! if(mInputDevice->isKeyDown(KC_7) && mTimeUntilNextToggle <= 0) ! { ! createWall(10, 10, opal::Vec3r(2, 0.5, 1)); ! ! // Reset the timer for toggle keys. ! mTimeUntilNextToggle = 0.3; ! } ! ! // Create a tower. ! if(mInputDevice->isKeyDown(KC_8) && mTimeUntilNextToggle <= 0) ! { ! createTower(3, 3, 6, opal::Vec3r(2, 1, 1)); // Reset the timer for toggle keys. *************** *** 229,233 **** // The following code updates the camera's position. ! Ogre::Vector3 cameraDir = Ogre::Vector3::ZERO; bool cameraMoved = false; --- 269,273 ---- // The following code updates the camera's position. ! opal::Vec3r cameraDir; bool cameraMoved = false; *************** *** 236,240 **** { // Move camera left. ! cameraDir.x -= (dt * mMoveSpeed); cameraMoved = true; } --- 276,280 ---- { // Move camera left. ! cameraDir[0] -= (dt * mMoveSpeed); cameraMoved = true; } *************** *** 244,248 **** { // Move camera right. ! cameraDir.x += (dt * mMoveSpeed); cameraMoved = true; } --- 284,288 ---- { // Move camera right. ! cameraDir[0] += (dt * mMoveSpeed); cameraMoved = true; } *************** *** 252,256 **** { // Move camera forward. ! cameraDir.z -= (dt * mMoveSpeed); cameraMoved = true; } --- 292,296 ---- { // Move camera forward. ! cameraDir[2] -= (dt * mMoveSpeed); cameraMoved = true; } *************** *** 260,264 **** { // Move camera backward. ! cameraDir.z += (dt * mMoveSpeed); cameraMoved = true; } --- 300,304 ---- { // Move camera backward. ! cameraDir[2] += (dt * mMoveSpeed); cameraMoved = true; } *************** *** 270,274 **** // Use the camera dir vector to translate the camera. ! ExampleApplication::mCamera->moveRelative(cameraDir); // Toggle shadows. --- 310,314 ---- // Use the camera dir vector to translate the camera. ! mPhysicalCamera->moveRelative(cameraDir); // Toggle shadows. *************** *** 290,295 **** } ! // Toggle HUD. ! if (mInputDevice->isKeyDown(KC_H) && mTimeUntilNextToggle <= 0) { mStatsOn = !mStatsOn; --- 330,335 ---- } ! // Toggle GUI. ! if (mInputDevice->isKeyDown(KC_G) && mTimeUntilNextToggle <= 0) { mStatsOn = !mStatsOn; *************** *** 321,326 **** // the last poll. This data can be used to rotate the camera // around its X and Y axes (pitch and yaw, respectively). ! Ogre::Radian rotY(-mInputDevice->getMouseRelativeX() * mRotateSpeed); ! Ogre::Radian rotX(-mInputDevice->getMouseRelativeY() * mRotateSpeed); // The following code checks the mouse button state. --- 361,370 ---- // the last poll. This data can be used to rotate the camera // around its X and Y axes (pitch and yaw, respectively). ! Ogre::Degree rotY = -mInputDevice->getMouseRelativeX() * mRotateSpeed; ! Ogre::Degree rotX = -mInputDevice->getMouseRelativeY() * mRotateSpeed; ! ! // Use the relative mouse motion to rotate the camera. ! mPhysicalCamera->yawRelative(rotY.valueDegrees()); ! mPhysicalCamera->yawRelative(rotX.valueDegrees()); // The following code checks the mouse button state. *************** *** 328,335 **** { // The right mouse button is down. - - // Use the relative mouse motion to rotate the camera. - ExampleApplication::mCamera->yaw(rotY); - ExampleApplication::mCamera->pitch(rotX); } else --- 372,375 ---- *************** *** 343,350 **** void PlaypenApp::createWall(unsigned int length, unsigned height, ! opal::Vec3r boxDim, opal::Matrix44r baseTransform) { - opal::Matrix44r tempTransform; - for (unsigned int l=0; l<length; ++l) { --- 383,388 ---- void PlaypenApp::createWall(unsigned int length, unsigned height, ! const opal::Vec3r& boxDim, const opal::Matrix44r& baseTransform) { for (unsigned int l=0; l<length; ++l) { *************** *** 357,367 **** } ! tempTransform = baseTransform; ! tempTransform.translate(l * boxDim[0] + 0.5 * boxDim[0] - 0.5 * length * boxDim[0] + offset, h * boxDim[1] + 0.5 * boxDim[1], 0); opal::Solid* s = mSimulator->createSolid(); ! s->setTransform(tempTransform); //s->setSleeping(true); opal::BoxShapeData boxData; --- 395,405 ---- } ! opal::Matrix44r blockTransform = baseTransform; ! blockTransform.translate(l * boxDim[0] + 0.5 * boxDim[0] - 0.5 * length * boxDim[0] + offset, h * boxDim[1] + 0.5 * boxDim[1], 0); opal::Solid* s = mSimulator->createSolid(); ! s->setTransform(blockTransform); //s->setSleeping(true); opal::BoxShapeData boxData; *************** *** 374,381 **** } ! void PlaypenApp::createTower(unsigned int length, unsigned int width, ! unsigned height, opal::Vec3r boxDim, opal::Matrix44r baseTransform) { } } --- 412,486 ---- } ! void PlaypenApp::createTower(unsigned int width, unsigned int depth, ! unsigned height, const opal::Vec3r& boxDim, ! const opal::Matrix44r& baseTransform) { + for (unsigned int wall=0; wall<4; ++wall) + { + opal::Matrix44r wallBaseTransform = baseTransform; + opal::real length = 0; + + switch(wall) + { + case 0: + length = width; + wallBaseTransform.translate( + -(opal::real)0.25 * boxDim[0], 0, + -(opal::real)0.5 * depth * boxDim[0]); + break; + case 1: + length = width; + wallBaseTransform.translate( + (opal::real)0.25 * boxDim[0], 0, + (opal::real)0.5 * depth * boxDim[0]); + wallBaseTransform.rotate(180, 0, 1, 0); + break; + case 2: + length = depth; + wallBaseTransform.translate( + -(opal::real)0.5 * width * boxDim[0], 0, 0); + wallBaseTransform.rotate(90, 0, 1, 0); + wallBaseTransform.translate( + -(opal::real)0.25 * boxDim[0], 0, 0); + break; + case 3: + length = depth; + wallBaseTransform.translate( + (opal::real)0.5 * width * boxDim[0], 0, 0); + wallBaseTransform.rotate(-90, 0, 1, 0); + wallBaseTransform.translate( + -(opal::real)0.25 * boxDim[0], 0, 0); + break; + default: + assert(false); + break; + } + + for (unsigned int l=0; l<length; ++l) + { + for (unsigned int h=0; h<height; ++h) + { + opal::real offset = 0; + if (h % 2 == 0) + { + offset = (opal::real)0.5 * boxDim[0]; + } + + opal::Matrix44r blockTransform = wallBaseTransform; + blockTransform.translate(l * boxDim[0] + + 0.5 * boxDim[0] - 0.5 * length * boxDim[0] + + offset, h * boxDim[1] + 0.5 * boxDim[1], 0); + opal::Solid* s = mSimulator->createSolid(); + s->setTransform(blockTransform); + //s->setSleeping(true); + opal::BoxShapeData boxData; + boxData.dimensions = boxDim; + s->addShape(boxData); + Ogre::Vector3 boxDimensions(boxDim[0], boxDim[1], boxDim[2]); + createPhysicalEntityBox("", "Plastic/Red", boxDimensions, s); + } + } + } } } Index: playpen.vcproj =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/playpen.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** playpen.vcproj 1 Apr 2005 23:13:49 -0000 1.2 --- playpen.vcproj 3 Apr 2005 00:11:41 -0000 1.3 *************** *** 33,36 **** --- 33,37 ---- <Tool Name="VCLinkerTool" + AdditionalOptions="/STACK:20000000" AdditionalDependencies="ogremain_d.lib opal-ode_d.lib" OutputFile="../win32bin/debug/playpen.exe" *************** *** 84,87 **** --- 85,89 ---- <Tool Name="VCLinkerTool" + AdditionalOptions="/STACK:10000000" AdditionalDependencies="ogremain.lib opal-ode.lib" OutputFile="../win32bin/release/playpen.exe" |