simple problem, two colliding objects
2 posters
simple problem, two colliding objects
I am still struggling to use bullet physics in SIO2. In order to understand and get started with Bullet and SIO2 I am trying to solve the basic problem of letting two solid objects collide (without any detection right now) that I created in blender. In order to do that I am doing the following in my render function:
1. Create transforms for the scaling and positioning of both objects.
2. Create ball object.
3. Create rigid body object in bullet for ball object.
4. Apply both transforms to ball object
5. Set linear velocity
6. Render Object
But the objects don't move once I create the rigid body in 3 or if I try using the line
CubeObject->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( CubeObject->_SIO2transform->mat );
(the objects move through each other but don't collide when i omit both lines)
Could somebody please tell me what I am missing in order to get this simple problem solved?
Thanks so much in advance!
1. Create transforms for the scaling and positioning of both objects.
- Code:
vec3 BallLocationVector;
BallLocationVector.x = 480.0f;
BallLocationVector.y = 0.0;
BallLocationVector.z = 0.0f;
vec3 BallSizeVector;
BallSizeVector.x = 3.75;
BallSizeVector.y = 3.75;
BallSizeVector.z = 0.0f;
vec3 CubeLocationVector;
CubeLocationVector.x = 0.0f;
CubeLocationVector.y = 320.0f;
CubeLocationVector.z = 0.0f;
vec3 CubeSizeVector;
CubeSizeVector.x = 3.75f;
CubeSizeVector.y = 3.75f;
CubeSizeVector.z = 0.0f;
SIO2transform* BallSize = sio2TransformInit();
SIO2transform* BallLocation = sio2TransformInit();
//projectile
SIO2transform* CubeSize = sio2TransformInit();
SIO2transform* CubeLocation = sio2TransformInit();
sio2TransformSetLoc(BallLocation, &BallLocationVector);
sio2TransformSetScl(BallSize, &BallSizeVector);
sio2TransformSetLoc(CubeLocation, &CubeLocationVector);
sio2TransformSetScl(CubeSize, &CubeSizeVector);
2. Create ball object.
- Code:
SIO2object *BallObject = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, "object/Sphere" );
3. Create rigid body object in bullet for ball object.
- Code:
btScalar mass(1.f);
btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
btCollisionShape* colShape = new btBoxShape(btVector3(10,10,10));
btVector3 localInertia(0,0,0);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
BallObject->_btRigidBody = new btRigidBody(rbInfo);
4. Apply both transforms to ball object
- Code:
glPushMatrix();
sio2PhysicPause(sio2->_SIO2physic);
BallObject->_SIO2transform = BallLocation;
sio2TransformBindMatrix( BallObject->_SIO2transform );
sio2TransformApply(BallObject->_SIO2transform);
BallObject->_SIO2transform = BallSize;
sio2TransformBindMatrix( BallObject->_SIO2transform );
sio2TransformApply(BallObject->_SIO2transform);
5. Set linear velocity
- Code:
sio2PhysicPlay( sio2->_SIO2physic );
BallObject->_btRigidBody->setActivationState( ACTIVE_TAG );
6. Render Object
- Code:
sio2ObjectRender(BallObject, sio2->_SIO2window, sio2->_SIO2camera, 0, SIO2_RENDER_SOLID_OBJECT );
glPopMatrix();
But the objects don't move once I create the rigid body in 3 or if I try using the line
CubeObject->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( CubeObject->_SIO2transform->mat );
(the objects move through each other but don't collide when i omit both lines)
Could somebody please tell me what I am missing in order to get this simple problem solved?
Thanks so much in advance!
sctm81- Posts : 29
Join date : 2009-04-24
Re: simple problem, two colliding objects
I think you are totally missing the point in the Bullet & SIO2 integration... watch the video tutorial06 5 times in a row then post again
Similar topics
» Problem with tutorial04 simple plain and cube
» Join objects and materials problem?
» Simple Collision Sensor
» Simple Transform Animation System
» duplicating objects at runtime and changing textures on the duplicated objects
» Join objects and materials problem?
» Simple Collision Sensor
» Simple Transform Animation System
» duplicating objects at runtime and changing textures on the duplicated objects
Permissions in this forum:
You cannot reply to topics in this forum