00001 // vertexlist.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 _CELENGINE_VERTEXLIST_H_ 00011 #define _CELENGINE_VERTEXLIST_H_ 00012 00013 #include <celutil/basictypes.h> 00014 #include <celutil/color.h> 00015 #include <celutil/reshandle.h> 00016 #include <celmath/vecmath.h> 00017 #include <celmath/aabox.h> 00018 #include <celmath/ray.h> 00019 00020 00021 class VertexList 00022 { 00023 public: 00024 enum { 00025 VertexNormal = 0x01, 00026 VertexColor = 0x02, 00027 VertexColor0 = 0x02, 00028 VertexColor1 = 0x04, 00029 TexCoord0 = 0x08, 00030 TexCoord1 = 0x10, 00031 }; 00032 00033 class Vertex 00034 { 00035 public: 00036 Point3f point; 00037 Vec3f normal; 00038 Color color; 00039 Point2f texCoords[2]; 00040 }; 00041 00042 union VertexPart 00043 { 00044 float f; 00045 unsigned char c[4]; 00046 }; 00047 00048 public: 00049 VertexList(uint32 _parts, uint32 initialVertexPoolSize = 0); 00050 ~VertexList(); 00051 00052 void addVertex(const Vertex& v); 00053 00054 Color getDiffuseColor() const; 00055 void setDiffuseColor(Color); 00056 Color getSpecularColor() const; 00057 void setSpecularColor(Color); 00058 float getShininess() const; 00059 void setShininess(float); 00060 ResourceHandle getTexture() const; 00061 void setTexture(ResourceHandle); 00062 00063 void render(); 00064 bool pick(const Ray3d& ray, double& distance); 00065 00066 AxisAlignedBox getBoundingBox() const; 00067 void transform(Vec3f translation, float scale); 00068 00069 uint32 getVertexParts() const; 00070 void* getVertexData() const; 00071 uint32 getVertexCount() const; 00072 00073 private: 00074 uint32 parts; 00075 uint32 vertexSize; 00076 00077 uint32 nVertices; 00078 uint32 maxVertices; 00079 VertexPart* vertices; 00080 00081 Color diffuseColor; 00082 Color specularColor; 00083 float shininess; 00084 ResourceHandle texture; 00085 00086 AxisAlignedBox bbox; 00087 }; 00088 00089 #endif // _CELENGINE_VERTEXLIST_H_
1.4.1