Garry Adams

Garry Adams

  • NA
  • 530
  • 86k

Animate camera look direction using XAML and C#

May 12 2014 6:05 PM
I think I'm a glutton for punishment. I am just learning Visual C# and have gotten to the chapter in my book about graphics and then the chapter about WPF. After the book's only example of 3D, rotating a pyramid, I have started writing a 3D maze game. I know, it would be easier if I had the DirectX SDK, but I have no internet connnection (how barbaric and primitive!) and only get an hour a day at the local library, so I can't download it.

I have created the 3D environment, made wall objects to place in my maze, got the camera position to change as I walk around, etc. My problem is I want to animate the camera to turn left or right from the current look direction. I can do it in pure C# but not have the 3D of XAML, or I can do it in XAML ONCE, but I want to be able to do it every time I turn. My resource is the MSDN help file and I can't find exactly what I want. If only XAML used variables.

I have used a Storyboard with Vector3DAnimation to achieve this, but have trouble setting up the different multiple animations I need:  i.e. turn left from north (-1,0,0) to (0,-1,0) AND turn left from west, etc. Is there a way to do this??

Currently I press a key to turn left or right from the current look direction and change the perspective camera's look direction all at once. I want to be able to turn slowly instead of just "snapping" to the new look direction. Animate using key frames, animate using properties, animate using matrix (haven't tried that one) are not doing what I want with my currently limited skill set and knowledge.

Has anyone out there done this, or have some hints, tricks, clues, suggestions or code examples????

I would love to hear from someone with advice about this.

I have been programming for many years but I am very new to C# and XAML.

I will be posting some of the games I have written in the last month when I come back to the library.

Thanks in advance for any help,
Garry

Does anyone know how to do this?