00001 // vertexbuf.h 00002 // 00003 // Copyright (C) 2001, Chris Laurel 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 00010 #ifndef _VERTEXBUF_H_ 00011 #define _VERTEXBUF_H_ 00012 00013 #include <celutil/basictypes.h> 00014 #include <celutil/color.h> 00015 #include <celmath/vecmath.h> 00016 #include <celmath/aabox.h> 00017 00018 00019 class VertexBuffer 00020 { 00021 public: 00022 enum { 00023 VertexNormal = 0x01, 00024 VertexColor = 0x02, 00025 VertexColor0 = 0x02, 00026 VertexColor1 = 0x04, 00027 TexCoord0 = 0x08, 00028 TexCoord1 = 0x10, 00029 }; 00030 00031 class Vertex 00032 { 00033 public: 00034 Point3f point; 00035 Vec3f normal; 00036 Color color; 00037 Point2f texCoords[2]; 00038 }; 00039 00040 union VertexPart 00041 { 00042 float f; 00043 unsigned char c[4]; 00044 }; 00045 00046 public: 00047 VertexList(uint32 _parts, uint32 initialVertexPoolSize = 0); 00048 ~VertexList(); 00049 00050 void addVertex(const Vertex& v); 00051 00052 Color getDiffuseColor() const; 00053 void setDiffuseColor(Color); 00054 00055 void render(); 00056 00057 AxisAlignedBox getBoundingBox() const; 00058 void transform(Vec3f translation, float scale); 00059 00060 private: 00061 uint32 parts; 00062 uint32 vertexSize; 00063 00064 uint32 nVertices; 00065 uint32 maxVertices; 00066 VertexPart* vertices; 00067 00068 Color diffuseColor; 00069 00070 AxisAlignedBox bbox; 00071 }; 00072 00073 #endif // _VERTEXBUF_H_
1.4.1