Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

glmeshbuilder.h

Go to the documentation of this file.
00001 /*
00002     Sheep - A Rigid Body Dynamics Engine
00003     Copyright (C) 2001-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of Sheep.
00007 
00008     Sheep is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Sheep is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Sheep; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef SHEEP_RENDERER_GLMESHBUILDER_H
00024 #define SHEEP_RENDERER_GLMESHBUILDER_H
00025 
00026 #include "common/math/real.h"
00027 #include "common/math/vector2.h"
00028 #include "common/math/vector3.h"
00029 #include "common/meshio/imeshbuilder.h"
00030 #include "glmesh.h"
00031 
00032 #include <memory>   // std::auto_ptr<>
00033 #include <string>
00034 #include <vector>
00035 
00036 namespace sheep {
00037 
00038     class Material;
00039 
00040     class GLMeshBuilder :
00041         public IMeshBuilder,
00042         public IMeshBuilder::IGeometryBuilder,
00043         public IMeshBuilder::IMaterialBuilder
00044     {
00045     public:
00046         GLMeshBuilder();
00047         virtual ~GLMeshBuilder();
00048 
00049         // IMeshBuilder interface.
00050 
00051         typedef GLMesh MeshType;
00052 
00053         virtual IGeometryBuilder *GeometryBuilder();
00054         virtual IMaterialBuilder *MaterialBuilder();
00055 
00056         std::auto_ptr<GLMesh> GetMesh();
00057 
00058         // IGeometryBuilder interface.
00059 
00060         virtual void BeginSubMesh(const std::string &name);
00061         virtual void EndSubMesh();
00062 
00063         virtual FeatureId AppendVertex(const Vector3 &v);
00064         virtual FeatureId AppendNormal(const Vector3 &vn);
00065         virtual FeatureId AppendTexCoord(const Vector2 &vt);
00066         virtual FeatureId AppendFace(int n, const FeatureId *v);
00067 
00068         virtual void SetFaceNormals(FeatureId face, int n, const FeatureId *vn);
00069         virtual void SetFaceTexCoords(FeatureId face, int n, const FeatureId *vt);
00070 
00071         virtual void SetMaterial(FeatureId material);
00072 
00073         // IMaterialBuilder interface.
00074 
00075         virtual FeatureId BeginMaterial(const std::string &name);
00076         virtual void EndMaterial();
00077 
00078         virtual void SetAmbientColor(Real r, Real g, Real b);
00079         virtual void SetDiffuseColor(Real r, Real g, Real b);
00080         virtual void SetSpecularColor(Real r, Real g, Real b);
00081 
00082         virtual void SetTexture(int w, int h, const unsigned char *texels); //!< 24-bit RGB format.
00083 
00084     private:
00085         std::auto_ptr<GLMesh> m_mesh;
00086 
00087         std::vector<Material *> m_materials;
00088 
00089         GLMesh::SubMesh *m_submesh;     //!< Current sub mesh.
00090         Material *m_material;           //!< Current material.
00091     };
00092 
00093 }
00094 
00095 #endif  // !SHEEP_RENDERER_GLMESHBUILDER_H

Generated on Tue May 11 01:31:50 2004 for toxic by doxygen 1.3.6