| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
| Connecting U3D + Newton for an arbitrary Keep Upright Constraint; An intense math problem | |
|---|---|
| Tweet Topic Started: May 11 2009, 06:33 AM (240 Views) | |
| skarik | May 11 2009, 06:33 AM Post #1 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
So, how do I do it? I've got a working track, but hell, every time I turn, I flip over. Now, I remember that in Half Life 2, they had the same problem with the vehicles, but they solved that with a loose keep-upright constraint, a gravity gun, and a very expensive physics engine. Not to mention, they had four wheels, and I have zero wheels. I've got a vector that describes the 'downward' direction. Basically, it's a vector pointing to where the vehicle should anchor to. This vehicle hovers slightly above the ground (say an average of 10 units) to prevent smashing into ramps. The vector here is named gravity_vector . Not only do I use it for calculating the force, I also use it for ray-tracing to the track to check the distance to the track itself. The only function that's available for me to use is GmnBodyAddTorque(world,body,Fx,Fy,Fz) . The problem with this function is that it doesn't exactly lie in a direct translation from U3D's coordinate space to GM-Newton's coordinate space. I'm pretty sure that this deals in Newton's world space. From what I could tell, when my vehicle is pointing to roty = 90, Fx becomes the roll, Fy becomes the pitch, and Fz becomes the yaw. That means, to the U3D world, Fx is the pitch, Fy is the roll, and Fz is the yaw. When I do the movements for my vehicle, I create a vector for the basic untransformed directions. Basically, it's like <Fx,Fy,Fz>. I then use the transformation matrix of my vehicle - that I create earlier from a costly conversion - to transform that movement vector. I then just use the vector values to move my vehicle. So if roty = 90, the resultant vector would be something along the lines of <Fy,Fx,Fz>. That, I know. The thing is with the torque is that I only want to change the local roll, nothing else. Normally, I would think the variable would then be rotz, but then you have to figure out how to transform the roll into relation so that gravity is down and the front of the vehicle is forward. At least, that's what I think I have to do. Correct me if I'm wrong. Now, I don't know how to change the gravity vector into a transformation matrix. Normal gravity would be <0,0,-1> , but I can't figure out how in a matrix that would translate. What I see in my mind is that normal gravity of <0,0,-1> and front facing direction of roty = 0 degrees = <0,1,0> would translate to a matrix of all zeros. That's where I'm stuck. So if anybody has any ideas, that would be great. You know what would be really bad? If it turned out all I had to do was transform the gravity by the front facing direction. That would result in all zeros. |
| Blog|EHS | |
![]() |
|
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |





![]](http://z1.ifrm.com/static/1/pip_r.png)



10:20 AM Jul 11