ride the elevator

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
vorschau
Posts: 10
Joined: Thu Mar 03, 2005 3:00 pm
Location: vienna

ride the elevator

Post by vorschau »

hi
having a little problem with my elevator.
i created an animated mesh and did a follow spline animation.
i'v put an metaselector in the scene and collidind works fine in the scenery. ---

but when i enter the moving elevator im not moving with it if it moves up.

anybody out there helping whith an example code - please :(
Guest

Post by Guest »

Are you updating player position with the postition of the platform?
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Set your animated node's parent to the elevator and be sure to adjust it's x/y/z position to be relative to the elevator when your on it, and then change/remove the parent and set the X/Y/Z position back when you get off it.

ISceneNode->setParent(ISceneNode*);
Crud, how do I do this again?
Guest

Post by Guest »

Of course, the "proper" way to do it is with collision detection and maybe even some simple physics.

That way, you can have the user jump out of the elevator (the initial velocity would be higher if the elevator is going up and lower if it's going down) and walk off the edge and fall, without having to code the size of the elevator.

But Saigumi's suggestion _is_ the simplest and least CPU intensive, and it's the way it's done in Unreal and UT, so you'd be in good company.
vorschau
Posts: 10
Joined: Thu Mar 03, 2005 3:00 pm
Location: vienna

Post by vorschau »

sorry i'm not a progammer, i have no idea where to change the parent scene for the camera to get from solig mesh to the elevator and back again.

help please :?


code:

int main()
{
MyEventReceiver receiver;
device = createDevice(video::EDT_DIRECTX8,
core::dimension2d<s32>(800, 600),
32, false, false, false, &receiver);

// Fensterbeschriftung
device->setWindowCaption(L"3D VIEWER - powered by Irrlicht Engine - Beenden = ALT+F4");


video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();

// verschl datensatz
device->getFileSystem()->addZipFileArchive("daten/3d.pk3");



// camera
scene::IMetaTriangleSelector* metaselector = smgr->createMetaTriangleSelector();

scene::ICameraSceneNode* camera =
camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(0,150,0));
// collisionserkennung - camera
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
metaselector, camera, core::vector3df(30,50,30),
core::vector3df(0,-100,0), 100.0f,
core::vector3df(0,100,0));

camera->setFarValue (8000.0f);
camera->addAnimator(anim);
anim->drop();




// solid-oberflächen
scene::IAnimatedMeshSceneNode* mesh = 0;
scene::IAnimatedMesh* solid = smgr->getMesh("solid.3ds");
// geometrieerkenner für collision
scene::ITriangleSelector* selectormesh = 0;



if (solid)
{
mesh = smgr->addAnimatedMeshSceneNode(solid);
mesh->setMaterialType(video::EMT_SOLID);
// erkennung für collision
selectormesh = smgr->createTriangleSelector(solid->getMesh(0), mesh);
mesh->setTriangleSelector(selectormesh);
metaselector->addTriangleSelector(selectormesh);

}



// aufzug mit animation
scene::IAnimatedMeshSceneNode* aufzug = 0;
scene::IAnimatedMesh* move = smgr->getMesh("aufzug.3ds");
scene::ITriangleSelector* selectormove = 0;
scene::ISceneNodeAnimator* sa = 0;


core::array<core::vector3df> points;

points.push_back(core::vector3df(0.0f, 50.0f, 0.0f)); // Start
points.push_back(core::vector3df(0.0f, 440.0f, 0.0f)); //ziel
points.push_back(core::vector3df(0.0f, 440.0f, 0.0f)); //ziel
points.push_back(core::vector3df(0.0f, 50.0f, 0.0f)); // start

if (move)
{
aufzug = smgr->addAnimatedMeshSceneNode(move);
aufzug->setMaterialType(video::EMT_SOLID);
driver->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY, false);

selectormove = smgr->createTriangleSelector(move->getMesh(0), aufzug);
aufzug->setTriangleSelector(selectormove);
metaselector->addTriangleSelector(selectormove);

sa = smgr->createFollowSplineAnimator(0,
points, 0.2f);
aufzug->addAnimator(sa);


selectormove = smgr->createTriangleSelector(move->getMesh(0), aufzug);
aufzug->setTriangleSelector(selectormove);
metaselector->addTriangleSelector(selectormove);

sa->drop();


}



device->getCursorControl()->setVisible(false);


int lastFPS = -1;
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();

driver->endScene();

}
device->drop();

return 0;
}
Post Reply