本文整理汇总了C++中PhysicsComponent::SetMass方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsComponent::SetMass方法的具体用法?C++ PhysicsComponent::SetMass怎么用?C++ PhysicsComponent::SetMass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsComponent
的用法示例。
在下文中一共展示了PhysicsComponent::SetMass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Play
void Client::Play() {
OgreEasy::SimpleOgreInit lOgreInit;
if(!lOgreInit.initOgre()) {
std::cout<<"Could not init ogre"<<std::endl;
return;
}
Ogre::Root* lRoot = lOgreInit.mRoot.get();
Ogre::RenderWindow* lWindow = lOgreInit.mWindow;
World* w = new World();
w->SetDebugMode(false);
GameObject camObject = w->AddObject("camera");
camObject.AddCameraComponent("camera");
camObject.SetPosition(Ogre::Vector3(0,0,0));
camObject.LookAt(Ogre::Vector3(0,0,0));
GameObject& light2 = w->AddObject("point_light");
light2.AddLightComponent(Ogre::Light::LT_DIRECTIONAL);
light2.SetPosition(Ogre::Vector3(0,0,40));
light2.LookAt(Ogre::Vector3(0,100,0));
GameObject& c = w->AddPhysicsObject("esine", "cube/Cube.mesh");
c.SetPosition(Ogre::Vector3(0,0,0));
c.AddBoxCollider(1,1,1);
PhysicsComponent phys = c.GetPhysicsComponent();
phys.SetMass(1.0);
c.SetMaterial("tex");
GameObject& c2 = w->AddPhysicsObject("esine2", "cube/Cube.mesh");
c2.SetPosition(Ogre::Vector3(1,2,1));
c2.AddBoxCollider(1,1,1);
PhysicsComponent phys2 = c2.GetPhysicsComponent();
phys2.SetMass(1.0);
c2.SetMaterial("tex");
GameObject& taso = w->AddPhysicsObject("taso", "cube/other/Cube.mesh");
taso.SetPosition(Ogre::Vector3(0, -10, 0));
taso.AddBoxCollider(10,0.1,10);
taso.SetMaterial("plane");
PhysicsComponent phys3 = taso.GetPhysicsComponent();
phys3.SetMass(0.0);
GameObject& anim = w->AddObject("anim" , "second_anim/Cube.mesh");
anim.SetPosition(Ogre::Vector3(0, -5, 0));
anim.SetMaterial("tex");
lRoot->clearEventTimes();
float f=0.0;
unsigned long t=0;
double d;
Ogre::Timer* a = new Ogre::Timer();
while(!lWindow->isClosed()) {
t=a->getMicroseconds();
camObject.SetPosition(Ogre::Vector3(cos(f)*15.0, -5, sin(f)*15.0));
camObject.LookAt(Ogre::Vector3(-0,-10,-0), Ogre::Vector3::UNIT_Y);
w->Update(d);
f+=d*.5;
d = (double)(a->getMicroseconds()-t)/1000000;
}
delete w;
}