Camera Class Reference

#include <Camera.h>

List of all members.

Public Member Functions

 Camera (float winRatio, float x, float y, float z)
void SetPosition (float x, float y, float z)
void ChangeRatio (float winRatio)
void SetProjection ()
void SetCamera ()

Private Member Functions

void CalcValues ()

Private Attributes

float m_ratio
float m_angle
float m_angle2
float m_position [3]


Detailed Description

Definition at line 9 of file Camera.h.


Constructor & Destructor Documentation

Camera::Camera ( float  winRatio,
float  x,
float  y,
float  z 
)

Definition at line 19 of file Camera.cpp.

References ChangeRatio(), and SetPosition().

00019                                                         {
00020   ChangeRatio(winRatio);
00021 
00022   // Set the camera position
00023   SetPosition(x, y, z);
00024 }


Member Function Documentation

void Camera::CalcValues (  )  [private]

Definition at line 55 of file Camera.cpp.

References m_angle, m_angle2, m_position, and radiansToDegrees().

Referenced by SetPosition().

00055                         {
00056   m_angle = radiansToDegrees(atan2(m_position[1], fabs(m_position[2])));
00057   m_angle2 = radiansToDegrees(atan2(m_position[0], m_position[2]));
00058 }

void Camera::ChangeRatio ( float  winRatio  ) 

Definition at line 35 of file Camera.cpp.

References m_ratio.

Referenced by Camera().

00035                                        {
00036   m_ratio = winRatio;
00037 }

void Camera::SetCamera (  ) 

Definition at line 47 of file Camera.cpp.

References m_angle, m_angle2, m_position, and SetProjection().

Referenced by StateSailing::Display(), Battle::Display(), and SetPosition().

00047                        {
00048   SetProjection();
00049 
00050   glRotatef(m_angle, 1.0, 0.0, 0.0);
00051   glRotatef(m_angle2, 0.0, 1.0, 0.0);
00052   glTranslatef(m_position[0], -1*m_position[1], -1*m_position[2]);
00053 }

void Camera::SetPosition ( float  x,
float  y,
float  z 
)

Definition at line 26 of file Camera.cpp.

References CalcValues(), m_position, and SetCamera().

Referenced by Camera(), StateSailing::HandleKeyDown(), and Battle::HandleKeyDown().

00026                                                   {
00027   m_position[0] = x;
00028   m_position[1] = y;
00029   m_position[2] = z;
00030 
00031   CalcValues();
00032   SetCamera();
00033 }

void Camera::SetProjection (  ) 

Definition at line 39 of file Camera.cpp.

References m_ratio.

Referenced by SetCamera(), StateSailing::SwitchTo(), and Battle::SwitchTo().

00039                            {
00040   glMatrixMode(GL_PROJECTION);
00041   glLoadIdentity();
00042   gluPerspective(60.0, m_ratio, 1.0, 512.0);
00043 
00044   glMatrixMode(GL_MODELVIEW);
00045 }


Member Data Documentation

float Camera::m_angle [private]

Definition at line 30 of file Camera.h.

Referenced by CalcValues(), and SetCamera().

float Camera::m_angle2 [private]

Definition at line 31 of file Camera.h.

Referenced by CalcValues(), and SetCamera().

float Camera::m_position[3] [private]

Definition at line 32 of file Camera.h.

Referenced by CalcValues(), SetCamera(), and SetPosition().

float Camera::m_ratio [private]

Definition at line 29 of file Camera.h.

Referenced by ChangeRatio(), and SetProjection().


The documentation for this class was generated from the following files:
Generated on Mon Jan 8 22:34:14 2007 for CrownandCutlass by  doxygen 1.4.7