00001 /* COPYRIGHT 00002 * 00003 * This file is part of the Simple Object Loader and Renderer - SOLAR 00004 * 00005 * Read the file "SOLAR-LICENSE" for the license. 00006 * 00007 * Authors & Copyright: 00008 * 00009 * Tommi Ilmonen, 2001-2003, except LWO-code by RJ, 2001-2003 00010 * 00011 * Tommi's email: firstname.lastname@hut.fi 00012 * 00013 */ 00014 00015 #ifndef SOLAR_GRAPHIC_TRIANGLES_STRIPS_HPP 00016 #define SOLAR_GRAPHIC_TRIANGLES_STRIPS_HPP 00017 00018 #include <Fluid/Vector2.hpp> 00019 00020 #include <Solar/BoundingBox.hpp> 00021 #include <Solar/Graphic.hpp> 00022 00023 #include <vector> 00024 00025 namespace Solar { 00026 00047 class GraphicTriangleStrips : public Graphic 00048 { 00049 public: 00050 class Vertex { 00051 public: 00052 00053 Fluid::Vector3 m_location; 00054 Fluid::Vector3 m_normal; 00055 Fluid::Vector2 m_uv; 00056 00057 void clear() { m_location.clear(); m_normal.clear(); m_uv.clear(); } 00058 }; 00059 00060 class Strip { 00061 public: 00062 uint m_begin; 00064 uint m_length; 00065 }; 00066 00067 00068 GraphicTriangleStrips(); 00069 virtual ~GraphicTriangleStrips(); 00070 00071 virtual Type type() const; 00073 virtual void getBoundingBox(BoundingBox *bbox); 00074 virtual int nofPrimitives() const; 00075 00076 virtual void render(Renderer *); 00077 virtual void scale(const Fluid::Vector3 &); 00078 virtual void move(const Fluid::Vector3 &); 00079 virtual void transform(const Fluid::Matrix3 &); 00080 00081 virtual void write(std::ostream *); 00082 00083 void addVertex(const Vertex &v); 00084 void addVertex(const Fluid::Vector3 & location, 00085 const Fluid::Vector3 & normal, 00086 const Fluid::Vector2 & uv) 00087 { 00088 Vertex v; 00089 v.m_location = location; 00090 v.m_normal = normal; 00091 v.m_uv = uv; 00092 addVertex(v); 00093 } 00094 00095 unsigned nofVertices() const { return m_vertices.size(); } 00096 00097 Vertex & vertex(unsigned n) { return m_vertices[n]; } 00098 const Vertex & vertex(unsigned n) const { return m_vertices[n]; } 00099 00100 Vertex & vertex(unsigned strip, unsigned vertex) 00101 { return m_vertices[m_strips[strip].m_begin + vertex]; } 00102 00103 unsigned nofStrips() const { return m_strips.size(); } 00104 Strip & strip(unsigned n) { return m_strips[n]; } 00105 00106 void finalizeStrip(); 00107 00108 void clear(); 00109 00110 protected: 00111 00112 std::vector<Vertex> m_vertices; 00113 std::vector<Strip> m_strips; 00114 00115 BoundingBox m_boundingBox; 00116 00117 }; 00118 00119 } // namespace Solar 00120 00121 #endif