here is my code:
Code: Select all
p_world = createPhysicsWorld(device);
// add terrain scene node
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"media/terrain-heightmap.bmp");
terrain->setScale(core::vector3df(10, 1.1f, 10));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("media/terrain-texture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap3.jpg"));
terrain->setMaterialFlag(video::EMF_BACK_FACE_CULLING,false);
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(1.0f, 30.0f);
//create terrain body
irr::newton::SBodyFromNode terrainData;
terrainData.Node=terrain;
terrainData.Type = newton::EBT_AUTODETECT;
terrainData.TerrainLOD = 1;
terrain_body = p_world->createBody(terrainData);
terrain_body->setMass(5.9736*1000000000000); //earth's mass
terrain_body->addForceContinuous(vector3df(0,-9.81,0));
terrain_material=p_world->createMaterial();
terrain_body->setMaterial(terrain_material);
//create an actor to test the rpg camera
scene::IAnimatedMeshSceneNode *actor = smgr->addAnimatedMeshSceneNode(smgr->getMesh("media/sydney.md2"),0,-1);
actor->setMaterialTexture(0, driver->getTexture("media/sydney.bmp"));
actor->setPosition(vector3df(280,56,693));
actor->setMaterialFlag(video::EMF_LIGHTING, false);
actor->setLoopMode(true);
actor->setMD2Animation(scene::EMAT_STAND);
//create actor body
irr::newton::SBodyFromNode actorData;
actorData.Type = newton::EBT_AUTODETECT;
actorData.Node = actor;
actor_body = p_world->createBody(actorData);
actor_body->setMass(56.f);
actor_body->setCentreOfMass(vector3df(0,-1,0));
//actor_body->addForceContinuous(vector3df(0,-9.81*actor_body->getMass(),0));
actor_body->setContinuousCollisionMode(true);
actor_material=p_world->createMaterial();
actor_body->setMaterial(actor_material);
actor_material->setFriction(terrain_material, 0, 0);
actor_material->setCollidable(terrain_material, true);
//terrain triangle selector, used for camera
scene::ITriangleSelector* selector = 0;
selector = smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
scene::ISceneNodeAnimator * anim = smgr->createCollisionResponseAnimator( selector, actor, core::vector3df(10,24.5,10), core::vector3df(0,-9.81,0), core::vector3df(0,-0.1,0));
actor->addAnimator(anim);
anim->drop();
//camera RPG (test)
irr::scene::CCameraRPGSceneNode* camera = new irr::scene::CCameraRPGSceneNode(actor, smgr, 1, device, selector);
camera->configure("cam.xml");
smgr->setActiveCamera(camera);
camera->drop();
any help is appreciated.
now i can go to sleep