Point of Origin and Rotation

Post Reply
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Point of Origin and Rotation

Post by Click16 »

Hello everybody. I need some help with this little issue. I'm making a program that basically does what Amorphous Remedy does, but has more features, and uses mach tags instead of bloc tags. Anyways, The Point of Origin of the boxes in 3ds max are located at the top of the box, where in Halo 2, it gets centered. I'll draw up some diagrams to explain what I mean.

This is how the 3ds Max Rotation looks, as being rotated in 3ds max
Image

As you can see, the point of origin is at the top of the cube (or square in this example), and the cube is rotated about that location.

Now when that data gets translated to Halo 2, the point of origin becomes the center of the cube, and now the rotation looks like this
Image

I need to determine a mathematical formula, using the degrees of rotation, and the X and Y coords of the original square (centered, or not centered origin), so it looks like this
Image

So the data I have to data from the cubes to work with is the Length (L), Width (W), Height (H), X Coordinate (X), Y Coordinate (Y), Z Coordinate (Z), Roll (Xr), Pitch (Yr), and Yaw (Zr) to make this work. (Variable names are in parenthesis, if you're gonna post a mathematical formula, try to use these variables I supplied :P)

Also please assume the Roll, Pitch, and Yaw are in degrees, not radians.
In this 2D example, Use Length, Width, X, Y, and Yaw.
Last edited by Click16 on Thu Aug 14, 2014 9:15 pm, edited 1 time in total.
Image
User avatar
NotZachary82
Posts: 1846
Joined: Thu Dec 20, 2007 8:39 pm

Re: Point of Origin and Rotation

Post by NotZachary82 »

Does it really move the origin to the center of the object? I was under the impression that exporting a .OBJ file automatically sets the origin of each element to 0,0,0. THAT would cause the rotation in-game to be different than in 3ds Max.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: Point of Origin and Rotation

Post by XZodia »

Click your question doesn't even make sense...

You should make change the origin of the box in Max to be at the center, not try and fix it later.
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Point of Origin and Rotation

Post by Click16 »

@Zach
This has nothing to do with display models, this program is all about resizing and positioning collision boxes. (which don't have a render model associated with them)

@XZodia
This is the way 3ds max creates cubes, and I really don't want to have to manually move the transform point every time I make a box in 3ds max.
Image
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: Point of Origin and Rotation

Post by XZodia »

Well your rotations wouldnt make sense unless you do so, because rotating about a point other than the center effectively adds a translation to your box on top of the rotation
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Point of Origin and Rotation

Post by Click16 »

which is exactly what I'm trying to accomplish, I need to know the math to get the translated X and Y coords. I will probably make a few test programs and try out some trigonometry functions to figure out how to do this.
Image
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: Point of Origin and Rotation

Post by XZodia »

I really dont advise this method however, to get the translation:

Part A:
Find the center
Calculate the distance from the pivot point to the center
Normalize this distance

Part B:
Reverse the Rotation
Find the center
Calculate the distance from the pivot point to the center
Get the Length of this distance

Part C:
Multiply the vector from Part A with the length from Part B
Take this vector away from the position of the box
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
neodos
Posts: 1493
Joined: Sun Dec 09, 2007 8:58 pm

Re: Point of Origin and Rotation

Post by neodos »

You should not change the object's transform(aka pivot point) to move/rotate/scale.

You want to use a "working pivot" or a temporary pivot to move/rotate/scale your object from different points so that the object gets translated, but the object's pivot actually doesn't get modified when you do it, the object pivot should be at the center of the mesh and have its original orientation.

For exporting to game engines, generally and specifically on this case, since we are dealing with collision boxes, you want the object's pivot to be at the center of the mesh.

Here's some examples, box just created, its local transform and global transform look like this:
Image

If I move, rotate or scale the object, its local transform still is centered and orientaded as it original was, and should be!

Image

Global transform now looks like this (global transforms are orientated relative to the world transform)

Image


Here's a quick video that explains working pivot, I don't use 3Ds max, so not sure if there are faster tools to do this:
http://www.youtube.com/watch?v=M6SHIKIDOPU


As for exporting the position and rotation data, it should be easy as long as you have exported each box that has a different scale as an individual "bloc" (+coll + phmo etc).

Normally, it would be better to have every different box placed at the origin of the scene for exporting as the base objects for the coll/phmo and visual model, but given how you are building boxes over your level directly and then wanting to export placed boxes, you can still do it, it just requires a bit more programming.

You can either write a mesh exporter to do this, or you can also more easily freeze the object scale tranform so that its scale is applied to the mesh and 3DS max should take care of exporting the data properly for you, there should be export options to choose if you want to export the meshes as individual objects and in global or local space as well as the transform order (XYZ).

But if you want to write a mesh exporter, 3DS max should have a scripting/programming API with all the math and functions to the local/global space conversions, and most likely the mesh components can be read in local and global space already.
You want to export the vertex position relative to the local space (its transform that should be at the center of the mesh, and properly rotation aligned to the box-mesh (0,0,0)) for mesh data.

As for exporting the position and rotation data for spawning the bloc item, you want to export the pos/rot relative to Global space (global pivot/transform).
This is assuming you kept the box pivot at its center and properly oriented, as it should be went you created the box.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Point of Origin and Rotation

Post by Click16 »

Yeah looking at the documentation for 3ds max, I think there is an easy way to move the pivot point to the center just by clicking one button, so if this works, i'll just use this method. EDIT: Fuck me sideways, there is literally a little flyout button menu that lets you click "use center transform" Edit again: Well it doesn't seem like this actually moves the pivot point, it is just shows it moved, and it works like normal, but it isn't the objects actual pivot point.
Image
User avatar
NotZachary82
Posts: 1846
Joined: Thu Dec 20, 2007 8:39 pm

Re: Point of Origin and Rotation

Post by NotZachary82 »

This?

Image

Center to Object
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Point of Origin and Rotation

Post by Click16 »

Yeah I completely forgot about that button -_- well, good news everyone, its working perfectly now!

Image

Image
Image
User avatar
NotZachary82
Posts: 1846
Joined: Thu Dec 20, 2007 8:39 pm

Re: Point of Origin and Rotation

Post by NotZachary82 »

Do ramps make your feet go in the ground?
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Point of Origin and Rotation

Post by Click16 »

Its a slight mismatch with the collision box and the map's mesh, I would fix it, but its such a little problem that i'm not even gonna bother

Actually, it looks like it, but all of the weapon impact effects and everything appear fine on the surface, as well as grenades and whatnot. I think it might just be MC with this one...
Image
User avatar
neodos
Posts: 1493
Joined: Sun Dec 09, 2007 8:58 pm

Re: Point of Origin and Rotation

Post by neodos »

Great to see you sorted it out! I was worried even if you can reset the pivot to the center, as most 3D apps can, if you do it after you have moved and rotated your object, the orientation of the pivot won't be aligned to the cube, so that might cause problems.

For the slopes, maybe its the player collider yeah, perhaps the phmo is a bit shifted, projectiles use the "coll" collision model while the player users the phmo for movement over the surfaces.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: Point of Origin and Rotation

Post by Click16 »

Yeah I'm aware of the roles of the coll and phmo, but its just a slight visual bug, and I'm not going to stress over it. I'm just glad my program is finally working properly. Its almost ready for release. Just need to make it handle String ID material assignment, and we'll be good to go!
Image
Post Reply