Camera.cpp
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:2k
- // Camera.cpp: implementation of the CCamera class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Camera.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CCamera::CCamera()
- {
- m_CamPos=VERTEX(10,0,10);
- m_CamDirection=NORMAL(1,0,0);
- m_CamRotX=0;
- m_CamRotY=-90;
- m_CamRotZ=0;
- m_VisualAngle=60;
- }
- CCamera::~CCamera()
- {
- }
- void CCamera::UpdateCamera(VERTEX position,float rotX,float rotY,float rotZ)
- {
- m_CamPos=position;
- m_CamRotX=rotX;
- m_CamRotY=rotY;
- m_CamRotZ=rotZ;
- m_CamDirection=NORMAL(-cosf(rotX*0.0174533f)*sinf(rotY*0.0174533f),
- sinf(rotX*0.0174533f),
- -cosf(rotX*0.0174533f)*cosf(rotY*0.0174533f));
- m_CamDirection=math.Normalization(m_CamDirection);
- }
- void CCamera::UpdateCamera(VERTEX newFoucs)
- {
- m_CamDirection=NORMAL(newFoucs.xpos-m_CamPos.xpos,newFoucs.ypos-m_CamPos.ypos,newFoucs.zpos-m_CamPos.zpos);
- m_CamDirection=math.Normalization(m_CamDirection);
- m_CamRotX=asinf(m_CamDirection.ny)*57.29578f;
- m_CamRotY=acosf(-m_CamDirection.nz/(sqrt(m_CamDirection.nz*m_CamDirection.nz+m_CamDirection.nx*m_CamDirection.nx)))*57.29578f;
- // m_CamRotY=float(57.29583f*acos(-m_CamDirection.nz/(sqrt(m_CamDirection.nz*m_CamDirection.nz+m_CamDirection.nx*m_CamDirection.nx))));
- if(m_CamDirection.nx>0)m_CamRotY=360-m_CamRotY;
- }
- void CCamera::SetVisualAngle(float visualAngle)
- {
- m_VisualAngle=visualAngle;
- }
- float CCamera::GetAngleCosine(VERTEX point)
- {
- float cosValue=math.GetTwoVectorAngleCosine(NORMAL(point.xpos-m_CamPos.xpos,
- point.ypos -m_CamPos.ypos,
- point.zpos-m_CamPos.zpos ) ,
- m_CamDirection);
- if(cosValue>cosf(m_VisualAngle*0.0174533f))
- {
- return cosValue;
- }
- return 0;
- }
- bool CCamera::IsOnFoucs(VERTEX point)
- {
- return false;
- }