Object Orientation Problem 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

Object Orientation Problem on iPhone

Post by vikthered »

Hey guys,

I'm building a 3d car game on the iphone platform using sio2 game engine. I've implemented a third person cam mode. However, i'm finding it difficult to orient my car properly whenever my car comes in contact with a hill/slope.

Please see this (u'll kno wat i mean)->http://www.youtube.com/watch?v=E5p1yHWdpDQ


as you can see my car doesnt change its orientation watsoever. sio2 game engine has been integrated with Bullet, so i can use Bullet to do all that for me.

I've written this code to get the normals at contact points. I'm trying to find the average Normal and use this for my car orientation. (i have no idea wat im doing is even correct!)

This is executed whenever a collision occurs between the car and the terrain

Code: Select all

btRigidBody *_btRigidBody = NULL;
	btVector3 avgNormal(0,0,0);
	
	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();
			
		
			
			_btPersistentManifold->getContactPoint(j).m_localPointA.normalize();
			
			avgNormal += _btPersistentManifold->getContactPoint(j).m_localPointA;
			
			++j;
		}
		
		
		avgNormal /= j;
		
		
		++i;
	}
	
and now i'm stuck here. This is all i could manage. I want to know if it is possible to use the vehicle class demo on iphone (without affecting the performance). I've seen the Bullet SDK Manual but couldnt understand most of it.

My car(single mesh, ie no separate wheels) is a RigidBody (sphere shape) and the terrain is a static triangle mesh.

I'd be glad if someone could help me out. Any code contribution is welcome :wink:
vikthered
Posts: 6
Joined: Fri Aug 07, 2009 7:00 pm

Re: Object Orientation Problem on iPhone

Post by vikthered »

i'm looking for code that'll orient my car properly whenever it goes upslope/downslope....

or any idea that'll help me get started
cheers:D
vikthered
Posts: 6
Joined: Fri Aug 07, 2009 7:00 pm

Re: Object Orientation Problem on iPhone

Post by vikthered »

please help me people! :|