Pitch camera around model

Posted by ChocoMan on Game Development See other posts from Game Development or by ChocoMan
Published on 2012-09-21T07:29:44Z Indexed on 2012/09/21 9:51 UTC
Read the original article Hit count: 372

Filed under:
|
|

Currently, my camera rotates with my model's Y-Axis (yaw) perfectly. What I'm having trouble with is rotating the X-Axis (pitch) along with it. I've tried the same method for cameraYaw() in the form of cameraPitch(), while adjusting the axis to Vector.Right, but the camera wouldn't pitch at all in accordance to the Y-Axes of the controller.

Is there a way similar to this to get the same effect for pitching the camera around the model?

// Rotates model on its own Y-axis
    public void modelRotMovement(GamePadState pController)
    {
        Yaw = pController.ThumbSticks.Right.X * MathHelper.ToRadians(speedAngleMAX);

        AddRotation = Quaternion.CreateFromYawPitchRoll(Yaw, 0, 0);
        ModelLoad.MRotation *= AddRotation;
        MOrientation = Matrix.CreateFromQuaternion(ModelLoad.MRotation);          
    }

    // Orbit (yaw) Camera around model
    public void cameraYaw(Vector3 axis, float yaw, float pitch)
    {
        Pitch = pController.ThumbSticks.Right.Y * MathHelper.ToRadians(speedAngleMAX);

        ModelLoad.CameraPos = Vector3.Transform(ModelLoad.CameraPos - ModelLoad.camTarget,
            Matrix.CreateFromAxisAngle(axis, yaw)) + ModelLoad.camTarget;
    }

    public void updateCamera()
    {
        cameraYaw(Vector3.Up, Yaw);
    }

© Game Development or respective owner

Related posts about XNA

Related posts about camera