00001
00002
00003 #ifndef _OBJECT_H_
00004 #define _OBJECT_H_
00005
00006 #include <GL/gl.h>
00007 #include <map>
00008 #include <vector>
00009
00010 using std::map;
00011 using std::vector;
00012
00013 namespace MeshNS {
00014
00018 struct SimpleVertex {
00019
00020 SimpleVertex() {
00021 xyzw[0]= 0;
00022 xyzw[1]= 0;
00023 xyzw[2]= 0;
00024 xyzw[3]= 1;
00025 }
00026 SimpleVertex(float _x, float _y, float _z) {
00027 xyzw[0]= _x;
00028 xyzw[1]= _y;
00029 xyzw[2]= _z;
00030 xyzw[3]= 1;
00031 }
00032
00033 float x() const {
00034 return xyzw[0];
00035 }
00036 float y() const {
00037 return xyzw[1];
00038 }
00039 float z() const {
00040 return xyzw[2];
00041 }
00042
00043 float& operator[](int index) {
00044 return xyzw[index];
00045 }
00046 float operator[](int index) const {
00047 return xyzw[index];
00048 }
00049 float xyzw[4];
00050 };
00051
00055 struct SimpleFace {
00056 SimpleFace(int num_vert) :
00057 num_elems(num_vert) {
00058 }
00059
00060 SimpleFace() {
00061 }
00062
00063 int operator[](unsigned int which) const {
00064 return vert_indices[which];
00065 }
00066
00067 int& operator[](unsigned int which) {
00068 return vert_indices[which];
00069 }
00070
00071 unsigned int size() const {
00072 return vert_indices.size();
00073 }
00074
00075 void push_back(int face) {
00076 vert_indices.push_back(face);
00077 }
00078
00079 vector<int> vert_indices;
00080 int num_elems;
00081 };
00082
00083 typedef std::vector<SimpleVertex> SimpleVertices;
00084 typedef std::vector<SimpleFace> SimpleFaces;
00085
00090 class SimpleMesh {
00091
00092 public:
00093
00094 SimpleMesh() {
00095 }
00096
00097 int num_verts;
00098 int num_faces;
00099 vector<SimpleVertex> vertices;
00100 vector<SimpleFace> faces;
00101 };
00102
00103 }
00104
00105 #endif