I've added an octreetriangleselector to the room and set it on my room scene node and I added a collisionresponseanimator to the ball just like with camera in the tutorial with collision detection. Also I have an animator that moves the ball around the room to the place where u click with the mouse but there is a problem..
The ball is moving but it's not colliding with walls or interior of the room, and if i set gravity other than 0 it just falls thru the floor..
I determine the elipsoide radius for collision by substracting MaxEdge and MinEdge of the ball's boundingbox and I divide it by 2. Gravity is -100, speed 100, center of elipsoide is at the center of the ball.
Here is the code i use for that part of program:
Code: Select all
IAnimatedMeshSceneNode* ball = smgr->addAnimatedMeshSceneNode(smgr->getMesh("data/ball.3ds"));
ball->setPosition(vector3df(35,0,185));
ball->setMaterialFlag(EMF_LIGHTING, false);
player = ball;
IAnimatedMesh* floormesh = smgr->getMesh("data/floor.3ds");
ISceneNode* floor = 0;
ITriangleSelector* world = 0;
if (floormesh)
floor = smgr->addOctTreeSceneNode(floormesh);
if (floor) {
floor->setPosition(vector3df(0,0,0));
floor->setMaterialFlag(EMF_LIGHTING, false);
world = smgr->createOctTreeTriangleSelector(floormesh->getMesh(0), floor, 128);
floor->setTriangleSelector(world);
world->drop();
}
camera = smgr->addCameraSceneNode(0, vector3df(0,150,-100), vector3df(0,0,0));
vector3df radius = ball->getBoundingBox().MaxEdge - ball->getBoundingBox().MinEdge;
radius = radius / 2.0f;
ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
world, ball, radius,
vector3df(0,-100,0),
100.0f,
vector3df(0,0,0));
ball->addAnimator(anim);
anim->drop();
Where have I made a mistake?