[Opal-commits] opal/samples/simple SConstruct,1.1,1.2 main.cpp,1.1,1.2 simple.suo,1.1,1.2
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-06-25 06:45:51
|
Update of /cvsroot/opal/opal/samples/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22427/samples/simple Modified Files: SConstruct main.cpp simple.suo Log Message: Finished writing 'simple' sample app and its SConstruct file. Index: SConstruct =================================================================== RCS file: /cvsroot/opal/opal/samples/simple/SConstruct,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SConstruct 24 Jun 2005 23:38:09 -0000 1.1 --- SConstruct 25 Jun 2005 06:45:41 -0000 1.2 *************** *** 13,17 **** env = Environment( ENV = os.environ, ! LIBS = ['opal-ode', 'OgreMain'], options = opts ) --- 13,17 ---- env = Environment( ENV = os.environ, ! LIBS = ['GL', 'GLU', 'SDL', 'SDLmain', 'opal-ode'], options = opts ) *************** *** 20,31 **** LIBPATH = env['extra_lib_path']) ! if env['PLATFORM'] != 'win32': ! env.Append(CXXFLAGS = ['-DGCC_3_1', '-DEXT_HASH']) # Build the executable. ! exe = env.Program('playpen', sources) # Install the executable. ! inst = env.Install('../bin/release', exe) # Tell scons to build and install the executable by default. --- 20,36 ---- LIBPATH = env['extra_lib_path']) ! # Note: This doesn't seem to build on Win32. Try the Visual Studio project file ! # or bug the developers to fix this SConstruct for Win32. ! if env['PLATFORM'] == 'win32': ! env.Replace(LIBS = ['opengl32', 'glu32', 'SDL', 'SDLmain', 'opal-ode']) ! ! # Generate command line help text ! env.Help(opts.GenerateHelpText(env)) # Build the executable. ! exe = env.Program('simple', sources) # Install the executable. ! inst = env.Install('../bin/simple', exe) # Tell scons to build and install the executable by default. Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/simple/main.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.cpp 24 Jun 2005 23:38:09 -0000 1.1 --- main.cpp 25 Jun 2005 06:45:41 -0000 1.2 *************** *** 32,38 **** // to simulated physics in general). It starts with a simple scene and // allows the user to create new physical objects via keypresses. This ! // application is very basic and contains extremely verbose comments. ! // Feel free to use this as a starting point for your own OPAL applications, ! // if you'd like. // // This application uses OpenGL for rendering and SDL (www.libsdl.org) for --- 32,38 ---- // to simulated physics in general). It starts with a simple scene and // allows the user to create new physical objects via keypresses. This ! // application is very basic and contains extremely verbose comments. The ! // major steps are numbered for your convenience. Feel free to use this ! // as a starting point for your own OPAL applications, if you'd like. // // This application uses OpenGL for rendering and SDL (www.libsdl.org) for *************** *** 44,49 **** --- 44,52 ---- // 'Timer' is a simple class used to measure elapsed time between frames.) + #include <time.h> + #include <opal/opal.h> #include <sdl/SDL.h> + #include "Timer.h" #include "BoxEntity.h" *************** *** 96,101 **** gSimulator->setGravity(opal::Vec3r(0, (opal::real)-9.81, 0)); ! // 3. Create some initial Solids and Entities, and connect each ! // Solid to an Entity. Solids can move around and collide with // other Solids, but they're essentially invisible without some sort // of visual representation. The Entity class used in this --- 99,104 ---- gSimulator->setGravity(opal::Vec3r(0, (opal::real)-9.81, 0)); ! // 3. Create a ground platform by making a Solid and an Entity and ! // connecting them together. Solids can move around and collide with // other Solids, but they're essentially invisible without some sort // of visual representation. The Entity class used in this *************** *** 111,121 **** // multiple OPAL Shapes attached to it, one Solid could use // multiple Entities: one for each Shape. opal::Solid* platformSolid = gSimulator->createSolid(); ! // Make the platform Solid static. Dynamic Solids can move; static // Solids cannot. platformSolid->setStatic(true); ! // Add a box Shape to the Solid. Shapes describe a Solid's physical // boundaries. A Solid can use any number of Shapes, and each Shape // can be offset from the Solid's center. --- 114,126 ---- // multiple OPAL Shapes attached to it, one Solid could use // multiple Entities: one for each Shape. + + // 3a. Create the Solid for the platform. opal::Solid* platformSolid = gSimulator->createSolid(); ! // 3b. Make the platform Solid static. Dynamic Solids can move; static // Solids cannot. platformSolid->setStatic(true); ! // 3c. Add a box Shape to the Solid. Shapes describe a Solid's physical // boundaries. A Solid can use any number of Shapes, and each Shape // can be offset from the Solid's center. *************** *** 124,129 **** platformSolid->addShape(boxShape); ! // Make an Entity for the ground platform, set its visual dimensions to ! // match the physical box, attach it to the Solid, and add it to our // global list of Entities so it can get drawn. opalSamples::BoxEntity* groundEntity = new opalSamples::BoxEntity(); --- 129,134 ---- platformSolid->addShape(boxShape); ! // 3d. Make an Entity for the ground platform, set its visual dimensions ! // to match the physical box, attach it to the Solid, and add it to our // global list of Entities so it can get drawn. opalSamples::BoxEntity* groundEntity = new opalSamples::BoxEntity(); *************** *** 142,146 **** opal::real dt = (opal::real)timer.getElapsedSeconds(); ! // 5b. Check for user input. gQuit = processInput(); --- 147,153 ---- opal::real dt = (opal::real)timer.getElapsedSeconds(); ! // 5b. Check for user input. In this application we only care ! // about keyboard input for creating new objects, pausing the ! // simulation, and quitting. gQuit = processInput(); *************** *** 181,185 **** } ! // 6. Destroy the Entities. while (!gEntities.empty()) { --- 188,195 ---- } ! // 6. Close the OpenGL window. ! destroyWindow(); ! ! // 7. Destroy the Entities. while (!gEntities.empty()) { *************** *** 188,192 **** } ! // 7. Destroy the Simulator. This will automatically destroy everything // contained within the Simulator. gSimulator->destroy(); --- 198,202 ---- } ! // 8. Destroy the Simulator. This will automatically destroy everything // contained within the Simulator. gSimulator->destroy(); *************** *** 226,230 **** // Set key repeat rate (initial delay and interval between repeats, // both in milliseconds). ! SDL_EnableKeyRepeat(50, 50); // Setup OpenGL. --- 236,240 ---- // Set key repeat rate (initial delay and interval between repeats, // both in milliseconds). ! SDL_EnableKeyRepeat(300, 300); // Setup OpenGL. *************** *** 322,325 **** --- 332,344 ---- void createRandomObject() { + // Seed the random number generator (if it hasn't already happened) + // with the current time. + static bool seeded = false; + if (!seeded) + { + srand((unsigned int)time(NULL)); + seeded = true; + } + // Create a new Solid. opal::Solid* solid = gSimulator->createSolid(); *************** *** 327,336 **** opalSamples::Entity* entity = NULL; ! // Choose a random initial position. opal::real xMax = (opal::real)0.5 * gGroundDimensions[0]; opal::real zMax = (opal::real)0.5 * gGroundDimensions[2]; ! opal::Point3r pos(randomRealUniform(-xMax, xMax), 15, ! randomRealUniform(-zMax, zMax)); ! solid->setPosition(pos); // Choose a random type of object. --- 346,359 ---- opalSamples::Entity* entity = NULL; ! // Choose a random initial position and orientation. ! opal::Matrix44r transform; opal::real xMax = (opal::real)0.5 * gGroundDimensions[0]; opal::real zMax = (opal::real)0.5 * gGroundDimensions[2]; ! transform.translate(randomRealUniform(-xMax, xMax), ! randomRealUniform(15, 30), randomRealUniform(-zMax, zMax)); ! transform.rotate(randomRealUniform(0, 360), 1, 0, 0); ! transform.rotate(randomRealUniform(0, 360), 0, 1, 0); ! transform.rotate(randomRealUniform(0, 360), 0, 0, 1); ! solid->setTransform(transform); // Choose a random type of object. *************** *** 338,341 **** --- 361,369 ---- int objectType = (int)(numObjectTypes * rand() / (RAND_MAX + 1.0)); + // Choose a random color for the object. + opal::Vec3r color(randomRealUniform(0, (opal::real)0.7), + randomRealUniform(0, (opal::real)0.7), + randomRealUniform(0, (opal::real)0.7)); + // Add Shapes to the Solid and attach an Entity. The Shapes and // visual representation depend on the object type. *************** *** 346,355 **** // Simple box. opal::BoxShapeData boxShape; ! boxShape.dimensions[0] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! boxShape.dimensions[1] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! boxShape.dimensions[2] = randomRealUniform((opal::real)0.5, ! (opal::real)5); solid->addShape(boxShape); --- 374,380 ---- // Simple box. opal::BoxShapeData boxShape; ! boxShape.dimensions[0] = randomRealUniform((opal::real)0.5, 7); ! boxShape.dimensions[1] = randomRealUniform((opal::real)0.5, 7); ! boxShape.dimensions[2] = randomRealUniform((opal::real)0.5, 7); solid->addShape(boxShape); *************** *** 357,361 **** ((opalSamples::BoxEntity*)entity)->setDimensions( boxShape.dimensions); - entity->attachToSolid(solid); break; } --- 382,385 ---- *************** *** 363,380 **** { // Simple sphere. ! // TODO ! opal::BoxShapeData boxShape; ! boxShape.dimensions[0] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! boxShape.dimensions[1] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! boxShape.dimensions[2] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! solid->addShape(boxShape); ! entity = new opalSamples::BoxEntity(); ! ((opalSamples::BoxEntity*)entity)->setDimensions( ! boxShape.dimensions); ! entity->attachToSolid(solid); break; } --- 387,397 ---- { // Simple sphere. ! opal::SphereShapeData sphereShape; ! sphereShape.radius = randomRealUniform((opal::real)0.25, 3); ! solid->addShape(sphereShape); ! entity = new opalSamples::SphereEntity(); ! ((opalSamples::SphereEntity*)entity)->setRadius( ! sphereShape.radius); break; } *************** *** 382,399 **** { // Simple capsule. ! // TODO ! opal::BoxShapeData boxShape; ! boxShape.dimensions[0] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! boxShape.dimensions[1] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! boxShape.dimensions[2] = randomRealUniform((opal::real)0.5, ! (opal::real)5); ! solid->addShape(boxShape); ! entity = new opalSamples::BoxEntity(); ! ((opalSamples::BoxEntity*)entity)->setDimensions( ! boxShape.dimensions); ! entity->attachToSolid(solid); break; } --- 399,410 ---- { // Simple capsule. ! opal::CapsuleShapeData capsuleShape; ! capsuleShape.radius = randomRealUniform((opal::real)0.25, 3); ! capsuleShape.length = randomRealUniform((opal::real)0.5, 7); ! solid->addShape(capsuleShape); ! entity = new opalSamples::CapsuleEntity(); ! ((opalSamples::CapsuleEntity*)entity)->setDimensions( ! capsuleShape.radius, capsuleShape.length); break; } *************** *** 402,405 **** --- 413,422 ---- } + // Set the new Entity's color. + entity->setColor(color[0], color[1], color[2]); + + // Attach the new Entity to the Solid. + entity->attachToSolid(solid); + // Add the new Entity to the global list so it can get drawn. gEntities.push_back(entity); Index: simple.suo =================================================================== RCS file: /cvsroot/opal/opal/samples/simple/simple.suo,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsk4CCaU and /tmp/cvsM7gm0M differ |