Most efficient method of implementing 6dof objects?

Started by
12 comments, last by rumblesushi 13 years, 4 months ago
Quote:Original post by rumblesushi
Oh, what I want to ask is, could you advise me on a better way to handle the vehicle's orientation?
The most direct solution to this problem, IMO, is to use an existing physics engine that provides robust vehicle dynamics.

Aside from that, I can't really offer any sort of conclusive answer. You can simply align the object to the surface beneath it of course, but even with interpolation it's only an approximation and will likely result in your vehicle clipping into other objects in the scene.

Another option might be to raycast downwards from each of the four wheels (assuming there are four wheels), and choose from the four planes that can be generated from the intersection points one for which the other intersection point lies below the plane, and then align and position the vehicle accordingly. But, I'm just guessing - I haven't tried anything of that sort myself, so I can't say for sure how effective it would be.

Again though, for any sort of realistic simulation, an existing physics engine might be your best bet.
Advertisement
I probably should have said, an existing physics engine isn't possible, because I'm working in AS3.

Obviously in C++ you have the luxury of engines like Bullet, that apparently perform very well.

The only existing physics engine is HIDEOUSLY slow, so I really have no choice but to do all my own physics, which so far, work pretty well.

I have a highly efficient broadphase and sphere to triangle routine, for general object to environment collisions, but obviously vehicle physics are a fair bit more complex than that.

Also as it happens, the handling and collision detection on my soft body car is absolutely fine, the only bit that isn't working is the orientation (when introducing roll), which should be significantly easier than the handling and collisions. I have a collision routine for all 4 wheels and it works perfectly. My car is essentially a 3D rectangle tied together with constraints.

So really, orienting it to the terrain shouldn't be difficult at all, I have 4 points that define a plane (the wheels), maybe my best bet would be to simply orient the vehicle to the normal generated by these plane points.

Thanks for your help anyway jyk.
Yeah, if you have a rectangle in 3-d, you should be able to build the orientation from that. You can compute the forward and side basis vectors by subtracting appropriate vertices of the rectangle from other vertices of the rectangle and normalizing, and then compute the up basis vector as the cross product of those two. Then, you can build a matrix from these basis vectors and a position vector (e.g. the center of the rectangle).
Because I'm working on so many things at once I tend to overlook the obvious.

For some reason I was incrementing the rotation of each axis on the car from the angles defined by the front/back of the car, and the left/right wheels.

When of course, the best, simplest and most accurate thing to do is simply define the matrix from scratch for the car's orientation.

So obviously the car's z axis is the vector from the front and back of the car, the car's y axis is the plane normal defined by the 4 wheels, pointing up, and the x axis is the cross product between the z axis and normal.

It works perfectly now.

This topic is closed to new replies.

Advertisement