Page 1 of 1

3dsmax, oriented spawnpoints and rotation

Posted: Mon Nov 08, 2004 3:38 pm
by tenkei
Hi there,

I'm currently working on implementing oriented spawnpoints into our project. The goal is to have vehicles appear correctly oriented in front of a start/finish line on a track.

What I'm doing is:
1) I put a placeholder object (say, an arrow) in max where I want the spawnpoint to be
2) I rotate the object in max to orient it the way I want players to be oriented as they spawn in the game
3) I modified the exporter to not actually export that object's geometry but only its position/orientation (via userproperties).
4) I export the object and spawn the player according to the position/orientation I get from it.

The problem is, the orientation I get in Ogre is nothing like the orientation I have in Max!
I'm thinking this might be because the placeholder's mesh's orientation information is lost as I ignore its geometry... at any rate, about an hour messing around with different values produced no clear results

Has anyone else had this problem? Or do you guys have a better idea on how to do this? All help appreciated :)

Cheers

Posted: Mon Nov 08, 2004 11:51 pm
by PeterNewman
I think you kind of stepped out of the range of the help desk with the line
3) I modified the exporter to not actually...
Perhaps if you detail what changes you made?

Posted: Tue Nov 09, 2004 12:14 am
by tenkei
Sorry, I should've been more specific.

First, I'm talking about the scene exporter for max. We're using the dotsceneoctree plugin for our scene management.

I have several "placeholder" objects in my scene for which I don't want the geometry to be exported. They're there to provide gameplay information to the game, through their position, orientation and user-defined properties.

We're using max as a level editor, if you will.

The modification I made to the exporter makes it skip the mesh processing part for those placeholder objects and instead writes the relevant info into the .scene xml.

The information is then parsed from the .scene file by the game and data structures are initialized from it...

The only thing my modifications do, in essence, is skip the mesh generation for the placeholder items. I'd like to keep it that way, no point in having unused .meshes lying around. But because of this, I'm apparently also losing some orientation data...

Posted: Tue Nov 09, 2004 10:43 am
by Cyberdigitus
i guess you're aware Ogre has an Y-up and Max a Z-up coordinate system?

Posted: Tue Nov 09, 2004 11:36 pm
by PeterNewman
Something you will want to check is, when we export objects from MAX, their orientation gets "baked" into the verticies. So rather being, say a cube, that is rotated around this axis, its a set of vertecies that are in this, this, and this position, that is the end result of the rotated cube.

Check your Scene XML file, see whats in there.

Posted: Thu Nov 11, 2004 3:18 pm
by tenkei
Okay, so from what I understand, I'm screwed. There appears to be no easy way to "properly" get the orientation of a mesh in max to do what I need to.

This poster apparently had the same problem as I did, but no good solution has been found...
Is there a reason for the vertices to be "baked" into the mesh file? Seems to me like there should at least be an option to export meshes as suggested here...
So, in short, if I want correct orientation, I can't use meshes as my placeholder objects. Does anyone have any suggestions on what else I can use in max to store my data?

Cyberdigitus: yes, I'm aware of that. I'm using the exporter's getPRS() method to get orientation data, and I'm pretty positive it already does the Y/Z swapping as required...

Thanks all :)

Posted: Thu Nov 11, 2004 3:48 pm
by iq
Why not get coordinates of 2 'special' vertices an calculate the orientatin from that? (or center and normal of a face)

Posted: Thu Nov 11, 2004 6:17 pm
by tenkei
Okay, after some further hacking I managed to get "coherent" orientation data by using a dummy object in max instead of a mesh.

It still kinda sucks because there's no easy way of seeing which way it's oriented in max, but it's far better than trying to guess numbers at random.

Also, rotating in one direction in max seems to cause my mesh to rotate in the opposite direction in ogre. Still, it's an improvement! It was fairly easy to implement into the exporter too, as the hooks for exporting helper objects (such as Dummy) are already there.

Posted: Fri Nov 12, 2004 12:42 am
by PeterNewman
Glad to hear you've found a semi-solution. Keep us informed of how it goes, I think a few people want to do what your doing.

