My Project: openb3dlib.mod/openb3d/src/camera.h Source File

My Project

camera.h
Go to the documentation of this file.
1 #ifndef CAMERA_H
2 #define CAMERA_H
3
4 /*
5 * camera.h
6 * iminib3d
7 *
8 * Created by Simon Harrison.
9 * Copyright Si Design. All rights reserved.
10 *
11 */
12
13 #include "global.h"
14 #include "entity.h"
15 #include "mesh.h"
16 #include "sprite.h"
17
18 #include <vector>
19 #include <cmath>
20
21 using namespace std;
22
23 class Camera : public Entity{
24
25 public:
26
27 static list<Camera*> cam_list;
28 static list<Mesh*> render_list;
29
30 int vx,vy,vwidth,vheight;
31 float cls_r,cls_g,cls_b;
32 bool cls_color,cls_zbuffer;
33
34 float range_near,range_far;
35 float zoom;
36
37 int proj_mode;
38
39 int fog_mode;
40 float fog_r,fog_g,fog_b;
41 float fog_range_near,fog_range_far;
42
43 // used by CameraProject
44 int project_enabled;
45 float mod_mat[16];
46 float proj_mat[16];
47 int viewport[4];
48 static float projected_x;
49 static float projected_y;
50 static float projected_z;
51
52 float frustum[6][4];
53
54 Camera(){
55
56 vx=0,vy=0;
57 vwidth=320,vheight=480;
58 cls_r=0.0,cls_g=0.0,cls_b=0.0;
59
60 cls_color=true,cls_zbuffer=true;
61
62 range_near=1.0;
63 range_far=1000.0;
64 zoom=1.0;
65 proj_mode=1;
66
67 fog_mode=0;
68 fog_r=0.0,fog_g=0.0,fog_b=0.0;
69 fog_range_near=1.0,fog_range_far=1000.0;
70
71 project_enabled=false;
72
73 }
74
75 Camera* CopyEntity(Entity* parent_ent);
76 void FreeEntity(void);
77
78 static Camera* CreateCamera(Entity* parent_ent=NULL);
79
80 void CameraViewport(int,int,int,int);
81 void CameraClsColor(float r,float g,float b);
82 void CameraClsMode(int color,int zbuffer);
83 void CameraRange(float Near,float Far);
84 void CameraZoom(float zoom_val);
85 void CameraProjMode(int mode=1);
86 void CameraFogMode(int mode);
87 void CameraFogColor(float r,float g,float b);
88 void CameraFogRange(float Near,float Far);
89
90 void CameraProject(float x,float y,float z);
91 static float ProjectedX();
92 static float ProjectedY();
93 static float ProjectedZ();
94
95 float EntityInView(Entity* ent);
96 void ExtractFrustum();
97 float EntityInFrustum(Entity* ent);
98
99 void Update();
100 void Render();
101
102 void UpdateSprite(Sprite& sprite);
103 void AddTransformedSpriteToSurface(Sprite& sprite,Surface* surf);
104
105 void RenderListAdd(Mesh* mesh);
106
107 void accPerspective(float fovy,float aspect,float zNear,float zFar,float pixdx,float pixdy,float eyedx,float eyedy,float focus);
108 void accFrustum(float left_,float right_,float bottom,float top,float zNear,float zFar,float pixdx,float pixdy,float eyedx,float eyedy,float focus);
109 void UpdateProjMatrix();
110
111 };
112
113 void UpdateEntityRender0(Entity* ent,Entity* cam=NULL);
114 void UpdateEntityRender(Entity* ent,Entity* cam=NULL);
115
116 #endif
117
CameraFogColor
void CameraFogColor(Camera *cam, float r, float g, float b)
Definition: functions.cpp:239
AddTransformedSpriteToSurface
void AddTransformedSpriteToSurface(Camera *obj, Sprite &sprite, Surface *surf)
Definition: methods.cpp:67
entity.h
Mesh
Definition: mesh.h:34
EntityInFrustum
float EntityInFrustum(Camera *obj, Entity *ent)
Definition: methods.cpp:51
CameraClsMode
void CameraClsMode(Camera *cam, int cls_depth, int cls_zbuffer)
Definition: functions.cpp:232
CameraProject
void CameraProject(Camera *cam, float x, float y, float z)
Definition: functions.cpp:267
CameraRange
void CameraRange(Camera *cam, float nnear, float nfar)
Definition: functions.cpp:281
Surface
Definition: surface.h:19
Camera::fog_range_near
float fog_range_near
Definition: camera.h:41
Camera::vy
int vy
Definition: camera.h:30
ProjectedY
float ProjectedY()
Definition: functions.cpp:1285
CameraZoom
void CameraZoom(Camera *cam, float zoom)
Definition: functions.cpp:295
Camera::range_near
float range_near
Definition: camera.h:34
Camera::zoom
float zoom
Definition: camera.h:35
Camera::cam_list
static list< Camera * > cam_list
Definition: camera.h:27
CopyEntity
Entity * CopyEntity(Entity *ent, Entity *parent)
Definition: functions.cpp:421
mesh.h
CameraViewport
void CameraViewport(Camera *cam, int x, int y, int width, int height)
Definition: functions.cpp:288
std
accFrustum
void accFrustum(Camera *obj, float left_, float right_, float bottom, float top, float zNear, float zFar, float pixdx, float pixdy, float eyedx, float eyedy, float focus)
Definition: methods.cpp:79
ProjectedZ
float ProjectedZ()
Definition: functions.cpp:1292
global.h
Camera
Definition: camera.h:23
Camera::project_enabled
int project_enabled
Definition: camera.h:44
CameraFogRange
void CameraFogRange(Camera *cam, float nnear, float nfar)
Definition: functions.cpp:253
Camera::cls_r
float cls_r
Definition: camera.h:31
FreeEntity
void FreeEntity(Entity *ent)
Definition: functions.cpp:882
RenderListAdd
void RenderListAdd(Camera *obj, Mesh *mesh)
Definition: methods.cpp:71
Sprite
Definition: sprite.h:18
UpdateEntityRender
void UpdateEntityRender(Entity *ent, Entity *cam=NULL)
Definition: camera.cpp:625
Entity
Definition: entity.h:27
Camera::projected_z
static float projected_z
Definition: camera.h:50
UpdateEntityRender0
void UpdateEntityRender0(Entity *ent, Entity *cam=NULL)
Camera::Camera
Camera()
Definition: camera.h:54
Camera::fog_mode
int fog_mode
Definition: camera.h:39
Camera::fog_r
float fog_r
Definition: camera.h:40
Camera::proj_mode
int proj_mode
Definition: camera.h:37
Camera::cls_zbuffer
bool cls_zbuffer
Definition: camera.h:32
CameraProjMode
void CameraProjMode(Camera *cam, int mode)
Definition: functions.cpp:274
CameraFogMode
void CameraFogMode(Camera *cam, int mode)
Definition: functions.cpp:246
Camera::projected_y
static float projected_y
Definition: camera.h:49
ProjectedX
float ProjectedX()
Definition: functions.cpp:1278
load3ds::mesh
Mesh * mesh
Definition: 3ds.cpp:46
accPerspective
void accPerspective(Camera *obj, float fovy, float aspect, float zNear, float zFar, float pixdx, float pixdy, float eyedx, float eyedy, float focus)
Definition: methods.cpp:75
ExtractFrustum
void ExtractFrustum(Camera *obj)
Definition: methods.cpp:47
CreateCamera
Camera * CreateCamera(Entity *parent)
Definition: functions.cpp:471
sprite.h
Camera::render_list
static list< Mesh * > render_list
Definition: camera.h:28
Camera::projected_x
static float projected_x
Definition: camera.h:48
UpdateSprite
void UpdateSprite(Camera *obj, Sprite &sprite)
Definition: methods.cpp:63
CameraClsColor
void CameraClsColor(Camera *cam, float r, float g, float b)
Definition: functions.cpp:225
EntityInView
int EntityInView(Entity *ent, Camera *cam)
Definition: functions.cpp:699
NULL
#define NULL
Definition: tree.cpp:4
UpdateProjMatrix
void UpdateProjMatrix(Camera *obj)
Definition: methods.cpp:83