3D Camera Rotation

Jan 1, 2013 at 8:56 PM

I'm trying to understand why I can't get the 3D camera to rotate properly. I'm using the basic default scene with a plane and a couple of primitives added to it. I've also added a camera and have been trying to rotate it so that it points down from 90 degrees above the plane. However, I can't get it to work as I want it.

What kind of rotation is used? Are the values in degrees or radians?

Also, is there a way of accessing the rotation property of the Camera from code?

Developer
Jan 1, 2013 at 10:37 PM
Edited Jan 1, 2013 at 10:55 PM

All transformations (All Objects) are using radians.

There is a easy way of setting the Transformation on a object in Xaml:

 

<Box Transform="{Transform RotationY={Degrees 45}}">
     <BasicMaterial LightingEnabled="True" Texture="{ContentReference ../Textures/box}"  />
</Box>

// {Transform RotationY={Degrees 45}, RotationX={Degrees 45}}
// Contains ;
//   Vector3's
//     Rotation, Scale, Position
//   float's;
//     RotationX, RotationY, RotationZ
//     ScaleX, ScaleY, ScaleZ
//     PositionX, PositionY, PositionZ

 

 

The Camera is stored in Scene's Drawing Context that can be accessed by 'Scene.GetDrawingContext();', it is an extension from Nine.Graphics. But I would recommend naming (In Xaml) the Camera and then get it by name.  

Jan 3, 2013 at 10:17 AM

That's quite a nice way of doing it. So what you've shown will convert the Degrees into Radians?

So how do I access the scene's default camera if I haven't got one set up already?

Developer
Jan 3, 2013 at 2:22 PM
Edited Jan 3, 2013 at 2:23 PM

Yes, using {Degrees 0} will convert it to Radians.

If you haven't specified the camera in xaml, it will by default be a Free Camera.

 

// Gets the drawing context to adjust drawing settings.
var drawingContext = scene.GetDrawingContext(GraphicsDevice);
var Camera = drawingContext.Camera;