btRaycastVehicle on iPhone

Please don't post Bullet support questions here, use the above forums instead.
vikthered
Posts: 6
Joined: Fri Aug 07, 2009 7:00 pm

btRaycastVehicle on iPhone

Post by vikthered »

Hey guys,

I'm having a tough time porting the vehicle demo on the iphone? Has anyone implemented btRaycastVehicle on an iPhone?

Can you please share the xcode proj file. I'm sure it'll help many in the forum.


cheers :D
josemarin
Posts: 38
Joined: Fri Aug 12, 2005 5:37 pm

Re: btRaycastVehicle on iPhone

Post by josemarin »

Hi,

What kind of problems are you having?

Send us some code, so we can understand what you are trying to do.

Regards

Jose
vikthered
Posts: 6
Joined: Fri Aug 07, 2009 7:00 pm

Re: btRaycastVehicle on iPhone

Post by vikthered »

Please see my work so far...http://www.youtube.com/watch?v=E5p1yHWdpDQ

I couldnt understand the vehicle demo but ive managed to write this piece of code. Im using sio2 game engine..

Code: Select all


SIO2object *object = NULL;
btVector3 avgNormal(0,0,0);

SIO2sensor *Sensor = NULL;

void mySIO2sensorcollision ( void *_ptr )
{
   
   btRigidBody *_btRigidBody = NULL;
   
   
   unsigned int i = 0,
   j;
   
   while( i != sio2->_SIO2physic->_btSoftRigidDynamicsWorld->getDispatcher()->getNumManifolds() )
   {
      btPersistentManifold *_btPersistentManifold = sio2->_SIO2physic->_btSoftRigidDynamicsWorld->getDispatcher()->getManifoldByIndexInternal( i );
      
      j = 0;
      while( j != _btPersistentManifold->getNumContacts() )
      {
            _btRigidBody = ( btRigidBody * )_btPersistentManifold->getBody0();
         
      avgNormal = _btPersistentManifold->getContactPoint(j).m_normalWorldOnB;
         
                  
         
         ++j;
      }
      
      
      
      ++i;
   }
   
   
                      btMatrix3x3 mat3;
         
         
         mat3.setFromOpenGLSubMatrix( (btScalar *)object->_SIO2transform->mat );
         
         object->_SIO2objectphysic->_btRigidBody->getWorldTransform().setBasis( mat3 );
         

                      //Dont know how to orient my car 
//         object->_SIO2transform->dir->x += ??;---->?????????????? 
//         object->_SIO2transform->dir->y += ??;
//         object->_SIO2transform->dir->z += ??;
         
         sio2TransformBindMatrix(object->_SIO2transform);
         object->_SIO2objectphysic->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( object->_SIO2transform->mat );
               

}
As you can see, i'm unable to orient the car along the terrain.. What i did was setup a collision sensor between my car and the terrain. I'm finding the normals at the contact points, but i dont know how to convert all the normals into ONE single normal along which ive to orient my car. (average normal perhaps?)

As you know sio2 is integrated with Bullet, so using btRaycastVehicle would be simpler but there's so much detail...many forces...Also was unsure if its gonna work on an iPhone without slowing down...so i wanted to know if anyone has already done the btRaycastVehicle thing on the iPhone and was willing to share it on the forum:D

cheers:)