Moving btRigidBody

Overlord
Posts: 7
Joined: Sat Jun 21, 2008 7:23 pm

Moving btRigidBody

Post by Overlord »

I'm working on networking and i want to update the client's Object positions.

if i do:
object->getmotionstate->setWorldTransform(trans) nothing happens to the object.

however if i do:
object->setWorldTransform(trans) it seems to generally update correctly. But it appears the rotation is wrong. Even though i'm just setting it with the numbers i got from get.

But i'm not sure if even that is what i should be doing.
I need a way to set the rotation and position but i've been unable to find a way.

Any help or suggestion would be most appreciated. Thanks :)
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: Moving btRigidBody

Post by chunky »

object->getmotionstate->setWorldTransform(trans) nothing happens to the object.
Because that's moving your visible object on-screen, not the actual rigid body - the next time that the physics ticks, you're going to lose that update.
object->setWorldTransform(trans) it seems to generally update correctly. But it appears the rotation is wrong. Even though i'm just setting it with the numbers i got from get.
Define "wrong". Is it off by a small amount? Is the object rotating backwards instead of forwards?

If it's the first one, your network prediction might just be squiffy?

Gary (-;
Overlord
Posts: 7
Joined: Sat Jun 21, 2008 7:23 pm

Re: Moving btRigidBody

Post by Overlord »

o' ok.

and its wrong as in, the objects seem almost perpendicular to where they should be.

I copy the transformation and then take each part of the position and each part of the rotation (x, y, z, and w) and send them as doubles over the network.

So perhaps its the fact that i'm sending them as doubles?


and just a side question what is the w for anyways?
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: Moving btRigidBody

Post by chunky »

and just a side question what is the w for anyways?
Heh. If you have to as, then you also need to ask what the x,y, and z are for, too :-D

http://en.wikipedia.org/wiki/Quaternion

The short answer, and the best way to piss off mathematicians, is '"quaternions are for avoiding gimbol lock", which is where you lose the ability to rotate your object along one or more of its axes because computers are strictly linear beasts.
and its wrong as in, the objects seem almost perpendicular to where they should be.
What are you actually using for output? If you're seeing them always off by 90 degrees or so, then the odds are that your rendering system is using a left [or right] handed co-ordinate system, while bullet is using a right [or left] handed co-ordinate system.

Gary (-;
Overlord
Posts: 7
Joined: Sat Jun 21, 2008 7:23 pm

Re: Moving btRigidBody

Post by Overlord »

I'm using irrlicht for displaying everything.

and i thought it might be the displaying wrong as well, however i dont think that's the case because the server shows everything just fine and they both display the same way.

Thats why i've been thinking its something else.
Overlord
Posts: 7
Joined: Sat Jun 21, 2008 7:23 pm

Re: Moving btRigidBody

Post by Overlord »

So i think i've got it. My problem was i was sending in 1.0 for w every time, left over from earlier code. Put it in right this time and i think i got it working :).


Thank you so much for everything though! :D
chunky
Posts: 145
Joined: Tue Oct 30, 2007 9:23 pm

Re: Moving btRigidBody

Post by chunky »

My problem was i was sending in 1.0 for w every time
Easy mistake to make when you switch from euler to quaternions :-)

Gary (-;