i'm doing a "top-view-car-drive-through-a-city"-game. nothing big, just a simple thing. I use a testscenenode as a car and a q3map as a city mesh.
Viewing setup is: map is loaded in and rotated by -90 degrees around x, so it fits into the x-y-plane, camera is looking from -z into the scene, thus looking at the car from top, just like in micro machines games. X is to the right, Y is up vector.
However, adding collision detection causes very strange behaviour of my car... it's not steerable to the right and sticks to the lower end of the map.
Could it be that the triangle selector selects the triangles as they were still in the x-z-plane? that it doesn't get the rotation of the mesh node?
plz share your ideas with me and have a look at my code:
Code: Select all
//add quake3 map with city architecture, rotated by 90 deg around x
device->getFileSystem()->addZipFileArchive("../../media/citymap.pk3");
scene::IAnimatedMesh* citymesh = smgr->getMesh("city.bsp");
scene::ISceneNode* citynode = 0;
if (citymesh) {
citynode = smgr->addOctTreeSceneNode(citymesh->getMesh(0));
citynode->setRotation(core::vector3df(-90,0,0));
citynode->setMaterialFlag(video::EMF_LIGHTING, true);
citynode->getMaterial(0).Shininess = 20.0f;
}
// add collision detection
scene::ITriangleSelector* cityselector = smgr->createOctTreeTriangleSelector(citymesh->getMesh(0), citynode, 16);
citynode->setTriangleSelector(cityselector);
cityselector->drop();
//add a camera, looking onto the x-y plane from z, with y as up-vector
scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
cam->setTarget(core::vector3df(0,0,0));
cam->setPosition(core::vector3df(0,0,-300));
cam->setRotation(core::vector3df(0,0,0));
cam->setUpVector(core::vector3df(0,1,0));
//add the car... myCar is a testscenenode with modified control and texturing etc
myCar* car = new myCar(10,core::vector3df(0,0,-50),core::vector3df(1,1,1),0,smgr,0.2,15,0.01);
scene::ISceneNodeAnimatorCollisionResponse* car_anim = smgr->createCollisionResponseAnimator(cityselector, car->getNode(),core::vector3df(0.01,0.01,0.01),core::vector3df(0,0,1),core::vector3df(0,0,0), 4);
car->getNode()->addAnimator(car_anim);
car_anim->drop();