Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista Tutorial - Rotating the PerspectiveCamera

 
 
Old 02-28-2006   #1 (permalink)
Kevin Hoffman
Guest


 
 

Rotating the PerspectiveCamera

Ok... I've got a scene where my camera is above (Y+) and away from (Z+)
my 3D object. I can move the camera toward the object by doing this:

camera.Position += camera.LookDirection;

I find that quite handy, really intuitive, and brings back fond
memories of Vector study in Physics class in college

What I want is to be able to 'turn' the camera to the left or to the
right. At first glance, I thought I might just increment or decrement
the X value of the LookDirection... the problem is you get an
"approaches infinity" type of foreshortening effect there - as you turn
more and more left, the effect becomes more and more off because you're
still looking at a point off in the distance at the X axis, not
actually turning the camera the way it should be.

What I _think_ I should be doing is applying a 3D Axis rotation where I
rotate X degrees negative about the Y axis when turning the camera
left, and X degrees positive about the Y axis in order to spin the
camera to the right.

What I can't quite figure out is how to accomplish a transform of the
Unit Vector indicating my LookDirection. I've tried creating a
RotateTransform3D based on an AxisAngleRotation3D as follows:

RotateTransform3D cameraSpinner = new RotateTransform3D(
new AxisAngleRotation3D(new Vector3D(0,1,0), -10));

In my newbie little brain, this should create a transformer that will
rotate something about the Y axis (the 0,1,0 unit vector) to the 'left'
10 degrees.

The problem is the RotateTransform3D only operates on a Point3D or an
array of Point3Ds... so how does one Transform the LookDirection vector
by rotating the LookDirection of the camera about the Y axis?

I'm sure this is something totally trivial and I'm missing it because
I'm a complete newbie, but I would love for someone's input on how to
accomplish this..

Thanks,
Kevin


My System SpecsSystem Spec
Old 02-28-2006   #2 (permalink)
Kevin Hoffman
Guest


 
 

Re: Rotating the PerspectiveCamera

Valentin,
That looks like a good plan... The only problem I have is that when
I use the following line:

(camera1.Transform as MatrixTransform3D).Matrix *= rt3d.Value;

I end up with a run-time error telling me that I cannot modify the
Matrix property because its in a read-only state.

My System SpecsSystem Spec
Old 02-28-2006   #3 (permalink)
Kevin Hoffman
Guest


 
 

Re: Rotating the PerspectiveCamera

If I had to guess at the behavior here, I would say that the camera is
actually rotating about the Y axis as it passes through the origin,
rather than spinning about its own Y axis (e.g. its rotating around the
origin on Y rather than spinning in place).

My System SpecsSystem Spec
Old 02-28-2006   #4 (permalink)
Kevin Hoffman
Guest


 
 

Re: Rotating the PerspectiveCamera

GOT IT!
I do remember saying that it felt as though the rotational
transformation was taking place relative to a centerpoint of the origin
rather than the camera itself being the centerpoint...So,I added:

rt3d.CenterZ = camera1.Position.Z;
rt3d.CenterY = camera1.Position.Y;
rt3d.CenterX = camera1.Position.X;

Before I did the matrix multiplication and it works like a champ.

I knew it was something simple that I was missing, and setting the
centerpoint of the axis rotation to be the camera's position instead of
the origin was definitely a "D'oh!" moment... Thanks for all the
support getting me this far.

My System SpecsSystem Spec
Old 03-01-2006   #5 (permalink)
Jason [Mobiform]
Guest


 
 

Re: Rotating the PerspectiveCamera

Maybe this is a recent addition, but RotateTransform3D.Transform does seem
to accept Vector3D and Vector3D[].

Jason

"Kevin Hoffman" <alothien@gmail.com> wrote in message
news:1141154351.928956.174110@u72g2000cwu.googlegroups.com...
> Ok... I've got a scene where my camera is above (Y+) and away from (Z+)
> my 3D object. I can move the camera toward the object by doing this:
>
> camera.Position += camera.LookDirection;
>
> I find that quite handy, really intuitive, and brings back fond
> memories of Vector study in Physics class in college
>
> What I want is to be able to 'turn' the camera to the left or to the
> right. At first glance, I thought I might just increment or decrement
> the X value of the LookDirection... the problem is you get an
> "approaches infinity" type of foreshortening effect there - as you turn
> more and more left, the effect becomes more and more off because you're
> still looking at a point off in the distance at the X axis, not
> actually turning the camera the way it should be.
>
> What I _think_ I should be doing is applying a 3D Axis rotation where I
> rotate X degrees negative about the Y axis when turning the camera
> left, and X degrees positive about the Y axis in order to spin the
> camera to the right.
>
> What I can't quite figure out is how to accomplish a transform of the
> Unit Vector indicating my LookDirection. I've tried creating a
> RotateTransform3D based on an AxisAngleRotation3D as follows:
>
> RotateTransform3D cameraSpinner = new RotateTransform3D(
> new AxisAngleRotation3D(new Vector3D(0,1,0), -10));
>
> In my newbie little brain, this should create a transformer that will
> rotate something about the Y axis (the 0,1,0 unit vector) to the 'left'
> 10 degrees.
>
> The problem is the RotateTransform3D only operates on a Point3D or an
> array of Point3Ds... so how does one Transform the LookDirection vector
> by rotating the LookDirection of the camera about the Y axis?
>
> I'm sure this is something totally trivial and I'm missing it because
> I'm a complete newbie, but I would love for someone's input on how to
> accomplish this..
>
> Thanks,
> Kevin
>



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
screen rotating Vista performance & maintenance
Rotating Images Vista print fax & scan
Rotating Images Vista music pictures video
Rotating a received fax Vista print fax & scan
Rotating menu Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46