forked from jackyblf/SolarSystem-openGL-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglcamera.h
More file actions
40 lines (32 loc) · 667 Bytes
/
glcamera.h
File metadata and controls
40 lines (32 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef CAMERA_H
#define CAMERA_H
#include "base.h"
struct glCamera
{
vec3 pos;//ÉãÏñ»úµÄÊÀ½ç¿Õ¼ä×ø±ê
float viewMatrix[16];
vec3 forward;
vec3 right;
vec3 up;
public :
glCamera( vec3 at)
{
pos=at;
}
void getViewMatrix()
{
glMatrixMode(GL_MODELVIEW);
glGetFloatv(GL_MODELVIEW_MATRIX,viewMatrix);
}
void update()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-pos.x,-pos.y,-pos.z);
getViewMatrix();
right=vec3(viewMatrix[0],viewMatrix[4],viewMatrix[8]);
up=vec3(viewMatrix[1],viewMatrix[5],viewMatrix[9]);
forward=vec3(viewMatrix[2],viewMatrix[6],viewMatrix[10]);
}
};
#endif