Which way is Up?

Oct 6, 2011 at 8:50 AM
Edited Oct 6, 2011 at 9:25 AM

I've been wrestling with cameras, and suddenly realised I may have made some unwarranted assumptions. I haven't had these problems before, and it could be because we have different assumptions over world coordinates.

Given a scene consisting of just a skybox (DDS cube) and a teapot.

  • The forward face for the cube by convention is +Z and the up face is +Y. In Nine, it appears that the up face of a skybox is +Z. A FreeCamera initially points at the forward face, which is +Y (I think). A Quaternion camera initally points at the down face, which is -Z (I think).
  • The teapot model is an RHS mesh, with +Y up and +Z pointing out of the screen. The Quaternion camera sees the teapot the right way up (so they agree on Up) and points in the same direction as the handle.

Can you please just tell me which way is Up? Assume a skybox, a mesh at the origin, and a camera, what should it see?Where should the camera be positioned to look at the model? Why?

None of this matters a whole lot if you're using local (model) coordinates, but it matters plenty if you're using world coordinates, and we're living in different worlds! I should add that it seems to work if I assume that

  • world up is +Z
  • skybox up is +Z
  • teapot up is +Y (other models could be different)
  • camera initially points at -Z, camera up is +Y.
Coordinator
Oct 6, 2011 at 10:48 AM

I think different cameras are having different default forward values, but the coordinate system I used in Nine is a RH system with +Z pointing up, +X pointing right and +Y pointing forward.

It is different from the default Xna Vector3 setting, the decision was made mainly because the world I'm tring to create depend heavily on the terrain, it is pretty flat so (x,y) is used to access the terrain.

Assume a skybox, a mesh at the origin, and a camera, what should it see?Where should the camera be positioned to look at the model?

I assume you are asking for the default setting for a camera, I suggest using +Z as up, +X as forward and +Y as right. It's just my personal preference and I cannot think of a reasonable justice.

Consider Armer's comment "but maybe rest of Xna users uses Y as Up", I think the we should be able to set the up axis the of camera.

Or maybe you can first share or checkin your code so we can help with what you're trying to solve together.

Oct 7, 2011 at 12:13 AM

OK, now we're getting somewhere. That explains why what I was doing never seemed to work right. All clear now.

Suggestion: I really think you need to document your choice of world coordinates. Even better, if you could tie those choices into an explicitly settable World vector, it would allow others to make different choices.

I have now completed a sample with a new camera implementation, closely tied into your world coordinates. The reusable code consists of:

  • BasicCamera, implements a set of camera static moves, plus ICamera
  • BasicUpdaterCamera, implements a set of camera dynamic moves, implementing IUpdateable
  • BasicCameraController, implements keyboard and mouse control over the camera, using push input only
  • HudScreen, providing basic on-screen debugging info
  • VectorExtensions (work in progress)

The demo code includes a very basic scene with skybox and a game mainline to glue it together. It works quite well (but still a work in progress).

If you are interested to look at the code, I'll be happy to upload it somewhere. In my opinion the camera implementation could replace most if not all the existing cameras in Nine.The code is in fair shape, but not fully tested and almost certain to need some further work. I'll be interested to get any feedback.

Coordinator
Oct 7, 2011 at 2:56 AM
How about this link (Source Code => Upload Patch)
http://nine.codeplex.com/SourceControl/list/patches/upload?ProjectName=nine

From: [email removed]
To: [email removed]
Date: Thu, 6 Oct 2011 17:13:28 -0700
Subject: Re: Which way is Up? [nine:274950]

From: dyork11
OK, now we're getting somewhere. That explains why what I was doing never seemed to work right. All clear now.
Suggestion: I really think you need to document your choice of world coordinates. Even better, if you could tie those choices into an explicitly settable World vector, it would allow others to make different choices.
I have now completed a sample with a new camera implementation, closely tied into your world coordinates. The reusable code consists of:
  • BasicCamera, implements a set of camera static moves, plus ICamera
  • BasicUpdaterCamera, implements a set of camera dynamic moves, implementing IUpdateable
  • BasicCameraController, implements keyboard and mouse control over the camera, using push input only
  • HudScreen, providing basic on-screen debugging info
  • VectorExtensions (work in progress)
The demo code includes a very basic scene with skybox and a game mainline to glue it together. It works quite well (but still a work in progress).
If you are interested to look at the code, I'll be happy to upload it somewhere. In my opinion the camera implementation could replace most if not all the existing cameras in Nine.The code is in fair shape, but not fully tested and almost certain to need some further work. I'll be interested to get any feedback.
Read the full discussion online.
To add a post to this discussion, reply to this email (nine@discussions.codeplex.com)
To start a new discussion for this project, email nine@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com
Oct 7, 2011 at 3:46 AM

Uploaded. It's a buildable game project, exported from my local repository, not a patch. The code will need to be changed before it could be added to the Nine core.

No readme, just build and run and read the on-screen hud.