Question about bullet physics engine + opengl integration
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Question about bullet physics engine + opengl integration
Hello their!
I downloaded bullet v2.77. The demo is working well in my PC. and I am using opengl.
I want to know how to integrate bullet to opengl application.
I searched the manual but there is no comment about integration.
I hope there is some example about the application(bullet + opengl)
Please reply my question!
thanks.
I downloaded bullet v2.77. The demo is working well in my PC. and I am using opengl.
I want to know how to integrate bullet to opengl application.
I searched the manual but there is no comment about integration.
I hope there is some example about the application(bullet + opengl)
Please reply my question!
thanks.
-
- Posts: 14
- Joined: Wed Feb 09, 2011 8:35 pm
Re: Question about bullet physics engine + opengl integratio
Hey there!
On the wiki there's a nice Hello World which I think is all you need to "integrate".
http://www.bulletphysics.org/mediawiki- ... ello_World
On the wiki there's a nice Hello World which I think is all you need to "integrate".
http://www.bulletphysics.org/mediawiki- ... ello_World
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
I tested it by creating new vs2010 win32 project.
but after debugging, i cannot see any opengl screen and shapes.
if you tested it perfectly, please upload it in this forum.
very thanks
but after debugging, i cannot see any opengl screen and shapes.
if you tested it perfectly, please upload it in this forum.
very thanks
-
- Posts: 14
- Joined: Wed Feb 09, 2011 8:35 pm
Re: Question about bullet physics engine + opengl integratio
Do you know how to program? Not meaning to be mean, but you do need to know how to program before you can do things with bullet. If you do know how to program, post what's wrong and what parts of the code you don't understand.
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
I reviewed the HelloWorld tutorial. and I am not sure how to program.
I don't think that the manual is not good for first user like me because it telling me not more detail.
I couldn't fine some bullet programming book and reference guide.
so please teach me? or upload some example?
I don't think that the manual is not good for first user like me because it telling me not more detail.
I couldn't fine some bullet programming book and reference guide.
so please teach me? or upload some example?
-
- Posts: 14
- Joined: Wed Feb 09, 2011 8:35 pm
Re: Question about bullet physics engine + opengl integratio
It tells you all the detail you need to know. You do first need to learn how to program, preferably C++ since that's the language Bullet is written in. The Visual Studio project comes with a whole bunch of demos/examples. If you can't find these, you first need to learn how to use Visual Studio.
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
well it's difficult to understand. I hope there are some comments in the Demo.
The Demo is not seperated each other. All of the sample uses the Renderscene in DemoApplication.cpp
It's not good for me to understand. I need to understand the procedure.
I have asked the expert who is good at c++, he also cannot find the way or procedure.
and i found some example can you explain below code?
------------------------------------------------------
//*** init Bullet Physics
btQuaternion qtn;
btCollisionShape *shape;
btDefaultMotionState *motionState;
btDefaultCollisionConfiguration *collisionCfg
= new btDefaultCollisionConfiguration();
btAxisSweep3 *axisSweep
= new btAxisSweep3(btVector3(-1.0,-1.0,-1.0), btVector3(1,1,1), 128);
dynamicsWorld = new btDiscreteDynamicsWorld(new btCollisionDispatcher(collisionCfg),
axisSweep, new btSequentialImpulseConstraintSolver, collisionCfg);
dynamicsWorld->setGravity(btVector3(0, -0.8, 0));
//*** box1 - STATIC / mass=btScalar(0.0)
shape = new btBoxShape(btVector3(0.2,0.2,0.2));
trans.setIdentity();
qtn.setEuler(0, 0.25, -0.05);
trans.setRotation(qtn);
trans.setOrigin(btVector3(0, -0.2, 0));
motionState = new btDefaultMotionState(trans);
box1 = new btRigidBody(btScalar(0.0), motionState, shape, btVector3(0,0,0));
dynamicsWorld->addRigidBody(box1);
//*** box2 - DYNAMIC / mass=btScalar(1.0)
shape = new btBoxShape(btVector3(0.5,0.5,0.5));
trans.setIdentity();
qtn.setEuler(0.8, 0.7, 0.4);
trans.setRotation(qtn);
trans.setOrigin(btVector3(-0.1, 0.5, 0));
motionState = new btDefaultMotionState(trans);
box2 = new btRigidBody(btScalar(0.5), motionState, shape, btVector3(0.5,0.5,0.5));
dynamicsWorld->addRigidBody(box2);
------------------------------------------------------
The Demo is not seperated each other. All of the sample uses the Renderscene in DemoApplication.cpp
It's not good for me to understand. I need to understand the procedure.
I have asked the expert who is good at c++, he also cannot find the way or procedure.
and i found some example can you explain below code?
------------------------------------------------------
//*** init Bullet Physics
btQuaternion qtn;
btCollisionShape *shape;
btDefaultMotionState *motionState;
btDefaultCollisionConfiguration *collisionCfg
= new btDefaultCollisionConfiguration();
btAxisSweep3 *axisSweep
= new btAxisSweep3(btVector3(-1.0,-1.0,-1.0), btVector3(1,1,1), 128);
dynamicsWorld = new btDiscreteDynamicsWorld(new btCollisionDispatcher(collisionCfg),
axisSweep, new btSequentialImpulseConstraintSolver, collisionCfg);
dynamicsWorld->setGravity(btVector3(0, -0.8, 0));
//*** box1 - STATIC / mass=btScalar(0.0)
shape = new btBoxShape(btVector3(0.2,0.2,0.2));
trans.setIdentity();
qtn.setEuler(0, 0.25, -0.05);
trans.setRotation(qtn);
trans.setOrigin(btVector3(0, -0.2, 0));
motionState = new btDefaultMotionState(trans);
box1 = new btRigidBody(btScalar(0.0), motionState, shape, btVector3(0,0,0));
dynamicsWorld->addRigidBody(box1);
//*** box2 - DYNAMIC / mass=btScalar(1.0)
shape = new btBoxShape(btVector3(0.5,0.5,0.5));
trans.setIdentity();
qtn.setEuler(0.8, 0.7, 0.4);
trans.setRotation(qtn);
trans.setOrigin(btVector3(-0.1, 0.5, 0));
motionState = new btDefaultMotionState(trans);
box2 = new btRigidBody(btScalar(0.5), motionState, shape, btVector3(0.5,0.5,0.5));
dynamicsWorld->addRigidBody(box2);
------------------------------------------------------
-
- Posts: 14
- Joined: Wed Feb 09, 2011 8:35 pm
Re: Question about bullet physics engine + opengl integratio
All those lines are explained in detail by the Hello World example here http://www.bulletphysics.org/mediawiki- ... ello_World. The only thing I can do is copy and paste the lines of that wiki to this post, which I'm not going to. I'm sorry if you don't understand it after reading the Wiki, but you really should.
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
ok I will try it.
thank you very much!!
thank you very much!!
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: Question about bullet physics engine + opengl integratio
Bullet is not a rendering library, anyhow you can use
to see the shapes... You have to set debugDrawer first
you can take one/look at one from Demos/OpenGL.
To draw the object you can map physics object and graphics objects... For example you
use btBoxShape.. Create similar sized graphics box, color it, texture it, use shaders or whatever else... Get transform matrix of physics box and draw you graphic box....
Code: Select all
m_dynamicsWorld->debugDrawWorld();
Code: Select all
m_dynamicsWorld->setDebugDrawer(my_debug_drawer);
To draw the object you can map physics object and graphics objects... For example you
use btBoxShape.. Create similar sized graphics box, color it, texture it, use shaders or whatever else... Get transform matrix of physics box and draw you graphic box....
Code: Select all
float m[16];
btTransform t;
t.setIdentity();
if (body)
{
if (body->getMotionState())
{
body->getMotionState()->getWorldTransform(t);
}
else
{
t = body->getWorldTransform();
}
t.getOpenGLMatrix(m);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMultMatrixf(m);
glCallList(body_displaylist); // or draw it somehow
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
Last edited by mi076 on Sun Apr 17, 2011 6:22 pm, edited 1 time in total.
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
Blender? I don't know what the blender is.
Can you explain to me?
I like to learn bullet physics engine and how to use the engine.
but I cannot understand it by myself.
I hope there is some teacher or guider for me.
Can you explain to me?
I like to learn bullet physics engine and how to use the engine.
but I cannot understand it by myself.
I hope there is some teacher or guider for me.
-
- Posts: 22
- Joined: Mon Dec 20, 2010 7:13 pm
Re: Question about bullet physics engine + opengl integratio
You can't understand it because:unplugea wrote:Blender? I don't know what the blender is.
Can you explain to me?
I like to learn bullet physics engine and how to use the engine.
but I cannot understand it by myself.
I hope there is some teacher or guider for me.
1) You haven't learnt how things in c++(or any other language) work.
2) You can't read, search for information.
You won't get much help if you don't help yourself by doing the best you can, and showing what you have done.
-
- Posts: 144
- Joined: Fri Aug 01, 2008 6:36 am
- Location: Bonn, Germany
Re: Question about bullet physics engine + opengl integratio
Not, of course i mean Bullet..Blender?
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
I saw you typed "Blender" and then you modified that.
anyway, first of all you are right. I am a beginner of c++ but I developed some application during 1 year.
and the only way I can do for learning bullet Physics engine is asking here.
Although I read the manual, It was difficult to understand to me. so I asked here.
as you told me, I have searched some book lelated bullet or manual or anything I can fine. but there is not much information.
I would like to learn about bullet physics. but there is no one i can ask.
-------------------------------------------------
You can't understand it because:
1) You haven't learnt how things in c++(or any other language) work.
2) You can't read, search for information.
You won't get much help if you don't help yourself by doing the best you can, and showing what you have done.
-------------------------------------------------
anyway, first of all you are right. I am a beginner of c++ but I developed some application during 1 year.
and the only way I can do for learning bullet Physics engine is asking here.
Although I read the manual, It was difficult to understand to me. so I asked here.
as you told me, I have searched some book lelated bullet or manual or anything I can fine. but there is not much information.
I would like to learn about bullet physics. but there is no one i can ask.
-------------------------------------------------
You can't understand it because:
1) You haven't learnt how things in c++(or any other language) work.
2) You can't read, search for information.
You won't get much help if you don't help yourself by doing the best you can, and showing what you have done.
-------------------------------------------------
-
- Posts: 8
- Joined: Fri Apr 15, 2011 1:18 am
Re: Question about bullet physics engine + opengl integratio
I tested below code :
but the program is not working. I don't know why.
--------------------------------------------------------------
void RenderScene()
{
glColor3f(0.0, 0.0, 1.0);
glPushMatrix();
box1->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(0.;
glPopMatrix();
////*** draw box2
glColor3f(1.0, 1.0, 0.0);
glPushMatrix();
box1->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(0.5);
glPopMatrix();
timer_check();
}
void timer_check()
{
float dtime = m_time;
m_time = glutGet(GLUT_ELAPSED_TIME) / 500.0;
dtime = m_time - dtime;
if(dynamicsWorld)
dynamicsWorld->stepSimulation(dtime, 10); <<--- because of this line!
}
void SetPhysics()
{
//*** init Bullet Physics
btQuaternion qtn;
btCollisionShape *shape;
btDefaultMotionState *motionState;
btDefaultCollisionConfiguration *collisionCfg
= new btDefaultCollisionConfiguration();
btAxisSweep3 *axisSweep
= new btAxisSweep3(btVector3(-1.0,-1.0,-1.0), btVector3(1,1,1), 128);
dynamicsWorld = new btDiscreteDynamicsWorld(new btCollisionDispatcher(collisionCfg),
axisSweep, new btSequentialImpulseConstraintSolver, collisionCfg);
dynamicsWorld->setGravity(btVector3(0, -0.8, 0));
//*** box1 - STATIC / mass=btScalar(0.0)
shape = new btBoxShape(btVector3(0.2,0.2,0.2));
trans.setIdentity();
qtn.setEuler(0, 0.25, -0.05);
trans.setRotation(qtn);
trans.setOrigin(btVector3(0, -0.2, 0));
motionState = new btDefaultMotionState(trans);
box1 = new btRigidBody(btScalar(0.0), motionState, shape, btVector3(0,0,0));
dynamicsWorld->addRigidBody(box1);
//*** box2 - DYNAMIC / mass=btScalar(1.0)
shape = new btBoxShape(btVector3(0.5,0.5,0.5));
trans.setIdentity();
qtn.setEuler(0.8, 0.7, 0.4);
trans.setRotation(qtn);
trans.setOrigin(btVector3(-0.1, 0.5, 0));
motionState = new btDefaultMotionState(trans);
box2 = new btRigidBody(btScalar(0.5), motionState, shape, btVector3(0.5,0.5,0.5));
dynamicsWorld->addRigidBody(box2);
delete shape;
delete motionState;
delete collisionCfg;
delete axisSweep;
}
--------------------------------------------------------------
but the program is not working. I don't know why.
--------------------------------------------------------------
void RenderScene()
{
glColor3f(0.0, 0.0, 1.0);
glPushMatrix();
box1->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(0.;
glPopMatrix();
////*** draw box2
glColor3f(1.0, 1.0, 0.0);
glPushMatrix();
box1->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(0.5);
glPopMatrix();
timer_check();
}
void timer_check()
{
float dtime = m_time;
m_time = glutGet(GLUT_ELAPSED_TIME) / 500.0;
dtime = m_time - dtime;
if(dynamicsWorld)
dynamicsWorld->stepSimulation(dtime, 10); <<--- because of this line!
}
void SetPhysics()
{
//*** init Bullet Physics
btQuaternion qtn;
btCollisionShape *shape;
btDefaultMotionState *motionState;
btDefaultCollisionConfiguration *collisionCfg
= new btDefaultCollisionConfiguration();
btAxisSweep3 *axisSweep
= new btAxisSweep3(btVector3(-1.0,-1.0,-1.0), btVector3(1,1,1), 128);
dynamicsWorld = new btDiscreteDynamicsWorld(new btCollisionDispatcher(collisionCfg),
axisSweep, new btSequentialImpulseConstraintSolver, collisionCfg);
dynamicsWorld->setGravity(btVector3(0, -0.8, 0));
//*** box1 - STATIC / mass=btScalar(0.0)
shape = new btBoxShape(btVector3(0.2,0.2,0.2));
trans.setIdentity();
qtn.setEuler(0, 0.25, -0.05);
trans.setRotation(qtn);
trans.setOrigin(btVector3(0, -0.2, 0));
motionState = new btDefaultMotionState(trans);
box1 = new btRigidBody(btScalar(0.0), motionState, shape, btVector3(0,0,0));
dynamicsWorld->addRigidBody(box1);
//*** box2 - DYNAMIC / mass=btScalar(1.0)
shape = new btBoxShape(btVector3(0.5,0.5,0.5));
trans.setIdentity();
qtn.setEuler(0.8, 0.7, 0.4);
trans.setRotation(qtn);
trans.setOrigin(btVector3(-0.1, 0.5, 0));
motionState = new btDefaultMotionState(trans);
box2 = new btRigidBody(btScalar(0.5), motionState, shape, btVector3(0.5,0.5,0.5));
dynamicsWorld->addRigidBody(box2);
delete shape;
delete motionState;
delete collisionCfg;
delete axisSweep;
}
--------------------------------------------------------------
You do not have the required permissions to view the files attached to this post.