Forums

Full Version: VDrift coordinate system
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been thinking about moving the track editor functionality into blender. But I am somewhat irritated by the coordinate transforms.
A vertex(parkinglot track) in blender (-15, 179, 4.5) has the following coordinates in the track editor (179, 4.5, -15) :o

edit:
This means a 90° rotation around x-axis followed by 90° around z-axis?
I had a look at the code. So we have:

Code:
TRACK::LoadParameters()
...
pos.Set(f3[2], f3[0], f3[1]);
...
QUATERNION <float> orient(f3[2], f3[0], f3[1], f1);

So what do we have here take position xyz from start position and load it as zxy. The same happens to the orientation.

Code:
bool CAR::Load
...
//due to historical reasons the initial orientation places the car faces the wrong way
fixer.Rotate(3.141593,0,0,1);
dynamics.SetInitialConditions(initial_position, fixer*initial_orientation);

Load applies a 180 degrees rotation to the orientation around z-axis.


Code:
void CAR::CopyPhysicsResultsIntoDisplay()
.....
quat = dynamics.GetOrientation();
fixer.Rotate(-3.141593*0.5, 0, 0, 1);
bodynode->GetTransform().SetRotation(quat*fixer);

The orientation is updated by the physics multiplied with a -90 degrees rotation around z-axis(the fixer again).

Well, I've got a track export plugin which allows to do the complete track setup/creation within blender. But not being able to reproduce this orientation transforms in the plugin it returns incorrect orientations.

PS: My test track for the track exporter Tongue
[Image: test10v7gi.jpg]
[Image: testxs5f3.jpg]
Ooh, rainbow road! :-) That's got to be a hard track to drive on.

The transforms are crazy. Sorry about that. When I rewrote everything I had to keep the insanity intact to avoid changing the data. I went back and fixed the car coordinate system:
http://wiki.vdrift.net/Coordinate_systems
but haven't fixed the track coordinate system.

Anyway, it sounds like you have it figured out now. Are you still having trouble reproducing the orientation? One option would be to change the track orientations to match blender like I did with the .car file. I've actually been meaning to rewrite the track file format and combine the track.txt and list.txt and surfaces.txt and so on into one file.
i really like that track.. alot!

supertuxkart.sourcefourge would probably really like that track too.

for their kart game, you should check it out
Yeah, the track is a homage to Mario Kart 64. Big Grin
Hey Joe

I had a look at some of the track JPKs in blender. They have z-axis as up-axis. So the coordinate system transforms affect roads.trk, track.txt only?
I could write a tiny script to fix the coordinate transforms in this files.

Or we change the track file format now. Joining track.txt and surfaces.txt and roads.trk. (I am almost done with the import/export trk scripts.)
So, what's the coordinate system now, and what's the desired coordinate system? Is the desired coordinate system the opengl coordinate system that VDrift uses to render stuff (Y=up)? Or is the desired cooridnate system the blender coordinate system (Z=up)?
Personally, I would prefer the opengl(Y=up) orientation to get rid of the fix rotations in the code. I would modify the importer/exporter scripts and update the JOEs and JPKs. We would lose compatibility to old data. This could cause confusion among users/contributors Sad
Maybe increment the version counter on the .joe files, process them to change their rotations to the Y=up coordinate system, then (at runtime) if it's the old version, apply the rotation fix, if not, don't. Eventually once there are a couple of releases out with the newer coordinate system support, remove support for the old. What do you think?
Sounds good. So the next step is moving the rotation fixes into the joe loading code?
Yeah, that sounds good.