Would you like to react to this message? Create an account in a few clicks or log in to continue.

simple problem, two colliding objects

2 posters

Go down

simple problem, two colliding objects Empty simple problem, two colliding objects

Post  sctm81 Fri Jul 24, 2009 2:14 am

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.


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();

      SIO2transform* CubeSize = sio2TransformInit();
      SIO2transform* CubeLocation = sio2TransformInit();

      sio2TransformSetLoc(BallLocation, &BallLocationVector);
      sio2TransformSetScl(BallSize, &BallSizeVector);
      sio2TransformSetLoc(CubeLocation, &CubeLocationVector);
      sio2TransformSetScl(CubeSize, &CubeSizeVector);

2. Create ball object.

SIO2object *BallObject = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource,  SIO2_OBJECT, "object/Sphere" );

3. Create rigid body object in bullet for ball object.


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


      BallObject->_SIO2transform = BallLocation;
      sio2TransformBindMatrix( BallObject->_SIO2transform );

      BallObject->_SIO2transform = BallSize;
      sio2TransformBindMatrix( BallObject->_SIO2transform );

5. Set linear velocity


   sio2PhysicPlay( sio2->_SIO2physic );
      BallObject->_btRigidBody->setActivationState( ACTIVE_TAG );

6. Render Object

      sio2ObjectRender(BallObject, sio2->_SIO2window, sio2->_SIO2camera, 0, SIO2_RENDER_SOLID_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!


Posts : 29
Join date : 2009-04-24

Back to top Go down

simple problem, two colliding objects Empty Re: simple problem, two colliding objects

Post  sio2interactive Fri Jul 24, 2009 2:41 am

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 Wink

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum