资源简介
Focus On 3D Terrain Programming.pdf 配套源码,非常有参考意义。
代码片段和文件信息
//==============================================================
//==============================================================
//= camera.cpp =================================================
//= Original coders: Trent Polack (trent@voxelsoft.com) =
//==============================================================
//= The routines for the CCAMERA class
//==============================================================
//==============================================================
//--------------------------------------------------------------
//--------------------------------------------------------------
//- HEADERS AND LIBRARIES --------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
#include “camera.h“
//--------------------------------------------------------------
//--------------------------------------------------------------
//- DEFINITIONS ------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
// Name: CCAMERA::ComputeViewMatrix - public
// Description: Compute the information for the camera
// Arguments: -fTimeDelta: amount to interpolate from last frame
// (defaults to 1.0f)
// Return Value: None
//--------------------------------------------------------------
void CCAMERA::ComputeViewMatrix( float fTimeDelta )
{
if( ( m_fYaw>=360.0f) || ( m_fYaw<=-360.0f ) )
m_fYaw= 0.0f;
if( m_fPitch>60.0f )
m_fPitch= 60.0f;
if( m_fPitch<-60.0f )
m_fPitch= -60.0f;
float cosYaw = cosf( DEG_TO_RAD( m_fYaw ) );
float sinYaw = sinf( DEG_TO_RAD( m_fYaw ) );
float sinPitch= sinf( DEG_TO_RAD( m_fPitch ) );
float cosPitch= cosf( DEG_TO_RAD( m_fPitch ) );
m_vecForward[0]= sinYaw * cosPitch;
m_vecForward[1]= sinPitch;
m_vecForward[2]= cosPitch * -cosYaw;
m_vecLookAt= m_vecEyePos + m_vecForward;
m_vecSide= m_vecForward.CrossProduct( m_vecUp );
}
//--------------------------------------------------------------
// Name: CCAMERA::CalculateViewFrustum - public
// Description: Calculate the planes that make-up the viewing m_viewFrustum
// Arguments: None
// Return Value: None
//--------------------------------------------------------------
void CCAMERA::CalculateViewFrustum( void )
{
float fPMtrx[16]; //projection matrix
float fMMtrx[16]; //modelview matrix
float clip[16];
float fNorm;
/* Get the current PROJECTION matrix from OpenGL */
glGetFloatv( GL_PROJECTION_MATRIX fPMtrx );
/* Get the current MODELVIEW matrix from OpenGL */
glGetFloatv( GL_MODELVIEW_MATRIX fMMtrx );
/* Combine the two matrices (multiply projection by modelview) */
clip[ 0]= fMMtrx[ 0]*fPMtrx[ 0] + fMMtrx[ 1]*fPMtrx[ 4] + fMMtrx[ 2]*fPMtrx[ 8] + fMMtr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 26782 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\camera.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\camera.sbr
文件 2262016 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\demo5_1.bsc
文件 393338 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\demo5_1.exe
文件 470300 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\demo5_1.ilk
文件 211284 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\demo5_1.pch
文件 877568 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\demo5_1.pdb
文件 33276 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\geomipmapping.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\geomipmapping.sbr
文件 44999 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\gl_app.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\gl_app.sbr
文件 25464 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\image.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\image.sbr
文件 19216 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\log.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\log.sbr
文件 83617 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\main.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\main.sbr
文件 31758 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\math_ops.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\math_ops.sbr
文件 47324 2010-11-17 04:44 Code\Chapter 5\demo5_1\Debug\resource.res
文件 43406 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\terrain.obj
文件 0 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\terrain.sbr
文件 173056 2010-11-17 12:34 Code\Chapter 5\demo5_1\Debug\vc60.idb
文件 86016 2010-11-17 11:14 Code\Chapter 5\demo5_1\Debug\vc60.pdb
文件 26782 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\camera.obj
文件 0 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\camera.sbr
文件 2180096 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\demo5_2.bsc
文件 4991432 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\demo5_2.pch
文件 1067525 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\geomipmapping.sbr
文件 44999 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\gl_app.obj
文件 0 2010-11-17 04:43 Code\Chapter 5\demo5_2\Debug\gl_app.sbr
............此处省略773个文件信息
评论
共有 条评论