Go to the documentation of this file.00001
00002 #ifndef __TRACKER_MODEL_H__
00003 #define __TRACKER_MODEL_H__
00004
00005 namespace Tracking{
00006 class TrackerModel;
00007 }
00008 #include <blort/Tracker/headers.h>
00009 #include <blort/TomGine/tgModel.h>
00010 #include <blort/Tracker/Texture.h>
00011 #include <blort/Tracker/Shader.h>
00012 #include <blort/TomGine/tgMathlib.h>
00013 #include <blort/TomGine/tgPose.h>
00014 #include <blort/TomGine/tgCamera.h>
00015 #include <boost/utility.hpp>
00016
00017 #ifndef FN_LEN
00018 #define FN_LEN 256
00019 #endif
00020
00021 namespace Tracking{
00022
00023
00025 class TrackerModel : public TomGine::tgModel
00026 {
00027 private:
00028 TrackerModel(const TrackerModel& m);
00029
00030 TrackerModel& operator=(const TomGine::tgModel& m);
00031
00032 public:
00033 TrackerModel();
00034 TrackerModel(const TomGine::tgModel& m);
00035 ~TrackerModel();
00036
00037 TrackerModel& operator=(const TrackerModel& m);
00038
00039 void releasePassList();
00040
00041 struct Pass : public boost::noncopyable {
00042 std::vector<unsigned> f;
00043 mat4 modelviewprojection;
00044 float x,y,w,h;
00045 Texture* texture;
00046 Pass(){ texture = new(Texture); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); }
00047 ~Pass(){ delete(texture);}
00048 };
00049
00050 typedef std::vector<Pass*> PassList;
00051
00052
00053 PassList m_passlist;
00054 std::vector<int> m_facepixellist;
00055
00056 Texture* m_tex_original;
00057 Texture* m_texture;
00058 bool m_textured;
00059
00060
00061 void computeEdges();
00062 void computeBoundingSphere();
00063 void Update();
00064
00065
00066 virtual void Print() const;
00067 virtual void drawNormals();
00068 virtual void drawFaces(bool colorful=false);
00069 void drawFace(int i);
00070 void drawEdges();
00071 void drawTexturedFaces();
00072 void drawUntexturedFaces();
00073 void drawPass(bool colorful=false);
00074 void drawCoordinates();
00075
00076
00077 std::vector<unsigned> getFaceUpdateList(TomGine::tgPose& p_max, vec3 view, float minTexGrabAngle=3.0*PI/4.0, bool use_num_pixels=true);
00078
00079 void getBoundingBox2D( int width, int height, TomGine::tgPose& p_max, TomGine::tgCamera* m_cam,
00080 int &minX, int &maxX, int &minY, int &maxY );
00081
00083 void textureFromImage( Texture* image,
00084 int width, int height,
00085 TomGine::tgPose& p_max,
00086 vec3 view,
00087 float minTexGrabAngle,
00088 std::vector<unsigned> faceUpdateList,
00089 std::vector<TomGine::tgVertex> &vertices,
00090 TomGine::tgCamera* m_cam);
00091
00092 void useTexCoords(bool useTC);
00093 void unwarpTexturesBox_hacky(const char* name);
00094
00095
00096 bool getTextured(){ return m_textured; }
00097 Texture* getTexture(){ return m_texture; }
00098 Texture* getOriginalTexture(){ return m_tex_original; }
00099 float getBoundingSphereRadius(){ return m_boundingSphereRadius; }
00100
00101
00102 void setBFC(bool bfc){ m_bfc = bfc; }
00103 void setTexture(Texture* tex){ m_texture = tex; }
00104 void setOriginalTexture(Texture* tex){ m_tex_original = tex; }
00105 void restoreTexture(){ m_texture=m_tex_original; }
00106
00107
00108 void genListTexturedFaces();
00109 void genListUntexturedFaces();
00110 void genListPass(bool colorful=false);
00111 void genListFaces(bool colorful=false);
00112 void genListEdges();
00113 void genListNormals(float normal_length);
00114
00115 protected:
00116 GLint m_dlTexturedFaces;
00117 GLint m_dlUntexturedFaces;
00118 GLint m_dlPass;
00119 GLint m_dlFaces;
00120 GLint m_dlEdges;
00121 GLint m_dlNormals;
00122
00123 Shader* m_shadeTexturing;
00124 int m_shadeTexturingID;
00125 bool m_bfc;
00126 float m_boundingSphereRadius;
00127
00128
00129 bool isRedundant(TomGine::tgLine* e1);
00130 void UpdateDisplayLists();
00131 };
00132
00133 }
00134
00135 #endif