void BulletTestApp::setup() { // Set up lighting mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 ); mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() ); mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) ); mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) ); mLight->enable(); // Load meshes loadModels(); // Create a Bullet dynamics world mWorld = bullet::createWorld(); // Load texture mTexGround = gl::Texture( loadImage( loadResource( RES_TEX_GROUND ))); mTexBackBoard = gl::Texture( loadImage( loadResource( RES_TEX_BACKBOARD ))); mTexRing = gl::Texture( loadImage( loadResource( RES_TEX_RING ))); mTexBasketBall = gl::Texture( loadImage( loadResource( RES_TEX_BASKETBALL ))); // Parameters mFrameRate = 0.0f; mPoint = 0; mViewX = -27; mViewY = -64; mViewZ = 0; mStrengthX = 0; mStrengthY = 44; mStrengthZ = 33; // mStrengthY = 0; // mStrengthZ = 0; mParams = params::InterfaceGl( "Params", Vec2i( 200, 250) ); mParams.addParam( "Frame Rate", &mFrameRate, "", true ); mParams.addParam( "Point" , &mPoint , "", true ); mParams.addText ( "View" ); mParams.addParam( "view_x" , &mViewX, "min=-100 max=100 step=1 keyIncr=7 keyDecr=4" ); mParams.addParam( "view_y" , &mViewY, "min=-100 max=100 step=1 keyIncr=8 keyDecr=5" ); mParams.addParam( "view_z" , &mViewZ, "min=-100 max=100 step=1 keyIncr=9 keyDecr=6" ); mParams.addText ( "Strength" ); mParams.addParam( "strength_x" , &mStrengthX, "min=-100 max=100 step=1 keyIncr=q keyDecr=a" ); mParams.addParam( "strength_y" , &mStrengthY, "min=-100 max=100 step=1 keyIncr=w keyDecr=s" ); mParams.addParam( "strength_z" , &mStrengthZ, "min=-100 max=100 step=1 keyIncr=e keyDecr=d" ); // Initialize initTest(); // Run first resize to initialize view resize( ResizeEvent( getWindowSize() ) ); }
void BulletTestApp::setup() { mDragging = false; mFrameRate = 0.0f; mTest = 9; mTestPrev = mTest; // Set up lighting mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 ); mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() ); mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) ); mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) ); mLight->enable(); // Load meshes loadModels(); // Create a Bullet dynamics world mWorld = bullet::createWorld(); // Load texture mTexSquare = gl::Texture( loadImage( loadResource( RES_TEX_SQUARE ) ) ); mTexSphere = gl::Texture( loadImage( loadResource( RES_TEX_SPHERE ) ) ); mTexTerrain = gl::Texture( loadImage( loadResource( RES_TEX_TERRAIN ) ) ); mTexTerrain.setWrap( GL_REPEAT, GL_REPEAT ); mTexTerrain.unbind(); // Init terrain pointer mTerrain = 0; // Parameters mParams = params::InterfaceGl( "Params", Vec2i( 200, 120 ) ); mParams.addParam( "Frame Rate", &mFrameRate, "", true ); mParams.addParam( "Test", &mTest, "min=0 max=9 step=1 keyDecr=t keyIncr=T" ); mParams.addButton( "Drop", bind( &BulletTestApp::drop, this ), "key=space" ); mParams.addButton( "Screen shot", bind( &BulletTestApp::screenShot, this ), "key=s" ); mParams.addButton( "Quit", bind( &BulletTestApp::quit, this ), "key=q" ); // Initialize initTest(); // Run first resize to initialize view resize( ResizeEvent( getWindowSize() ) ); }
void BulletTestApp::setup() { // Set test mode mTest = 0; mTestPrev = mTest; // Set up lighting mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 ); mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() ); mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) ); mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) ); mLight->enable(); // Load meshes loadModels(); // Create a Bullet dynamics world mWorld = bullet::createWorld(); // Load texture mTexSquare = gl::Texture( loadImage( loadResource( RES_TEX_SQUARE ) ) ); mTexSphere = gl::Texture( loadImage( loadResource( RES_TEX_SPHERE ) ) ); mTexTerrain = gl::Texture( loadImage( loadResource( RES_TEX_TERRAIN ) ) ); mTexTerrain.setWrap( GL_REPEAT, GL_REPEAT ); mTexTerrain.unbind(); // Init terrain pointer mTerrain = 0; // Parameters mFrameRate = 0.0f; mParams = params::InterfaceGl( "Params", Vec2i( 150, 100) ); mParams.addParam( "Frame Rate", &mFrameRate, "", true ); mParams.addParam( "Test", &mTest, "min=0 max=7 step=1 keyDecr=d keyIncr=D" ); // Initialize initTest(); // Run first resize to initialize view resize( ResizeEvent( getWindowSize() ) ); }
void VboMeshSampleApp::setup() { // Setting an unrealistically high frame rate effectively // disables frame rate limiting setFrameRate( 10000.0f ); setWindowSize( 800, 600 ); // Set up OpenGL to work with default lighting glShadeModel( GL_SMOOTH ); gl::enable( GL_POLYGON_SMOOTH ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); gl::enable( GL_NORMALIZE ); gl::enableAlphaBlending(); gl::enableDepthRead(); gl::enableDepthWrite(); // Load the texture map mTexture = gl::Texture( loadImage( loadResource( RES_TEXTURE ) ) ); // Define properties mFrameRate = 0.0f; mFullScreen = false; mLightEnabled = true; mMeshIndex = 0; mNumSegments = 48; mNumSegmentsPrev = mNumSegments; mScale = Vec3f::one(); mTextureEnabled = true; mWireframe = false; // Set up the arcball mArcball = Arcball( getWindowSize() ); mArcball.setRadius( (float)getWindowHeight() * 0.5f ); // Set up the camera mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.0001f, 10.0f ); mCamera.lookAt( Vec3f( 0.0f, 0.0f, -5.0f ), Vec3f::zero() ); // Set up the light mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 ); mLight->setAmbient( ColorAf::white() ); mLight->setDiffuse( ColorAf::white() ); mLight->setDirection( Vec3f::one() ); mLight->setPosition( Vec3f::one() * -1.0f ); mLight->setSpecular( ColorAf::white() ); mLight->enable(); // Define the mesh titles for the params GUI mMeshTitles.push_back( "Cube" ); mMeshTitles.push_back( "Sphere" ); mMeshTitles.push_back( "Cylinder" ); mMeshTitles.push_back( "Cone" ); mMeshTitles.push_back( "Circle" ); mMeshTitles.push_back( "Square" ); mMeshTitles.push_back( "Ring" ); mMeshTitles.push_back( "Custom" ); // Set up the params GUI mParams = params::InterfaceGl( "Params", Vec2i( 200, 320 ) ); mParams.addParam( "Frame rate", &mFrameRate, "", true ); mParams.addSeparator(); mParams.addParam( "Enable light", &mLightEnabled, "key=l" ); mParams.addParam( "Enable texture", &mTextureEnabled, "key=t" ); mParams.addParam( "Mesh type", mMeshTitles, &mMeshIndex, "keyDecr=m keyIncr=M" ); mParams.addParam( "Scale", &mScale ); mParams.addParam( "Segments", &mNumSegments, "keyDecr=s keyIncr=S min=3 max=1024 step=1" ); mParams.addParam( "Wireframe", &mWireframe, "key=w" ); mParams.addSeparator(); mParams.addParam( "Full screen", &mFullScreen, "key=f" ); mParams.addButton( "Screen shot", bind( &VboMeshSampleApp::screenShot, this ), "key=space" ); mParams.addButton( "Quit", bind( &VboMeshSampleApp::quit, this ), "key=q" ); // Generate meshes createMeshes(); }