bullet irrlicht demo
bullet irrlicht demo
I have created a very simple irrlicht bullet demo using the latest versions(bullet 2.64 and irrlicht 1.4).
http://www.cs.utah.edu/~witkowsk/files/irrtest.zip
The zip is self-contained with all the libraries and includes. All you have to do is set the working directory inside the project debugging properties. Tested on Windows XP / Visual C++ Express.
http://www.cs.utah.edu/~witkowsk/files/irrtest.zip
The zip is self-contained with all the libraries and includes. All you have to do is set the working directory inside the project debugging properties. Tested on Windows XP / Visual C++ Express.
Visual C++ 5? 2005?jcfalcone wrote:why every time i trying to compile this on visual c++ 5 express,with bullet files, this show linker errors on bullet? i need to do some thing?
did you follow these steps:
http://msdn2.microsoft.com/en-us/express/aa700755.aspx
Do you have another version of bullet on your computer? Post the output of your compile.
Take a look at irrlamb's source code:
http://irrlamb.googlecode.com/svn/trunk/source/
If you look at mesh.cpp for example, you can use a btBvhTriangleMeshShape as the shape.
http://irrlamb.googlecode.com/svn/trunk ... s/mesh.cpp
Also, look at ConvertCollisionMesh inside physics.cpp:
http://irrlamb.googlecode.com/svn/trunk ... hysics.cpp
That will show you how to convert an irrlicht mesh to a bullet mesh.
Other examples to look at are in terrain.cpp and scene.cpp
Let me know if you have other questions.
http://irrlamb.googlecode.com/svn/trunk/source/
If you look at mesh.cpp for example, you can use a btBvhTriangleMeshShape as the shape.
http://irrlamb.googlecode.com/svn/trunk ... s/mesh.cpp
Also, look at ConvertCollisionMesh inside physics.cpp:
http://irrlamb.googlecode.com/svn/trunk ... hysics.cpp
That will show you how to convert an irrlicht mesh to a bullet mesh.
Other examples to look at are in terrain.cpp and scene.cpp
Let me know if you have other questions.
Thanks Jacky_J
I see your code XD
but help me here
i try to create a class to create my meshs
but every time i try to use the functions of bullet the exe stop to work
the function
UpdateMeshs() and PhysicMesh() with EnablePhysic = true stop my exe.
I see your code XD
but help me here
i try to create a class to create my meshs
but every time i try to use the functions of bullet the exe stop to work
the function
UpdateMeshs() and PhysicMesh() with EnablePhysic = true stop my exe.
Code: Select all
#ifndef MESHCLASS_CPP
#define MESHCLASS_CPP
// Change this to the path where your Irrlicht Header Files are.
#include <irrlicht.h>
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
#include "global.cpp"
#include "engine.physic.cpp"
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/// ==============================
/// MastMesh
/// ==============================
class Mastmesh
{
// Classes
ISceneNode* Node;
//mesh
IAnimatedMesh * Mesh;
//fisica
btRigidBody *RigidBody;
btCollisionShape *Shape;
btDefaultMotionState *MotionState;
//Engine de Fisica
PhysicEng Engine;
void PhysicMesh(ISceneNode* &Node)
{
// Graphics
IAnimatedMesh *AnimatedMesh = smgr->getMesh(Mesh_Model);
Node = smgr->addOctTreeSceneNode(AnimatedMesh);
Node->setScale(Scale);
if(MeshTexture != "")
{
Node->setMaterialTexture(0, driver->getTexture(MeshTexture));
}
if(EnablePhysic)
{
// Get the collision mesh
btTriangleMesh *CollisionMesh = new btTriangleMesh();
Engine.ConvertCollisionMesh(Mesh->getMesh(0),
CollisionMesh,
Scale);
Shape = new btBvhTriangleMeshShape(CollisionMesh, true);
// Orientation
btTransform Transform;
Engine.GetBulletTransform(Transform, TPosition, TRotation);
MotionState = new btDefaultMotionState(Transform);
// Body
RigidBody = new btRigidBody(Mass, MotionState, Shape);
RigidBody->setUserPointer((void *)this);
World->addRigidBody(RigidBody);
Objects.push_back(RigidBody);
}
};
void UpdatePhysics(u32 TDeltaTime) {
World->stepSimulation(TDeltaTime * 0.001f, 60);
// Relay the object's orientation to irrlicht
for(list<btRigidBody *>::Iterator Iterator = Objects.begin(); Iterator != Objects.end(); ++Iterator)
{
UpdateRender(*Iterator);
}
};
void UpdateRender(btRigidBody *TObject) {
ISceneNode *Node = static_cast<ISceneNode *>(TObject->getUserPointer());
// Set position
btPoint3 Point = TObject->getCenterOfMassPosition();
Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));
// Set rotation
btVector3 EulerRotation;
Engine.QuaternionToEuler(TObject->getOrientation(), EulerRotation);
Node->setRotation(vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2]));
};
public:
//textura e modelo
c8 *MeshTexture;
c8 *Mesh_Model;
//tamanho,massa e posição
vector3df Scale;
btScalar Mass;
vector3df TPosition;
vector3df TRotation;
//se possui fisica ou não
bool EnablePhysic;
IrrlichtDevice* device;
scene::ISceneManager* smgr;
video::IVideoDriver* driver;
u32 TimeStamp;
u32 DeltaTime;
void UpdateMeshs()
{
DeltaTime = irrTimer->getTime() - TimeStamp;
TimeStamp = irrTimer->getTime();
UpdatePhysics(DeltaTime);
};
void CreateMesh()
{
Mesh = smgr->getMesh(Mesh_Model);
Node = smgr->addOctTreeSceneNode(Mesh);
Node->setScale(Scale);
if (Node)
{
Node->setMaterialTexture(0, driver->getTexture(MeshTexture));
}
PhysicMesh(Node);
};
ISceneNode* GetNode()
{
return Node;
};
};
#endif
Get this put on the tutorial page!
This should be on the tutorial page because there are samples for other physics engines but I didn't see one for Bullet.
The problem is that you changed
to
but you didn't update the "receiving" side of it.
try changing
to
or something similar.
Code: Select all
RigidBody->setUserPointer((void *)(Node));
Code: Select all
RigidBody->setUserPointer((void *)this);
try changing
Code: Select all
ISceneNode *Node = static_cast<ISceneNode *>(TObject->getUserPointer());
Code: Select all
ISceneNode *Node = static_cast<Mastmesh *>(TObject->getUserPointer())->Node;
Thanks. I completely agree with you. Bullet doesn't have the best documentation/examples. There's another bullet/irrlicht demo floating around that's outdated and not really set up in a tutorial fashion.trixs wrote:I just had to let you know that this is EXTREMELY helpful.
An actual working simple example! That seems to be odd around here.
One thing that i should have done in this tutorial is load terrain/mesh from a file. But with the links i provided above it should get you in the right direction.
-
- Posts: 46
- Joined: Tue Oct 02, 2007 6:46 am
- Contact: