Krig Game Engine
Loading...
Searching...
No Matches
ModelGameObject.h
Go to the documentation of this file.
1
7#ifndef _MODEL_GAME_OBJECT_H_
8#define _MODEL_GAME_OBJECT_H_
9
10#include <GL/glut.h>
11#include <map>
12#include <string>
13
14#include "Object.h"
15
16class Terrain;
17
18struct Triangle {
19 GLuint vertices[3]; // index into model's vertex array
20 GLfloat colors[3][3]; // [vertex][rgb]
21};
22
23struct Edge {
24 int vertices[2];
25 int triangleIndex[2];
26};
27
29 Vector p1, p2;
30};
31
33 GLuint numVertices; // number of vertices in the model
34 GLuint numTriangles; // number of triangles in the model
35 GLfloat initalScale; // the scaleFactor that was used to scale the vertices
36 GLfloat** baseVertex; // list of base vertices ( not transformed )
37 Vector* normal; // list of normals that comprise the model
38 Triangle* triangle;
39
40 void load(char[]);
41};
42
43class ModelGameObject : public Object {
44 public:
45 ModelGameObject();
46 virtual ~ModelGameObject();
47 void load(std::string);
48 void unload(void);
49
50 // overridden virtual functions ////////////
51 virtual void draw(Object*) override;
52 virtual void drawOutline(Object*) override;
53 virtual void drawShadow (Vector*) override;
54
55 virtual void handleCollision(Object*) override;
56
57 virtual void update(Vector*) override;
58 virtual void animate(const float&, Object*) override;
59
60 virtual void orientOnTerrain(Terrain *temp, const Quaternion &baseRotation) override;
61 virtual void setHeightFromTerrain(Terrain *temp, const float &offset) override;
62
63 virtual void printTypeName() override {}
65
66 void buildEdges();
67
68 static std::map <std::string, ModelStorage*> modelHash;
69
70 protected:
71 std::string modelKey_;
72
73 // transformed data //
74 GLfloat *lightIntensity; // light intensity due to each normal, updated per cycle
75 GLfloat **updatedVertex; // list of vertices that comprise the model
76
77 // TODO: Determine if this data is included for shadows (which is not fully
78 // implemented).
79 int numEdges;
80 Edge *edges;
81
82 TransformedEdge *sEdge;
83 int numSEdge;
84};
85#endif
Base game object from which all concrete types are defined.
GameObject load()
Definition Quaternion.h:18
Definition Terrain.h:14
Definition ModelGameObject.h:23
Definition ModelGameObject.h:32
Definition ModelGameObject.h:28
Definition ModelGameObject.h:18
Definition Vector.h:15