00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEE_GL_RENDERER_H
00021 #define GEE_GL_RENDERER_H
00022
00023 #include <gee_renderer.h>
00024
00025 #include <gee_gl_light.h>
00026
00027 #include <GL/gl.h>
00028 #include <GL/glu.h>
00029
00030 #include <vector>
00031
00032 class GEE_Geometry;
00033 class GEE_GlDisplayLists;
00034 class GEE_GlMaterial;
00035 class GEE_GlMaterialBank;
00036 class GEE_Material;
00037
00038 class VEE_GlRenderer;
00039 class VEE_GlTexture2DBank;
00040
00057 class GEE_GlRenderer : public GEE_Renderer
00058 {
00059 public:
00060 GEE_GlRenderer();
00061 virtual ~GEE_GlRenderer();
00062
00063 virtual void renderGroupStructure(GEE_Group *);
00064 virtual void renderLines3D(GEE_Lines3D *);
00065 virtual void renderPath3D(GEE_Path3D *);
00066 virtual void renderParticleObject(GEE_ParticleObject *);
00067 virtual void renderPolygonMesh(GEE_PolygonMesh *);
00068 virtual void renderProfile(GEE_Profile *);
00069 virtual void renderSphere(GEE_Sphere *);
00070 virtual void renderTriangleMesh(GEE_TriangleMesh *);
00071 virtual void renderVeeObject(VEE_Object *,
00072 const VEE_Matrix4 * m = 0,
00073 float scale = 0.0f);
00074
00075 virtual void pushTransform(const VEE_Matrix4d &);
00076 virtual void pushTransform(const VEE_Matrix4 &);
00077 virtual void popTransform();
00078 virtual void enableTransforms(bool enable);
00079 virtual bool enableTransforms();
00080
00081 void setDisplayLists(GEE_GlDisplayLists * lists) { m_displayLists = lists; }
00082 void setHighlightDisplayLists(GEE_GlDisplayLists * lists)
00083 { m_highlightDisplayLists = lists; }
00084 void setMaterials(GEE_GlMaterialBank *materials) { m_materials = materials; }
00085 void setTextures(VEE_GlTexture2DBank *textures) { m_textures = textures; }
00086
00087 void addLights(const GEE_GlLights & lights);
00088 void loadLights(const char * nameBase = "lights-%d", int maximum = 100);
00089 uint lightCount() const { return m_lights.size(); }
00090 GEE_GlLights & light(int i) { return m_lights[i]; }
00091 void selectLights(uint i)
00092 { if(i < m_lights.size()) m_currentLight = & m_lights[i]; }
00093 void clearLights();
00094
00095 virtual void initGlState();
00096 virtual void closeGlState();
00097
00098 void applyGlTexture2D(GLuint tex);
00099 void applyGlBlend(bool blend);
00100 void applyGlLighting(bool lighting);
00101 void applyGlSmooth(bool smooth);
00102 void applyGlTwoSided(bool twoSided);
00103
00104 void applyMaterial(GEE_Material *);
00105
00106 void setShowroupSructure(bool show) { m_showGroups = show; }
00107
00109 long renderCount() const { return m_renderCount; }
00111 long renderDisplayListCount() const { return m_renderDisplayListCount; }
00112 long generateDisplayListCount() const { return m_generateDisplayListCount; }
00113
00114 void setVeeRenderer(VEE_GlRenderer *r) { m_veeRenderer = r; }
00115
00116 long vertexCount() const { return m_vertexCount; }
00117 long triangleCount() const { return m_triangleCount; }
00118 long polygonCount() const { return m_polygonCount; }
00119 long particleCount() const { return m_particleCount; }
00120 long geometryCount() const { return m_geometryCount; }
00121
00122 void resetCounters();
00123
00124 static void setDebug(bool d) { m_debug = d; }
00125
00126 protected:
00127
00128 enum ListMode {
00129 RENDERED_LIST,
00130 GENERATE_LIST,
00131 NO_LIST
00132 };
00133
00139 enum SelectionRender {
00140 RENDER_USUAL,
00141 RENDER_FACES_NS_HIGH1,
00142 RENDER_FACES_IS_HIGH1,
00143
00144 RENDER_EDGES_NS_HIGH1,
00145 RENDER_EDGES_IS_HIGH1,
00146 RENDER_EDGES_NS_HIGH2,
00147 RENDER_EDGES_IS_HIGH2,
00148
00149 RENDER_POINTS_NS_HIGH2,
00150 RENDER_POINTS_IS_HIGH2
00151 };
00152
00153 void renderLines3DInternal(GEE_Lines3D *);
00154 void renderTriangleMeshInternal(GEE_TriangleMesh *);
00155
00156 virtual void preRender(GEE_Geometry *);
00157 ListMode renderDisplayList(GEE_Geometry *);
00158
00159 void enterVee();
00160 void exitVee();
00161
00162 GEE_GlDisplayLists *m_displayLists;
00163 GEE_GlDisplayLists *m_highlightDisplayLists;
00164 GEE_GlMaterialBank *m_materials;
00165 const GEE_Material *m_currentMaterial;
00166 std::vector<GEE_GlLights> m_lights;
00167 GEE_GlLights *m_currentLight;
00168
00169 VEE_GlRenderer *m_veeRenderer;
00170 VEE_GlTexture2DBank *m_textures;
00171
00172 GLuint m_currentTexture;
00173 bool m_blend;
00174 bool m_lighting;
00175 bool m_smooth;
00176 bool m_twoSided;
00177 bool m_inVee;
00178 bool m_ignoreTransforms;
00179
00180 bool m_showGroups;
00181
00182 long m_renderCount;
00183 long m_renderDisplayListCount;
00184 long m_generateDisplayListCount;
00185
00186 long m_vertexCount;
00187 long m_triangleCount;
00188 long m_polygonCount;
00189 long m_particleCount;
00190 long m_geometryCount;
00191
00192
00193 SelectionRender m_selectionRender;
00194
00195
00196
00197
00198 VEE_Matrix4 m_worldMatrix;
00199
00200 GLUquadric * m_quadric;
00201
00202 static bool m_debug;
00203 };
00204
00205 #endif