本文整理汇总了C++中Platform::addToDynamicWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::addToDynamicWorld方法的具体用法?C++ Platform::addToDynamicWorld怎么用?C++ Platform::addToDynamicWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::addToDynamicWorld方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shootGlobeHit
void NickScene::shootGlobeHit(NickButton *button) {
// shoot cannon at the globe
m_globeCannon->shootCannon();
//// create a platform
Platform *platform = new Platform(this, Vector3(30.0f, 1.0f, 30.0f));
if ( !platform->initialize(new LightShader(0.2f, 1.0f, 4, RAND_COLOR))) { GLOG("ERROR: Could not initialize second to last platform\n"); }
platform->setPosition(Vector3(-60.0f, 50.0f, -560.0f));
platform->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(platform);
ParticleSystem *system = new RandomParticleSystem(400);
system->moveToPoint(0.0f, 50.0f, -600.0f);
system->speed = 4.0f;
system->speedVar = 3.0f;
system->startSystem();
m_graph->attach(system);
// create a checkpoint now that user has gotten through trampolines
FinishCheckPoint *cp = new FinishCheckPoint(this, "Objects/goal.obj", 0.125f);
if ( !cp->initialize(new LightShader(0.1f, 1.0, 8, RAND_COLOR))) { GLOG("ERROR: could not create OBJmodel\n");}
cp->setPosition(Vector3(0.0f, 32.0f, -600.0f));
m_allCheckpoints.push_back(cp);
cp->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(cp);
}
示例2: onInitialize
bool MainMenu::onInitialize()
{
//position camera so that any 3D elements we attach to the graph are rendered how we want
s_Cam()->setPosition(Vector3(0.0f, 15.0f, 40.0f));
s_Cam()->setLookAt(Vector3(0.0f, 5.0f, 0.0f));
s_Cam()->setCameraMode(CM_STILL);
m_graph->pushNode();
{
//// create a platform
Platform *platform = new Platform(this, Vector3(50.0f, 1.0f, 50.0f));
if ( !platform->initialize(new LightShader(0.2f, 0.8f, 4, RAND_COLOR))) { GLOG("ERROR: Could not initialize center platform\n"); return false; }
platform->setPosition(Vector3(0.0f, -0.5f, 0.0f));
platform->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(platform);
//new OBJmodel here
OBJmodel *game_title = new OBJmodel(this, "Objects/game_title.obj", 1.0f, false, false ,true);
if ( !game_title->initialize(new LightShader(0.1f, 0.8, 8, RAND_LIGHT_COLOR))) { GLOG("ERROR: could not create game_title\n"); return false; }
game_title->setPosition(Vector3(0.0f, game_title->getSize().y * 0.5f, 00.0f));
game_title->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(game_title);
}
m_graph->popNode();
// create particle system for the background
/*ParticleSystem *randomSystem = new RandomParticleSystem(500);
randomSystem->emitterPositionVar = Vector3(5.0f, 4.0f, 0.0f);
randomSystem->startColor = Color(0.0f, 0.0f, 0.0f, 1.0f);
randomSystem->endColor = Color(0.5f, 0.5f, 0.5f, 0.0f);
randomSystem->endColorVar = Color(0.5f, 0.5f, 0.5f, 0.0f);
randomSystem->speed = 0.1f;
randomSystem->startSystem();
m_graph->attach(randomSystem);*/
float scale = s_Cam()->getScreenWidth() / 1024.0f;
// create an image for nicks level
nicks_level = new GUIImage();
if ( !nicks_level->initialize(new TextureShader(), "Textures/nicks_level.tga"))
return false;
nicks_level->setPosition(Vector3(s_Cam()->getScreenWidth() * 0.25f, s_Cam()->getScreenHeight() - 100 * scale, 0.0f));
nicks_level->setScale(scale);
// create an image for charlies level
charlies_level = new GUIImage();
if ( !charlies_level->initialize(new TextureShader(), "Textures/charlies_level.tga"))
return false;
charlies_level->setPosition(Vector3(s_Cam()->getScreenWidth() * 0.75f, s_Cam()->getScreenHeight() - 100 * scale, 0.0f));
charlies_level->setScale(scale);
// create an image for how to play
how_to_play_button = new GUIImage();
if ( !how_to_play_button->initialize(new TextureShader(), "Textures/how_to_play_button.tga"))
return false;
how_to_play_button->setPosition(Vector3(s_Cam()->getScreenWidth() * 0.5f, s_Cam()->getScreenHeight() - 220 * scale, 0.0f));
how_to_play_button->setScale(scale);
// create an image for how to play
how_to_play = new GUIImage();
if ( !how_to_play->initialize(new TextureShader(), "Textures/how_to_play.tga"))
return false;
how_to_play->setPosition(Vector3(s_Cam()->getScreenWidth() * 0.5f, s_Cam()->getScreenHeight() * 0.5f, 0.0f));
how_to_play->setScale(scale);
return resetPlayer();
}
示例3: onInitialize
bool NickScene::onInitialize()
{
Vector3 nodeCenter = Vector3(0.0f, 0.0f, 0.0f);
//-----------------------------------------------------------------
// create the initial platform which has a button that user can hit
// to turn the globe on
//-----------------------------------------------------------------
m_graph->pushNode();
{
nodeCenter = Vector3(0.0f, 100.0f, 300.0f);
//start position Waypoint this is where the player starts/resets
m_WPstart = new Start(this, "Objects/goal.obj", 0.125f);
if ( !m_WPstart->initialize(new LightShader(0.2f, 1.0, 8, RAND_COLOR))) { GLOG("ERROR: could not create OBJmodel\n"); return false; }
m_WPstart->setPosition(nodeCenter + Vector3(0.0f, 0.0f, 10.0f));
m_WPstart->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(m_WPstart);
// create a platform
Platform *platform = new Platform(this, Vector3(40.0f, 1.0f, 40.0f));
if ( !platform->initialize(new LightShader(0.2f, 0.8f, 8, RAND_COLOR))) { GLOG("ERROR: Could not initialize initial platform\n"); return false; }
platform->setPosition(nodeCenter + Vector3(0.0f, -0.5f, 0.0f));
platform->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(platform);
}
m_graph->popNode();
//-----------------------------------------------------------------
// create long platform that has cannons shooting at it
//-----------------------------------------------------------------
m_graph->pushNode();
{
nodeCenter += Vector3(0.0f, -30.0f, -130.0f);
// create a platform
Platform *platform = new Platform(this, Vector3(10.0f, 1.0f, 220.0f));
if ( !platform->initialize(new LightShader(0.3f, 1.0f, 8, RAND_LIGHT_COLOR))) { GLOG("WARNING: Could not initialize cannon platform\n"); }
platform->setPosition(nodeCenter + Vector3(0.0f, 0.0f, 0.0f));
platform->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(platform);
bool rightSide = false;
for (int i = 0; i < 10; i++) {
float cannonZ = (platform->getSize().z * 0.5f) - 50.0f - (i * 15.0f);
float fireTime = 0.4f + RANDF(1.0f);
// add a cannon aiming at the platform
Cannon *cannon = new Cannon(this, Vector3(3.0f, 3.0f, 6.0f), 120.0f, fireTime);
if (!cannon->initialize(new LightShader(0.1f, 1.0f, 8, Color(0.1f, 0.8f, 0.2f)))) { GLOG("WARNING: could not initialize first cannon\n"); }
float cannonX = rightSide ? 20.0f : -20.0f;
cannon->setPosition(nodeCenter + Vector3(cannonX, 10.0f, cannonZ));
float yaw = rightSide ? 90.0f : -90.0f;
cannon->setOrientation(yaw, -20.0f, 0.0f);
cannon->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(cannon);
rightSide = !rightSide;
m_cannons.push_back(cannon);
}
// create a button that will stop the cannons
NickButton *stop_cannon_button = new NickButton(this, &NickScene::stopCannonsHit, Vector3(8.0f, 0.5f, 4.0f));
if (!stop_cannon_button->initialize(new LightShader(0.3f, 1.0f, 8, RAND_COLOR))) { GLOG("ERROR: could not create stop_cannon_button\n"); }
stop_cannon_button->setPosition(nodeCenter + Vector3(0.0f, stop_cannon_button->getSize().y, -105.0f));
stop_cannon_button->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(stop_cannon_button);
}
m_graph->popNode();
//-----------------------------------------------------------------
// create platform after the cannon platform, which just has cube pyramid
// that covers a gap to the next platform
//-----------------------------------------------------------------
m_graph->pushNode();
{
nodeCenter += Vector3(0.0f, 0.0f, -120.0f);
// create a checkpoint now that user has gotten through cannons
NickCheckPoint *cp = new NickCheckPoint(this, "Objects/goal.obj", 0.125f);
if ( !cp->initialize(new LightShader(0.2f, 1.0, 8, RAND_COLOR))) { GLOG("ERROR: could not create OBJmodel\n"); return false; }
cp->setPosition(nodeCenter + Vector3(8.0f, 0.5f, 0.0f));
m_allCheckpoints.push_back(cp);
cp->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(cp);
cp->attachParticleSystem(new WaypointParticleSystem(200));
// create a platform
Platform *platform = new Platform(this, Vector3(50.0f, 1.0f, 12.0f));
if ( !platform->initialize(new LightShader(0.2f, 0.8f, 8, RAND_COLOR))) { GLOG("ERROR: Could not initialize gap platform\n"); return false; }
platform->setPosition(nodeCenter + Vector3(25.0f, -0.5f, 0.0f));
platform->addToDynamicWorld(m_dynamicsWorld);
m_graph->attach(platform);
// cube pyramid right before gap
m_graph->pushNode();
Vector3 cubeSize = Vector3(1.5f, 1.5f, 0.5f);
Vector3 startPoint = nodeCenter + Vector3(49.0f, cubeSize.y / 2.0f, -5.0f);
//.........这里部分代码省略.........