I was read exemples files(H and C++) files until now, but i can't make the "follow" the gravity
Code: Select all
void main()
{
MyEventExample receiver;
IrrlichtDevice* device = createDevice(EDT_OPENGL,dimension2d<u32>(800,600),32,false,false,false,&receiver);
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
//smgr->addLightSceneNode(0,vector3df(0,0,0),SColor(1,1,1,1),1000,-1);
smgr->addLightSceneNode(0,vector3df(200,80,100 ), SColorf(1.0f, 1.0f, 1.0f), 4000.0f);
//int rows = 10;
//int colums = 10;
irrBulletWorld* world = createIrrBulletWorld(device,true,true);
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
//double amprenta = device->getTimer()->getTime();
//u32 myTime = device->getTimer()->getTime();
IAnimatedMesh* sid = smgr->getMesh("media/sydney.md2");
ISceneNode* sidney = smgr->addAnimatedMeshSceneNode(sid);
sidney->setMaterialTexture(0,driver->getTexture("sydney.bmp"));
sidney->setPosition(vector3df(600,32,100));
ISceneNode* ground = smgr->addCubeSceneNode(1);
ground->setMaterialTexture(0,driver->getTexture("media/terrain.jpg"));
ground->setScale(vector3df(600,32,200));
ground->setPosition(vector3df(200,0,100));
ground->setMaterialFlag(EMF_LIGHTING,true);
ground->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);
camera->setPosition(vector3df(600,40,-200));
ICollisionShape* groundShape =new IBoxShape(ground,0,false);
ICollisionShape* sidneyShape = new IBoxShape(sidney,0,false);
IRigidBody* groundRigid;
IRigidBody* sidneyRigid;
groundRigid = world->addRigidBody(groundShape);
sidneyRigid = world->addRigidBody(sidneyShape);
world->setGravity(vector3df(0,-10,0));
u32 TimeStamp = device->getTimer()->getTime();
u32 DeltaTime = 0;
u32 force = rand() % 40 + 20;
//static_cast<IRigidBody*>(world->getCollisionObjectByIndex(world->getNumCollisionObjects()-1))->setLinearVelocity(vector3df(0,0,force));
while(device->run()) {
driver->beginScene(true,true,SColor(1,0,0,0));
smgr->drawAll();
sidneyRigid->applyGravity();
DeltaTime = device->getTimer()->getTime() - TimeStamp;
TimeStamp = device->getTimer()->getTime();
world->stepSimulation(DeltaTime*0.001f, 120);
driver->endScene();
}
device->drop();
return;
}