Thursday 12 July 2012

Bullet physics btRaycastVehicle + Cocos3D

My long term goal is to make some form of truck game.  I'm not 100% sure what the game objectives will be, but I do know that it will be in 3D and will require simulated physics.


As a little example of what I have accomplished so far(very basic) I have recorded the following video.






Now that I have got Cocos3D up and running with Bullet physics, I thought the first step would be to try and implement some of their examples.


This is where the ray cast vehicle came into play.

I have had to make some alterations to the btRaycastVehicle library to get it up and running.


I could not for the live of me get the steering rotation to render correctly within cocos3d.


So I stripped out the steering rotation from within bullet and now do this within my cocos3d app.


In


void btRaycastVehicle::updateWheelTransform( int wheelIndex , bool interpolatedTransform)


I have changed


wheel.m_worldTransform.setBasis(steeringMat * rotatingMat * basis2);


to


wheel.m_worldTransform.setBasis(steeringMat   * btMatrix3x3(m_chassisBody->getOrientation()));


Now within my cocos3d application I have a wheel node that renders the position and steering angle of the physics wheel and a child node that is actually the tyre.


I rotate the tyre node manually from my wheels rotation information


tyre.rotation = cc3v(-1 * (wheelInf.m_rotation * (180/3.142)),0,0);

The above converts the m_rotation in radians to the degrees required for cocos3d rotation.

Unfortunatly after all this it has shown to me that a raycast vehicle doesn't really work for trucks moving over terrain, so I will now need to construct one from scratch! Lets see what happens....

Duncan.





3 comments:

  1. Hi! Im having trouble to create a 2D menu(inside cocos3d) like what you had in your video. Can you teach me how you do that?? Thanks!

    please email me at soxx6740@mylaurier.ca

    ReplyDelete
  2. Great Blog to you share, its very useful to us.
    There is no hard and fast rule you need to follow up when it comes to the iOS Development Services In USA of the mobile apps. The guidelines we did mention for you are excessive important that would help you a lot at the end of the day.

    ReplyDelete
  3. Tired of hearing about how much we love remote working? Take it from some others! Rounded up below are 27 Quotes on Remote Work and flexible lifestyles from some major power players.

    ReplyDelete