Posted: Fri Nov 12, 2004 7:15 pm
by tenkei
Making good progress here.

I'm back to using meshes as my "placeholder" objects.

After reading this, I updated my exporter to export object-coordinates (vs world coordinates) for meshes. Since I want to retain compatibility with the dotsceneoctree, I'm only switching to object-coords for my placeholder objects (for which I still don't export geometry), while keeping world-coords for the rest of the meshes.

This way the position/rotation aren't baked into the mesh's vertices anymore and the rotation info is coherent.

The second step was to provide each placeholder object with a "reference" from which to calculate rotation. What I did was loading an arrow mesh for my spawnpoint from a separate max file. Without rotating it, I cloned it, and applied the necessary transformations to the clone. Apparently, IGame magically saw it was a clone of the original object and when I exported both of those, I had something like this:

Code: Select all

    <nodes name="Scene Root" id="-1">
        <node name="_reference" id="8411">
            <entity meshfile="_reference.mesh" static="true" physics="true" name="_reference" id="8411" />
        </node>
        <node name="_homebase.01" id="8413">
            <homebase id="1" lineNumber="0" maxPlayers="3" spaceBetweenPlayers="1.5" />
            <position x="-80.0226" y="-39.9836" z="-225.473" />
            <rotation qx="0" qy="0.5" qz="0" qw="0.866025" />
        </node>
    </nodes>
As you can see, "_homebase.01" is rotated relatively to "_reference". Which is basically just what I wanted.

Now this thing still needs some polishing, but afterwards I'd be happy to share my dirty, undocumented code with whoever wants it. ;)

Posted: Thu Jan 27, 2005 6:50 pm
by tenkei
Huh.

Upgrading to Ogre 0.15.x broke this (with the angle classes changes, I suspect).

Is there anyone out there who knows his igame library and would be willing to help me out? :)

Thanks!

Posted: Fri Jan 28, 2005 1:02 pm
by fantastico
Dunno if it'll be any help, but my MAXScript exporter runs every quaternion or position through this function;

Code: Select all

function convertUnit i =
(
    m = (Matrix3 [-1,0,0] [0,0,1] [0,1,0] [0,0,0])
    newI = i * m
    return newI
)
Every quaternion and positions comes across into Ogre's coordinate system perfectly. It's perfectly possible to do this with the classes exposed by the 3ds max sdk too.

fantastico

Posted: Fri Jan 28, 2005 6:07 pm
by tenkei
Hm. I guess I'm missing something crucial here.

I tried multiplying my orientation quaternion by the matrix you provided. It didn't help much, the orientations were still messed up (though in a different way ;))

As I explained above, I export my placeholder objects in relation to a "reference" object, that's located at 0,0,0 and doesn't have any rotation applied to it.

I clone that object and applied the necessary rotation to the clones. This used to work quite well after export when we used Ogre 0.14.x, but after upgrading to 0.15.x this suddenly broke.

Now, all of the clones have the same orientation as the reference object for some reason (although they have the correct positions).

It's been a few days that I'm trying not to go insane over this, so if anyone has any idea, it'd be cool :)

For info, I'm using cTh's scene exporter, with my own modifications (unrelated to orientation export)

Posted: Wed Feb 02, 2005 11:26 am
by tenkei
Anyone? :?
This is really messing up several important aspects of the game I'm working on, and I'm really out of ideas here.

Help :(

Posted: Wed Feb 02, 2005 2:54 pm
by sinbad
Can't you just debug the position / orientation values of the nodes you're creating and trace them from the source (the exporter)? Sorry, but most of us aren't wealthy enough to own such an expensive tool as 3DS.

Posted: Wed Feb 02, 2005 6:39 pm
by tenkei
Okay, I've tried exporting with Octopus (from the Yake project) and the orientations are exported fine. However, Octopus' written in maxScript, while cTh's exporter is in C++/IGAME.

So far I've no idea how to do the equivalent of what's done in Octopus with IGAME but I'll be looking at it.