diff options
Diffstat (limited to 'matchblox/engine/typedefs.h')
-rw-r--r-- | matchblox/engine/typedefs.h | 322 |
1 files changed, 162 insertions, 160 deletions
diff --git a/matchblox/engine/typedefs.h b/matchblox/engine/typedefs.h index 3821bc6..a7b0b49 100644 --- a/matchblox/engine/typedefs.h +++ b/matchblox/engine/typedefs.h @@ -1,157 +1,158 @@ -#ifndef TYPEDEFS_H - -#define TYPEDEFS_H - -#include <wiimote.h> -#include <vector> +#ifndef TYPEDEFS_H
+
+#define TYPEDEFS_H
+
+//#include <wiimote.h>
+#include <wiiuse.h>
+#include <vector>
#include <limits>
- -#undef max - -typedef struct vec3d -{ - double x, y, z; - - //constructors - vec3d() - { x=0.0, y=0.0, z=0.0; } - vec3d(double fx, double fy, double fz) - { x=fx, y=fy, z=fz; } - vec3d(const vec3d &clone) - { x=clone.x; y=clone.y; z=clone.z; } - - inline vec3d& operator=(const vec3d &rhs) - { x=rhs.x; y=rhs.y; z=rhs.z; return *this; } - inline vec3d& operator+=(const vec3d &rhs) - { x+=rhs.x; y+=rhs.y; z+=rhs.z; return *this; } - inline vec3d& operator-=(const vec3d &rhs) - { x-=rhs.x; y-=rhs.y; z-=rhs.z; return *this; } - inline vec3d& operator*=(const vec3d &rhs) - { x*=rhs.x; y*=rhs.y; z*=rhs.z; return *this; } - inline vec3d& operator*=(const double &scal) - { x*=scal; y*=scal; z*=scal; return *this; } - - inline const vec3d& operator+(const vec3d &rhs) const - { return vec3d(*this) += rhs; } - inline const vec3d& operator-(const vec3d &rhs) const - { return vec3d(*this) -= rhs; } - inline const vec3d& operator*(const vec3d &rhs) const - { return vec3d(*this) *= rhs; } - inline const vec3d& operator*(const double &scal) const - { return vec3d(*this) *= scal; } -} Vect3D_t; - -typedef struct bb -{ - Vect3D_t m_Min, //minimal corner vertex (-x, -y, -z) - m_Max; //maximal corner vertex (+x, +y, +z) - - //default constructor creates a maximum inverted bounding box - bb() - { - //init a bounding box with the min values set to max double and visa versa - double l_doubleMax = std::numeric_limits<double>::max(); - m_Min = Vect3D_t(l_doubleMax, l_doubleMax, l_doubleMax); - m_Max = Vect3D_t(-l_doubleMax, -l_doubleMax, -l_doubleMax); - } - - //copy constructor - bb(const bb &b) : m_Min(b.m_Min), m_Max(b.m_Max) {} - - //translating a bounding box - inline bb& operator+=(const Vect3D_t &v) - { m_Min += v; m_Max += v; return *this; } - inline const bb& operator+(const Vect3D_t &v) const - { return (bb(*this) += v); } - - //update the bounding box min/max coords with vertex v - inline bb& operator<<(const Vect3D_t &v) - { - if (v.x < m_Min.x) m_Min.x = v.x; - else if (v.x > m_Max.x) m_Max.x = v.x; - if (v.y < m_Min.y) m_Min.y = v.y; - else if (v.y > m_Max.y) m_Max.y = v.y; - if (v.z < m_Min.z) m_Min.z = v.z; - else if (v.z > m_Max.z) m_Max.z = v.z; - return *this; - } - - inline bool Contains(const Vect3D_t &v) const - { - //check if the point is contained in the box - return m_Min.x < v.x && v.x < m_Max.x && - m_Min.y < v.y && v.y < m_Max.y && - m_Min.z < v.z && v.z < m_Max.z; - } - - inline bool Contains(const bb& b) const - { - return Contains(b.m_Min) && Contains(b.m_Max); - } - - inline bool Overlap(const bb& rhs) const - { - //check if the boxes overlap in all three axis - return ( ( m_Min.x < rhs.m_Min.x && rhs.m_Min.x < rhs.m_Max.x) || - ( m_Min.x < rhs.m_Max.x && rhs.m_Max.x < rhs.m_Max.x) ) && - ( ( m_Min.y < rhs.m_Min.y && rhs.m_Min.y < rhs.m_Max.y) || - ( m_Min.y < rhs.m_Max.y && rhs.m_Max.y < rhs.m_Max.y) ) && - ( ( m_Min.z < rhs.m_Min.z && rhs.m_Min.z < rhs.m_Max.z) || - ( m_Min.z < rhs.m_Max.z && rhs.m_Max.z < rhs.m_Max.z) ); - } - -} BoundingBox_t; - - -typedef struct triangle -{ - int v1, n1, t1, - v2, n2, t2, - v3, n3, t3; -} Triangle_t; - -typedef struct mat -{ - GLfloat m_fAmb[4], - m_fDif[4], - m_fSpec[4], - m_fEmi[4], - m_fShin; - - //default constructor - mat() - { - m_fAmb[0] = m_fAmb[1] = m_fAmb[2] = 0.7f; m_fAmb[3] = 1.0f; - m_fDif[0] = m_fDif[1] = m_fDif[3] = 0.7f; m_fDif[3] = 1.0f; - m_fSpec[0] = m_fSpec[1] = m_fSpec[2] = m_fSpec[3] = 1.0f; - m_fEmi[0] = m_fEmi[1] = m_fEmi[2] = 0.0f; m_fEmi[3] = 1.0f; - m_fShin = 128.0f; - } - //for convenience - inline void setAmb(float r, float g, float b, float a) - { m_fAmb[0] = r; m_fAmb[1] = g; m_fAmb[2] = b; m_fAmb[3] = a; } - inline void setDif(float r, float g, float b, float a) - { m_fDif[0] = r; m_fDif[1] = g; m_fDif[2] = b; m_fDif[3] = a; } - inline void setSpec(float r, float g, float b, float a) - { m_fSpec[0] = r; m_fSpec[1] = g; m_fSpec[2] = b; m_fSpec[3] = a; } - inline void setEmi(float r, float g, float b, float a) - { m_fEmi[0] = r; m_fEmi[1] = g; m_fEmi[2] = b; m_fEmi[3] = a; } - -} MatProps_t; -/* -typedef struct facegroup -{ - MatProps_t m_material; - std::vector<Face_t> m_faces; -} FaceGroup_t; -*/ - -typedef struct geom -{ - std::vector<Vect3D_t> m_verts, - m_norms, - m_texs; - std::vector<Triangle_t> m_triangles; +
+#undef max
+
+typedef struct vec3d
+{
+ double x, y, z;
+
+ //constructors
+ vec3d()
+ { x=0.0, y=0.0, z=0.0; }
+ vec3d(double fx, double fy, double fz)
+ { x=fx, y=fy, z=fz; }
+ vec3d(const vec3d &clone)
+ { x=clone.x; y=clone.y; z=clone.z; }
+
+ inline vec3d& operator=(const vec3d &rhs)
+ { x=rhs.x; y=rhs.y; z=rhs.z; return *this; }
+ inline vec3d& operator+=(const vec3d &rhs)
+ { x+=rhs.x; y+=rhs.y; z+=rhs.z; return *this; }
+ inline vec3d& operator-=(const vec3d &rhs)
+ { x-=rhs.x; y-=rhs.y; z-=rhs.z; return *this; }
+ inline vec3d& operator*=(const vec3d &rhs)
+ { x*=rhs.x; y*=rhs.y; z*=rhs.z; return *this; }
+ inline vec3d& operator*=(const double &scal)
+ { x*=scal; y*=scal; z*=scal; return *this; }
+
+ inline const vec3d& operator+(const vec3d &rhs) const
+ { return vec3d(*this) += rhs; }
+ inline const vec3d& operator-(const vec3d &rhs) const
+ { return vec3d(*this) -= rhs; }
+ inline const vec3d& operator*(const vec3d &rhs) const
+ { return vec3d(*this) *= rhs; }
+ inline const vec3d& operator*(const double &scal) const
+ { return vec3d(*this) *= scal; }
+} Vect3D_t;
+
+typedef struct bb
+{
+ Vect3D_t m_Min, //minimal corner vertex (-x, -y, -z)
+ m_Max; //maximal corner vertex (+x, +y, +z)
+
+ //default constructor creates a maximum inverted bounding box
+ bb()
+ {
+ //init a bounding box with the min values set to max double and visa versa
+ double l_doubleMax = std::numeric_limits<double>::max();
+ m_Min = Vect3D_t(l_doubleMax, l_doubleMax, l_doubleMax);
+ m_Max = Vect3D_t(-l_doubleMax, -l_doubleMax, -l_doubleMax);
+ }
+
+ //copy constructor
+ bb(const bb &b) : m_Min(b.m_Min), m_Max(b.m_Max) {}
+
+ //translating a bounding box
+ inline bb& operator+=(const Vect3D_t &v)
+ { m_Min += v; m_Max += v; return *this; }
+ inline const bb& operator+(const Vect3D_t &v) const
+ { return (bb(*this) += v); }
+
+ //update the bounding box min/max coords with vertex v
+ inline bb& operator<<(const Vect3D_t &v)
+ {
+ if (v.x < m_Min.x) m_Min.x = v.x;
+ else if (v.x > m_Max.x) m_Max.x = v.x;
+ if (v.y < m_Min.y) m_Min.y = v.y;
+ else if (v.y > m_Max.y) m_Max.y = v.y;
+ if (v.z < m_Min.z) m_Min.z = v.z;
+ else if (v.z > m_Max.z) m_Max.z = v.z;
+ return *this;
+ }
+
+ inline bool Contains(const Vect3D_t &v) const
+ {
+ //check if the point is contained in the box
+ return m_Min.x < v.x && v.x < m_Max.x &&
+ m_Min.y < v.y && v.y < m_Max.y &&
+ m_Min.z < v.z && v.z < m_Max.z;
+ }
+
+ inline bool Contains(const bb& b) const
+ {
+ return Contains(b.m_Min) && Contains(b.m_Max);
+ }
+
+ inline bool Overlap(const bb& rhs) const
+ {
+ //check if the boxes overlap in all three axis
+ return ( ( m_Min.x < rhs.m_Min.x && rhs.m_Min.x < rhs.m_Max.x) ||
+ ( m_Min.x < rhs.m_Max.x && rhs.m_Max.x < rhs.m_Max.x) ) &&
+ ( ( m_Min.y < rhs.m_Min.y && rhs.m_Min.y < rhs.m_Max.y) ||
+ ( m_Min.y < rhs.m_Max.y && rhs.m_Max.y < rhs.m_Max.y) ) &&
+ ( ( m_Min.z < rhs.m_Min.z && rhs.m_Min.z < rhs.m_Max.z) ||
+ ( m_Min.z < rhs.m_Max.z && rhs.m_Max.z < rhs.m_Max.z) );
+ }
+
+} BoundingBox_t;
+
+
+typedef struct triangle
+{
+ int v1, n1, t1,
+ v2, n2, t2,
+ v3, n3, t3;
+} Triangle_t;
+
+typedef struct mat
+{
+ GLfloat m_fAmb[4],
+ m_fDif[4],
+ m_fSpec[4],
+ m_fEmi[4],
+ m_fShin;
+
+ //default constructor
+ mat()
+ {
+ m_fAmb[0] = m_fAmb[1] = m_fAmb[2] = 0.7f; m_fAmb[3] = 1.0f;
+ m_fDif[0] = m_fDif[1] = m_fDif[3] = 0.7f; m_fDif[3] = 1.0f;
+ m_fSpec[0] = m_fSpec[1] = m_fSpec[2] = m_fSpec[3] = 1.0f;
+ m_fEmi[0] = m_fEmi[1] = m_fEmi[2] = 0.0f; m_fEmi[3] = 1.0f;
+ m_fShin = 128.0f;
+ }
+ //for convenience
+ inline void setAmb(float r, float g, float b, float a)
+ { m_fAmb[0] = r; m_fAmb[1] = g; m_fAmb[2] = b; m_fAmb[3] = a; }
+ inline void setDif(float r, float g, float b, float a)
+ { m_fDif[0] = r; m_fDif[1] = g; m_fDif[2] = b; m_fDif[3] = a; }
+ inline void setSpec(float r, float g, float b, float a)
+ { m_fSpec[0] = r; m_fSpec[1] = g; m_fSpec[2] = b; m_fSpec[3] = a; }
+ inline void setEmi(float r, float g, float b, float a)
+ { m_fEmi[0] = r; m_fEmi[1] = g; m_fEmi[2] = b; m_fEmi[3] = a; }
+
+} MatProps_t;
+/*
+typedef struct facegroup
+{
+ MatProps_t m_material;
+ std::vector<Face_t> m_faces;
+} FaceGroup_t;
+*/
+
+typedef struct geom
+{
+ std::vector<Vect3D_t> m_verts,
+ m_norms,
+ m_texs;
+ std::vector<Triangle_t> m_triangles;
} Geometry_t;
typedef struct FrustumParms
@@ -173,18 +174,19 @@ typedef enum EyeOrigin { STEREO_LEFT_EYE = 0,
STEREO_RIGHT_EYE = 1,
MONO_CENTER = 2
-} EyeOrigin_t; - +} EyeOrigin_t;
+
typedef struct GameState
{
FrustumParms_t m_FrustumParms;
bool m_bHeadTrackingEnabled;
bool m_bStereoEnabled;
- wiimote *m_pTrackingWiimote;
+ //wiimote *m_pTrackingWiimote;
+ wiimote **m_ppWiimotes;
GLuint m_GreyScaleShaderProgram; //handle to the grayscale shader program
GLint m_GSConvScaleLoc; //handle to the g_ConversionScale variable in the shader
GLfloat m_GSConvScale[3]; //grayscale conversion scale (default 0.299, 0.587, 0.114)
-} GameState_t; - -#endif //TYPEDEFS_H - +} GameState_t;
+
+#endif //TYPEDEFS_H
+
|