-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawableObject.hpp
89 lines (81 loc) · 1.97 KB
/
DrawableObject.hpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "cs314Interfaces.h"
#include "VertexArray.hpp"
#include "akj_ogl.h"
class cPlayer;
class cLightManager;
class cDrawableObject: public iDrawable
{
public:
enum eObjectState{
DRAWABLE_DEFAULT,
DRAWABLE_INVISIBLE
};
typedef std::vector<const akj::cGLTexture*> tTextureList;
cDrawableObject(const akj::cVertexArray& mesh,
const akj::cGLShader& shader,
const tTextureList& textures,
const akj::cGLArrayBuffer& vbo,
int vbo_index);
~cDrawableObject(void);
virtual void Draw();
void TransformModelView();
cUnitQuat Orientation();
cCoord3 Position(){
return mPosition;
}
void SetVisibility(bool is_visible){
mIsVisible = is_visible;
}
void SetPlayer(const cPlayer* player){
mPlayer = player;
}
void SetLights(cLightManager* lighting){
mLightManager = lighting;
}
void SetDepthFunction(const GLuint val){
mDepthFunction = val;
}
const akj::cGLShader& GetShader() const {
return mShader;
}
cCoord3 GetPosition() const{
return mPosition;
}
void SetOrientation(cUnitQuat rot){
mOrientation = rot;
}
void FaceTowards(cCoord3 point){
cCoord3 vec = mPosition - point;
mOrientation = cUnitQuat(cCoord3::ZAxis(),-vec);
}
void RotateToFace(float rotation_radians){
mOrientation *= cUnitQuat(cAngleAxis(rotation_radians, cCoord3::YAxis()));
}
void SetOrientation(cCoord3 direction){
mOrientation = cUnitQuat(cCoord3::YAxis(), direction);
}
void MultiplyOrientation(cUnitQuat q){
mOrientation *= q;
}
void SetPosition(const cCoord3& pos){
mPosition = pos;
}
void SetScale(const cCoord3& scale){
mScale = scale;
}
private:
cCoord3 mPosition;
cUnitQuat mOrientation;
cCoord3 mScale;
const cPlayer* mPlayer;
const cLightManager* mLightManager;
const akj::cVertexArray& mMesh;
const akj::cGLShader& mShader;
GLuint mDepthFunction;
const GLuint DepthFunction() const { return mDepthFunction; }
const akj::cGLArrayBuffer& mVBO;
int mStartingVBOIndex;
tTextureList mTextures;
bool mIsVisible;
};