Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ACamera.cpp File Reference


Detailed Description

implements the 'camera_' functions in AEngine.h

Definition in file ACamera.cpp.

#include "AEngine.h"
#include "AUtil.h"

Include dependency graph for ACamera.cpp:

Include dependency graph

Go to the source code of this file.

Functions

void camera_set (const Vec3D pos, const Vec3D target, const FLOAT smoothness)
 -----------------------------------------------------------------------------------

Vec3D camera_getPos ()
 get the current camera position

Vec3D camera_getVec ()
 get the current direction vector

void camera_setScreenSize (FLOAT size)
 set the portion of the screen that will be drawn on should be called in update(), not render() (nothing) 0<size<=1 (fullscreen)

void camera_addVibration (float amount)


Function Documentation

void camera_addVibration float    amount
 

Definition at line 69 of file ACamera.cpp.

References absf.

Referenced by BattleGroup::destroyUnit().

00070 {
00071         amount = absf(amount);
00072         if( AS.camera_vibrateSpeed > 0 )
00073                 AS.camera_vibrateSpeed += amount;
00074         else
00075                 AS.camera_vibrateSpeed -= amount;
00076 }

Vec3D camera_getPos  
 

get the current camera position

Definition at line 51 of file ACamera.cpp.

References Vec3D.

00052 {
00053         return AS.camera_pos;
00054 }

Vec3D camera_getVec  
 

get the current direction vector

Definition at line 56 of file ACamera.cpp.

References Vec3D.

Referenced by BattleGroup::render().

00057 {
00058         Vec3D dir = AS.camera_target - AS.camera_pos;
00059         FLOAT len = D3DXVec3Length(&dir);
00060         return dir * 1.0f/len;
00061 }

void camera_set const Vec3D    pos,
const Vec3D    target,
const FLOAT    smoothness
 

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

Definition at line 26 of file ACamera.cpp.

References Vec3D.

Referenced by BattleEntry::input(), Overhead::overhead_render(), and Overhead::processOverheadInput().

00027 {
00028         assert( 0<=smoothness && smoothness<=1 && "camera smoothness must be between 0,1");     
00029         AS.camera_pos    = smoothness*AS.camera_pos    + (1.0f-smoothness)*pos;
00030         AS.camera_target = smoothness*AS.camera_target + (1.0f-smoothness)*target;
00031 
00032         // apply vibration
00033         FLOAT accel = - AS.camera_vibratePos * 5.7f;
00034         AS.camera_vibrateSpeed  += accel;
00035         AS.camera_vibrateSpeed  *= 0.96f;
00036         AS.camera_vibratePos    += AS.camera_vibrateSpeed * 0.4f;       
00037         AS.camera_pos.z += AS.camera_vibratePos * 0.05f;
00038         AS.camera_target.z += AS.camera_vibratePos * 0.05f;
00039 
00040         // prevents looking straight down
00041         if( AS.camera_pos[0]==AS.camera_target[0] && AS.camera_pos[1]==AS.camera_target[1] )
00042                 AS.camera_pos[1] += 0.00001f;
00043         
00044         const Vec3D upAxis( 0.0f, 0.0f, 1.0f );
00045         D3DXMatrixLookAtLH(&AS.camera_viewMatrix, &AS.camera_pos, &AS.camera_target, &upAxis );
00046         D3DXMatrixPerspectiveFovLH( &AS.camera_projMatrix, D3DXToRadian(60), 1.33333f, 0.1f, 1000.0f );
00047 
00048         AS.camera_world2projMatrix = AS.camera_viewMatrix * AS.camera_projMatrix;       
00049 }

void camera_setScreenSize FLOAT    size
 

set the portion of the screen that will be drawn on should be called in update(), not render() (nothing) 0<size<=1 (fullscreen)

Definition at line 63 of file ACamera.cpp.

00064 {
00065         assert( size>0.0f && size<=1.0f );
00066         AS.camera_screenSize = size;
00067 }


Generated on Wed Apr 23 05:50:17 2003 for Modern Warfare by doxygen1.3-rc2