locked
Camera Follow In Direct3D 9.0 RRS feed

  • Question

  •  

    Hello , I Have Rendered A Earth Mesh That Rotates around it self .... I can move This Earth With Arrow Keys ...

    But I Can't Make The Camera To Follow it , [ For example I want to rotate camera around the erath , What Should am I Do ? ] , [When Earth Rotates , Camera Start Rotation Automaticly]   ,,,

     

    here is My Code :

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    void RenderEarthMesh()

     {

      ang += 0.01f; //Angle of The Earth Rotations

      Vector3 Translation = new Vector3(0, 0, -1);//Position The Earth

      Matrix rot = Matrix.RotationY(ang);

      Matrix World = Matrix.Translation(Translation);

      dev.Transform.World = rot * World; //By This Code , Earth Start it's Rotation

      DrawEarth();

    }

    void UpdateCamera()

    {

     Vector3 campos = new Vector3(ang, 0, -1);

     Vector3 camTarget = new Vector3(ang, 0, -1);

     Vector3 camUp = new Vector3(0, 1, 0);

     Matrix view = Matrix.LookAtLH(campos, camTarget, camUp);

     dev.Transform.View = view;

    }

     

    Thanks ..
    Sunday, January 13, 2008 9:51 PM