-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctPlane.h
85 lines (77 loc) · 2.53 KB
/
ctPlane.h
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
#ifndef CTPLANE_H
#define CTPLANE_H
#include "ctObject.h"
#include <QVector3D>
#include <QMatrix4x4>
#include <QtGui/QOpenGLFunctions>
#include "ctShaderManager.h"
#include "ctTransform.h"
#include "ctTexture.h"
class ctPlane : public ctObject
{
public:
enum PlaneType
{
Colored,
Textured
};
private:
friend ctEntity* Clone();
QOpenGLShaderProgram * m_currentShader;
QVector3D m_AA;
QVector3D m_BB;
PlaneType m_currentType;
GLuint posAtribLoc;
GLuint colorAtribLoc;
GLuint textureLocation;
GLuint matrixUniform;
GLuint transformMatrixUniform;
GLuint materialUniform;
GLuint meshVBO;
unsigned short* planeIndexes;
ctTexture* m_texture;
int m_frame;
int m_rows;
int m_cols;
QVector2D m_offset;
QVector2D m_texCoords[4];
float planeTextureCoords[8];
void GettingAttributes(QOpenGLShaderProgram * t_shaderProgram);
protected:
virtual void SetDefault(ctShaderManager *, ctScene *, QOpenGLContext *);
virtual void ResizeMesh(QVector3D t_AA, QVector3D t_BB);
public:
//ctPlane(){}
//ctPlane(ShaderManager *t_shaderManager, QVector3D t_AA, QVector3D t_BB, PlaneType t_type);
explicit ctPlane(ctShaderManager *){}
ctPlane(ctShaderManager *, ctScene *){}
ctPlane(ctShaderManager *, ctScene *, QOpenGLContext *){}
ctPlane(ctShaderManager *, ctScene *, QOpenGLContext *, QVector3D t_AA, QVector3D t_BB, PlaneType t_type);
virtual ~ctPlane();
void InitShader();
void InitShader(QOpenGLShaderProgram * t_initedShader);
void InitShader(const char * t_shaderProgrammName);
void InitShader(QString t_shaderProgrammName);
void SetColor(QVector3D t_color);
void SetColor(QVector4D t_color);
void SetTexture(const char * t_textureFileName, bool t_needResize = false);
void SetTexture(QString t_textureFileName, bool t_needResize = false);
void SetTexture(ctTexture* t_texture);
ctTexture* GetTexture();
void Draw(QMatrix4x4);
void DrawTextured(QMatrix4x4);
void GenerateCompleteBuffer(QVector3D t_AA, QVector3D t_BB, bool t_selfGeneredTextureCoord = true);
//GLuint CreateTexture(const char *fileName, const char *fileFormat);
//----Overload-functions----
virtual void Update();
virtual void Draw();
virtual void Init();
virtual ctEntity* Clone();
//--------------------------
void SetTextureGrid(int t_rows, int t_cols);
void SetupTextureCoords();
void SetFrame(int t_frame);
int GetFrame();
void SetTextureOffset(QVector2D t_offset);
};
#endif // CTPLANE_H