struct TriMeshFace
{
TriMeshFace() {}
TriMeshFace(DWORD I0, DWORD I1, DWORD I2)
{
I[0] = I0;
I[1] = I1;
I[2] = I2;
}
DWORD I[3];
};
class BaseMesh
{
public:
BaseMesh();
virtual void Allocate(UINT NewVertexCount, UINT NewFaceCount) = 0;
virtual void FreeMemory() = 0;
void CopyMesh(BaseMesh &Copy) const;
BaseMesh& operator = (const BaseMesh &O);
virtual void operator += (const BaseMesh &O);
virtual void AppendVertices(const BaseMesh &O);
virtual void LoadMeshList(const Vector<BaseMesh *> &Meshes);
virtual void LoadMeshList(const Vector< pair<const BaseMesh *, Matrix4> > &Meshes);
virtual UINT IndexCount() const = 0;
virtual UINT VertexCount() const = 0;
virtual UINT FaceCount() const = 0;
virtual MeshVertex* Vertices() = 0;
virtual DWORD* Indices() = 0;
virtual const MeshVertex* Vertices() const = 0;
virtual const DWORD* Indices() const = 0;
GraphicsDevice& GetGD() const;
void SetGD(GraphicsDevice &GD);
Vec3f EvaluateBarycentricPos(UINT FaceIndex, float u, float v) const;
void SetColor(RGBColor C); void SetAlpha(BYTE Alpha); void RandomizeColors(); void ColorNormals(); void ColorNormals(float fr, float fg, float fb); void ColorNormals(RGBColor Color);
void ColorNormalsGrayScale(RGBColor Color);
void TextureSphericalMap(int variable); void TextureMapToNormals(int variable);
void CreateSphere(float radius, int refinement); void CreateSphere(float radius, int slices, int stacks);
void CreateBox(float w, float h, float d, int refinement = 0); void CreateBox(const Rectangle3f &Rect);
void CreateTriangle(const Vec3f &v0, const Vec3f &v1, const Vec3f &v2, RGBColor color);
void CreateTeapot(float radius);
void CreateCylinder(float radius, float height, UINT slices, UINT stacks); void CreateCylinder(float radius, const Vec3f &pt1, const Vec3f &pt2, UINT slices, UINT stacks); void CreateClosedCylinder(float radius, const Vec3f &pt1, const Vec3f &pt2, UINT slices, UINT stacks); void ReCreateCylinder(float radius, const Vec3f &pt1, const Vec3f &pt2, UINT slices, UINT stacks); void CreateCylinder(Vec3f (*PositionFunction) (float), float Start, float End, float radius, UINT slices, UINT stacks); void ReCreateCylinder(Vec3f (*PositionFunction) (float), float Start, float End, float radius, UINT slices, UINT stacks); void CreateClosedCylinder(float radius, float height, UINT slices, UINT stacks); void CreateLantern(float radius, float height, UINT slices, UINT stacks);
void CreatePrettyPlane(float size, UINT slicesX, UINT slicesY); void CreateCanonicalRenderPlane();
void CreatePlane(float size, UINT slicesX, UINT slicesY); void CreatePlane(const Vec3f &start, const Vec3f &end, UINT slicesX, UINT SlicesY); void CreatePlane(const Plane &p, float length, UINT slices); void CreatePlane(const Plane &p, float length, UINT slices, const Vec3f &Center); void CreateViewPlane(float EyeDist, UINT slices, MatrixController &MC);
void CreateTorus(float MainRadius, float SmallRadius,UINT slices, UINT stacks);
void CreateLozenge(float Radius, const Vec3f &Start, const Vec3f &End, UINT slices, UINT stacks); void ReCreateLozenge(float Radius, const Vec3f &Start, const Vec3f &End, UINT slices, UINT stacks);
void CreatePointCloudBoxes(const Vector<Vec3f> &Points, float Radius);
virtual void Render() const = 0;
void SaveASCII(const String &Filename) const;
void LoadASCII(const String &Filename);
void SaveStream(OutputDataStream &stream) const;
void LoadStream(InputDataStream &stream);
void SaveBinary(const String &Filename) const;
void LoadBinary(const String &Filename);
void SaveCompressed(const String &Filename) const;
void LoadCompressed(const String &Filename);
void SaveObj(const String &Filename) const; void SavePBRT(const String &Filename, const Vector<Vec3f> &LocalCoordinateFrame);
void SavePly(const String &Filename); void LoadObj(const String &Filename, bool IgnoreSlashes = true); void LoadPly(const String &Filename); void LoadGridPly(const String &Filename);
virtual void GenerateNormals(); void GCNormals(); void NormalizeNormals();
void Stretch(float Factor); void Stretch(const Vec3f &V); void Translate(const Vec3f &V); void SetRadius(float Size); void ApplyMatrix(const Matrix4 &M);
void TwoPatch(); void Subdivide();
void Subdivide(UINT Iterations);
Rectangle3f BoundingBox() const; Rectangle3f BoundingBox(const Matrix4 &transform) const;
float Radius(); float Radius(const Vec3f &Center);
Matrix4 UnitSphereTransform();
#ifdef USE_POINT_SET
virtual void WeldVertices(float epsilon); virtual void WeldVertices(float epsilon, Vector<UINT> &OldToNewMapping);
#endif
void UnIndex(); void CleanVerticesAndTriangles();
void CleanVerticesAndTriangles(Vector<UINT> &OldToNewMapping);
void Split(Plane &p, BaseMesh &M1, BaseMesh &M2); void Split(float (*PositionFunction) (Vec3f &), BaseMesh &M1, BaseMesh &M2); void ClosedPlaneSplit(const Plane &P, BaseMesh &M1, BaseMesh &M2);
void CullFaces(const BYTE FaceTest[]);
UINT32 Hash32() const;
UINT64 Hash64() const;
float SurfaceArea() const;
float SidedSurfaceArea(const Plane &P);
void RotateFaces();
protected:
GraphicsDevice *_GD;
};