O'Reilly logo

3D Game Development with Microsoft Silverlight 3 Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—rotating 3D characters

You have a problem. UFOs do not fly just by moving through the space. They usually rotate around themselves while moving in the different directions.

Now, we are going to add rotation capabilities to this 3D character.

  1. Stay in the 3DInvadersSilverlight project.
  2. Open Ufo.cs.
  3. Add the following protected variables. (The UFO has to keep track of the rotation angles and it has to rotate at certain speeds, both defined for each axis):
    // The rotation angles
    protected Vector _angleDegrees = new Vector(0, 0, 0);
    // The rotation speed for the three axis
    protected Vector _rotationSpeed = new Vector(10f, 5f, 0f);
    
  4. Add the following public method to calculate the UFO's rotation angles taking into account its rotation speed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required