Hiho Leute
brauch mal hilfe um Bullet in mein Projekt einzubauen
hab es geschafft das es fast fehlerfrei läuft nur leider reagieren einzele nodes nicht aufeinander
wenn ich
Code:
void CreateBox(const btVector3 &TPosition, const vector3df &TScale, btScalar TMass) {
ISceneNode *Node = irrScene->addCubeSceneNode(1.0f);
Node->setScale(TScale);
Node->setMaterialFlag(EMF_LIGHTING, 1);
Node->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
Node->setMaterialTexture(0, irrDriver->getTexture("C:/Users/igel/Desktop/Programmieren/irrlicht-1.6/media/irrlicht2_up.jpg"));
// Set the initial position of the object
btTransform Transform;
Transform.setIdentity();
Transform.setOrigin(TPosition);
btDefaultMotionState *MotionState = new btDefaultMotionState(Transform);
// Create the shape
btVector3 HalfExtents(TScale.X * 0.5f, TScale.Y * 0.5f, TScale.Z * 0.5f);
btCollisionShape *Shape = new btBoxShape(HalfExtents);
// Add mass
btVector3 LocalInertia;
Shape->calculateLocalInertia(TMass, LocalInertia);
// Create the rigid body object
btRigidBody *RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia);
// Store a pointer to the irrlicht node so we can update it later
RigidBody->setUserPointer((void *)(Node));
// Add it to the world
World->addRigidBody(RigidBody);
Objects.push_back(RigidBody);
}
void addphysik(ISceneNode* node ,const btVector3 &TPos, vector3df &TScale, btScalar TMass){
btTransform Transform;
Transform.setIdentity();
Transform.setOrigin(TPos);
btDefaultMotionState *MotionState = new btDefaultMotionState(Transform);
// Create the shape
btVector3 HalfExtents(TScale.X * 0.5f, TScale.Y * 0.5f, TScale.Z * 0.5f);
btCollisionShape *Shape = new btBoxShape(HalfExtents);
// Add mass
btVector3 LocalInertia;
Shape->calculateLocalInertia(TMass, LocalInertia);
// Create the rigid body object
btRigidBody *RigidBody = new btRigidBody(TMass, MotionState, Shape, LocalInertia);
// Store a pointer to the irrlicht node so we can update it later
RigidBody->setUserPointer((void *)(node));
// Add it to the world
World->addRigidBody(RigidBody);
Objects.push_back(RigidBody);
}
void build_scene()
{
//Boden
createcube(btVector3(0, 0, 0), vector3df(1000,3,1000), 0.0f);
//Zwerg
scene::IAnimatedMesh* charmesh = smgr->getMesh("C:/***/irrlicht-1.6/media/dwarf.x");
video::SMaterial material;
material.setTexture(0,driver->getTexture("C:/***/irrlicht-1.6/media/dwarf.jpg"));
material.Lighting = true;
if (charmesh)
{
charnode = smgr->addAnimatedMeshSceneNode(charmesh);
charnode->getMaterial(0) = material;
charnode->setMD2Animation(scene::EMAT_STAND);
selector = smgr->createTriangleSelector(charnode);
charnode->setTriangleSelector(selector);
selector->drop();
}
addphysik(charnode, btVector3(0, 100, 0), vector3df(0.1f, 0.1f, 0.1f), 100.0f);
createcube (btVector3(0, 100, 0), vector3df(10,10,10), 1.0f);
}
So bleibt der Zwerg auf dem Bode stehen aber der würfel fällt durch den zwerg durch bis er den boden berrührt
warum? Oo