Simple complete newbie question!

markhula
Posts: 34
Joined: Thu Jun 17, 2010 10:11 am

Simple complete newbie question!

Post by markhula »

Hi all,

From what I have seen Bullet is great; but my maths/physics are rather limited so go easy on me :lol:

I want to do something apparently simple and that is rotate a mesh to a fixed angle.
I understand once bullet takes over that simple rotations of the transform matrix aren't really possible.

I have looked at setangularvelocity but of course this applies a velocity and so the object continues rotating.

Ultimately I want a fixed rotation to an angle (degs or rads); but can't see how I reset the velocity increment.

Or of course I am approaching the problem completely incorrectly from bullets point of view. :oops:

Any help appreciated

Mark

P.S I attempting this on an iphone.
chrozz
Posts: 8
Joined: Fri Mar 12, 2010 10:21 pm

Re: Simple complete newbie question!

Post by chrozz »

From the init code of a static object in one of my scenes...

Code: Select all

	btTransform startTransform;	
        startTransform.setIdentity();
	startTransform.setOrigin(btVector3(0,-.05f,-6.90));
	startTransform.setRotation(btQuaternion(btVector3(0,1,0),-M_PI/2)*btQuaternion(btVector3(1,0,0),-M_PI/2))
	hookColl = fileLoader2->getCollisionShapeByName("compoundShape2");
	hookBody= localCreateRigidBody( 0, startTransform,hookColl);
So all you need to do is set up a transform , give it its origin, rotation.The rotation can be specified using a Quaternion. So use one of the constructors for btQuaternion to find your angle.http://www.bulletphysics.com/Bullet/Bul ... rnion.html

Then pass the transform to a localCreateRigidBody implementation. In my case I am using a nearly unmodified version of the localCreateRigidBody from the BulletDemos.
markhula
Posts: 34
Joined: Thu Jun 17, 2010 10:11 am

Re: Simple complete newbie question!

Post by markhula »

Hi Chrozz,

OK!, I'll give it a go, though I need to "dumb it down" a bit and convert for iphone usage (I'm running the sio2 lib which sits ontop bullet).
Assuming this works (or my version of it anyway!) how do I then have my mesh angle when going up/down et.c the landscape floor. The only control I need is to be able to rotate around local z (i.e. to face the direction I wish to move in).

Cheers

Mark