Notifications
Clear all

[Closed] z-up to y-up crisis

Hey everyone,

I’ve resurected some old export routines I used to use for max to After Effects for another project, but to be completely honest I’m a bit rusty on the ole 3D.

Position is fine, a simple case of swap the Y and the Z, then negate the Z in the new coordinate system.

What is really frying my noodle is the rotation though. There’s this extra 90 degrees that comes from somewhere, and I’m not sure what to do with it. I’ve seen various bits of advice on the web, bu I’m not sure how to translate that into useable code.

Do I do the rotate just on the X value, or with an entire matrix?

I’d really appreciate some help here. I’ve said I can do the job, now I’m feeling under a lot of pressure to complete, and I’m hacking around and getting near, but not near enough.

Many thanks,
Dave

21 Replies

All you have to do is multiply your vector or matrix from the Z-up system with the transformation matrix which converts Z-up into Y-up:

yUp = someZupVectorOrMatrix * matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0]

This flips the axes by taking the +Z as +Y and the +Y as -Z and will convert rotation and scale parts correctly, too.

To convert from Y-up back to Z-up, just use the inverse() of the conversion matrix above which is

zUp = someYupVectorOrMatrix * matrix3 [1,0,0] [0,0,-1] [0,1,0] [0,0,0]

Hi Bobo,
Thanks for replying! I couldn’t post for half an hour or so, but I’m checking it out now.
I’m sure I’ll be back in a mo with another question…

Hi Bobo,
Ok – the position looks great, but I just don’t seem to be getting the rotations I’m apparently supposed to be getting.

According to the developer who’s buildling the engine in Flash, if a FreeCamera is facing forwards (ie, looking the same way the front viewport is looking) it should have a rotation of [0,0,0].

However, with your matrix the rotation is [-180,0,0].

Adding 180 degrees solves the problem, and the camera then faces the other objects we’ve created, but then the world then appears upside down, and rotations in X appear to go the opposite way to the camera in max (ie, when it’s supposed to look up, it looks down)!

Any ideas what I’m missing, or maybe he’s missing?

Thanks,
Dave

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

I might have provided the matrices incorrectly – try swapping the two and see if you are getting correct results. It was from top of my head, not tested…

Hello,
Not sure if anyone is looking at this, but I’m battling through my Friday night / Saturday morning here – it would be really great if someone could chime in.
Thanks,
Dave

Hi Bobo,
Now the Y rotation is flipped, and the Y position is also flipped.

It’s almost like the result of the first solution needs to be reflected through the Y-Up Z axis (as when you look out on the scene through the newly transformed coordinates, the pitch up / down is flipped).

Imagine putting your arm through the screen as if you were pushing an inside-out sock the right way out – does that make sense?

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Hmm.
If I create a free camera at the origin pointing DOWN the -Z axis and multiply its transformation by the matrix, I get a camera pointing along the +Y axis (which is the -Z axis in Y-up systems = Front). The Max camera, in order to look into the Front viewport, has to be rotated at 90 degrees to match its local -Z axis with the +Y of the world. By default, it just looks down.

Is the problem you are seeing related to ALL objects or just cameras?

Please note that I am leaving the office now and will be back online in about 2 hours.

Hi again Bobo.

I really appreciate you taking the time to help me out as I’m clearly out of my depth on this one!

I’m not sure if I can answer your question about ALL objects or only cameras, as the engine I’m working with only allows me to import 2 kinds of objects; a 15x15x2 tile that makes up a grid of tiles that gets blown around by exported PFlow particles, and a virtual camera to look at said particles.

(FYI the engine is called PaperVision 3D – you may have seen some 3D Flash sites recently – most of them, eg Sony Bravia, are taking advantage of this new engine).

With your camera example, I get the same results you do.

So if my camera is pointing into the front viewport (the same way I am looking at the screen), the rotation value in max is [90,0,0].

The equivilent rotation value in the Y-Up system (for the camera to be looking the same way – into the screen) woudl be as [0,0,0].

So, if I then run the first matrix, the max camera rotates 90 degrees, and points upwards, and the rotation reads [+/-180,0,0].

For position values that are not [0,0,0], the X, Y & Z position appear to be correctly swapped, but it’s this +/-180 rotation that has me stumped, as it doesn’t sit nicely with the “looking forward” ideal in the new system, of [0,0,0].

Actually – if I look closely at the camera now in max, it’s FOV cone is now coming out the BACK of it!

Is it this initial 90 that is throwing everything out? I don’t have the experience you have in this area to help too much

It’s about 2:45am here, so probably best I hit the hay.
I’ll catch up with this thread in the morning.

Cheers,
Dave

The Max Camera and the Y-up Camera are inherently different in respect to their worlds, and the funny thing is that this difference is caused by the fact that they are identical in their working!

A Free Max Camera with no transforms (identity matrix) always points down the -Z axis.
A Free Camera in any Y-up world looks at the Front view along the -Z axis of the Y-world.

The problem is that while the worlds have different axis configurations and the OBJECTS in them also align to these axes, the Cameras in both look at the world with their -Z axes, using the X as the width and the Y as the height of the projection plane.

In fact, the main reason for the existence of the Y-up world is to align to a default camera looking at the Front view instead of the Top!

Thus, if a teapot is created in Max with no transforms and converted to Y-up, its axes will change (the vertical axis will change from Z to Y, the Y will change to -Z and X will remain the same), but the mesh will convert correctly and it will LOOK the same in both worlds.

But in the case of a camera, a camera looking down in Max turns into a camera looking at Front in Y-up world, which is a difference of 90 degrees about the X axis. So you will have to compensate for these 90 degrees for Cameras only.

Aha… a full and more than satisfactory explanation! Thanks.

The only thing is - can you give me a clue as to how I would go about creating this "special case" for cameras!?

I hate to ask, but my export pipeline is such a pain - it feels like sword-juggling blindfolded - I don't have a choice what I can give the engine, so it's difficult / impossible to produce test scenes at this time.


Do I just add / subtract 90 to the world rotation value of the camera in X, or do I need to rotate the matrix? (I'm assuming the first solution, as a matrix solution would alter position, right?)

As well, I don't have the firmest grasp on cumulative transforms down a hierarchy. At the moment I'm doing everything in world space to try and resolve any hierarchical issues that will arise.

In the meantime, I’ll be trying different solutions based on your input.

Thanks,
Dave

Just out of curiosity, have you tried NOT converting the camera at all? What orientation do you get?

3 Replies
(@davestewart)
Joined: 11 months ago

Posts: 0

Hmm… I’ll try this to see what happens.
(Most likely it will point down, and not front in the new coordinate system.)

(@bobo)
Joined: 11 months ago

Posts: 0

Actually, a camera in Max looking at the front view is equivalent to a camera looking down transformed by the Yup matrix (rotation at +90 degrees). So if a camera pointing down transforms into camera pointing Front, a camera pointing Front should transform 90 degrees more into a camera looking up. Thus, try multiplying by (rotateXmatrix -90) ONLY without the other transform and see what happens. That would turn a camera looking front in Zup into a camera looking down in Zup, which should result in a camera looking front in Yup.

(@davestewart)
Joined: 11 months ago

Posts: 0

This is beginning to make sense to me now.

As the Max camera has already been rotated 90 degrees in max to make it look front, then is rotated again in the Y-up-export, it gets rotated a total of 180 degrees – just to do nothing!

Which is why I was needing to compensate in Flash…

Page 1 / 2