captypes.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: captypes.h
00004 
00005     DESCRIPTION: Capping type defintions
00006 
00007     CREATED BY: Tom Hudson
00008 
00009     HISTORY: Created 12 October 1995
00010 
00011  *> Copyright (c) 1995, All Rights Reserved.
00012  **********************************************************************/
00013 
00014 #pragma once
00015 #include "maxheap.h"
00016 #include "coreexp.h"
00017 #include "PatchTypeConstants.h"
00018 #include <WTypes.h>
00019 #include "TabTypes.h"
00020 #include "point3.h"
00021 
00022 // forward declarations
00023 class PolyShape;
00024 class BezierShape;
00025 class PatchMesh;
00026 class Mesh;
00027 class Matrix3;
00028 
00029 // Capping types supported
00037 #define CAPTYPE_MORPH 0     //!< Uses the existing vertices in the PolyShape to generate the cap.
00038 
00041 #define CAPTYPE_GRID 1      //!< Generates new vertices in the interior of the shape in a grid pattern.
00042 
00043 
00044 // Capping information classes:
00045 // These classes provide information on how a cap is put together, based on the following:
00046 //
00047 // For Mesh caps, you get a list of created triangular faces, where the vertex indices are
00048 // either original vertices on the PolyShape, newly created vertices inside the shape, or
00049 // newly created vertices on the edge of a shape.  New vertices are only created for GRID
00050 // type capping.  Cap info is always stored in unflipped form -- That is, faces are oriented
00051 // in a counterclockwise order as viewed from the shape's "front", or positive Z.
00052 //
00053 // New free vertices are listed in the MeshCapInfo's "newVerts" table, a simple Point3 table.
00054 // The "newVert" member of the MeshCapVert class points to the entry in the newVerts table.
00055 //
00056 // New edge vertices are stored with the polygon and segment number where they reside, along
00057 // with a position on that segment (0-1) where they reside.  This information allows the cap
00058 // user to divide adjacent faces as needed.
00059 //
00060 // For Patch caps, you can only cap using MORPH type capping.  GRID capping is meant for Mesh
00061 // caps, where distorting a non-subdivided cap would result in serious surface discontinuities.
00062 // Patches are automatically subdivided, so GRID capping is unnecessary there.
00063 //
00064 
00065 // CapFace flags 
00066 #define CF_ABLINE (1<<0)
00067 #define CF_BCLINE (1<<1)
00068 #define CF_CALINE (1<<2)
00069 
00070 class CapFace: public MaxHeapOperators {
00071     public:
00072         int va; // Index of vertex a
00073         int vb; // Index of vertex b
00074         int vc; // Index of vertex c
00075         DWORD flags;
00076         CapFace() {}
00077         CapFace(int a, int b, int c, DWORD f) { va=a; vb=b; vc=c; flags=f; }
00078     };
00079 
00080 // Mesh cap vertices:
00081 // These can be original vertices from the PolyShape or new free vertices
00082 // in the center of the PolyShape.
00083 
00084 #define MCV_ORIGINAL    0
00085 #define MCV_FREE        1
00086 
00087 class MeshCapVert: public MaxHeapOperators {
00088     public:
00089         int type;       // See above
00090         int poly;       // The polygon number
00091         int index;      // The index of the vertex
00092         int newVert;    // The index of the new vertex
00093         MeshCapVert() {}
00094         MeshCapVert(int t, int p, int i, int nv=0) { type=t; poly=p; index=i; newVert=nv; }
00095     };
00096 
00097 typedef Tab<CapFace> CapFaceTab;
00098 typedef Tab<MeshCapVert> MeshCapVertTab;
00099 
00100 // The information class for mesh capping (MORPH or GRID)
00101 
00116 class MeshCapInfo: public MaxHeapOperators {
00117     public:
00118         CapFaceTab faces;
00119         MeshCapVertTab verts;
00120         Point3Tab newVerts;
00122         MeshCapInfo &operator=(MeshCapInfo& from) { faces=from.faces; verts=from.verts; newVerts=from.newVerts; return *this; }
00124         CoreExport void Init(PolyShape* shape);
00128         CoreExport void FreeAll();
00129     };
00130 
00131 // Support classes for MeshCapper
00132 
00133 class PolyLine;
00134 
00145 class MeshCapPoly: public MaxHeapOperators {
00146     public:
00147         int numVerts;
00148         int *verts; // List of verts in mesh corresponding to verts in the PolyLine (1 per vert)
00150         MeshCapPoly() { verts = NULL; }
00152         CoreExport void Init(PolyLine &line);
00154         CoreExport ~MeshCapPoly();
00163         CoreExport void SetVert(int index, int vertex);
00164     };
00165 
00166 // This class is used to apply the MeshCapInfo data to a mesh -- It will modify the mesh as required to
00167 // add the cap.  Simply fill in the vertices and faces bordering the cap, then call the CapMesh method.
00168 
00180 class MeshCapper: public MaxHeapOperators {
00181     public:
00182         int numPolys;
00183         MeshCapPoly *polys;
00189         CoreExport MeshCapper(PolyShape &shape);
00193         CoreExport ~MeshCapper();
00196         CoreExport MeshCapPoly &operator[](int index);
00225         CoreExport int CapMesh(Mesh& mesh, MeshCapInfo& capInfo, BOOL flip, DWORD smooth, Matrix3* tm = NULL, int mtlID = -1);
00226     };
00227 
00228 // Patch capping
00229 
00230 class CapPatch: public MaxHeapOperators {
00231     public:
00232         int type;       // PATCH_TRI or PATCH_QUAD
00233         int verts[4];
00234         int vecs[8];
00235         int interior[4];
00236         CapPatch() {}
00237         CapPatch(int va, int vab, int vba, int vb, int vbc, int vcb, int vc, int vca, int vac, int i1, int i2, int i3) {
00238             type=PATCH_TRI; verts[0]=va; verts[1]=vb; verts[2]=vc; vecs[0]=vab; vecs[1]=vba; vecs[2]=vbc, vecs[3]=vcb;
00239             vecs[4]=vca; vecs[5]=vac; interior[0]=i1; interior[1]=i2; interior[2]=i3; }
00240         CapPatch(int va, int vab, int vba, int vb, int vbc, int vcb, int vc, int vcd, int vdc, int vd, int vda, int vad, int i1, int i2, int i3, int i4) {
00241             type=PATCH_QUAD; verts[0]=va; verts[1]=vb; verts[2]=vc; verts[3]=vd; vecs[0]=vab; vecs[1]=vba; vecs[2]=vbc, vecs[3]=vcb;
00242             vecs[4]=vcd; vecs[5]=vdc; vecs[6]=vda, vecs[7]=vad;  interior[0]=i1; interior[1]=i2; interior[2]=i3; interior[3]=i4; }
00243     };
00244 
00245 // Patch cap vertices:
00246 // These can be original vertices from the BezierShape or new free vertices
00247 // in the center of the BezierShape.
00248 
00249 #define PCVERT_ORIGINAL 0
00250 #define PCVERT_FREE     1
00251 
00264 class PatchCapVert: public MaxHeapOperators {
00265     public:
00266         int type;
00267         int poly;       // The polygon number (ORIGINAL or EDGE)
00268         int index;      // The index of the vertex (ORIGINAL) or the segment for the EDGE vertex
00270         PatchCapVert() {}
00273         PatchCapVert(int t, int p, int i) { type=t; poly=p; index=i; }
00274     };
00275 
00276 // Patch cap vectors:
00277 // When a patch cap is generated, new interior vectors will be generated within the patch, and patch
00278 // edges within the cap will have new vectors.  Patch edges along the edges of the originating bezier
00279 // shape will use existing vectors.  This class provides information on which is which.
00280 
00281 #define PCVEC_ORIGINAL  0
00282 #define PCVEC_NEW       1
00283 
00298 class PatchCapVec: public MaxHeapOperators {
00299     public:
00300         int type;       // See above
00301         int poly;       // Polygon number for ORIGINAL
00302         int index;      // Index for ORIGINAL or into newVecs table (see below)
00304         PatchCapVec() {}
00307         PatchCapVec(int t, int p, int i) { type=t; poly=p; index=i; }
00308     };
00309 
00310 typedef Tab<CapPatch> CapPatchTab;
00311 typedef Tab<PatchCapVert> PatchCapVertTab;
00312 typedef Tab<PatchCapVec> PatchCapVecTab;
00313 
00314 // The information class for patch capping
00315 
00334 class PatchCapInfo: public MaxHeapOperators {
00335     public:
00336         CapPatchTab patches;
00337         PatchCapVertTab verts;
00338         PatchCapVecTab vecs;
00339         Point3Tab newVerts;
00340         Point3Tab newVecs;
00342         PatchCapInfo &operator=(PatchCapInfo &from) { patches=from.patches; verts=from.verts; vecs=from.vecs; newVerts=from.newVerts; newVecs=from.newVecs; return *this; }
00344         CoreExport void Init(BezierShape *shape);
00348         CoreExport void FreeAll();
00349     };
00350 
00351 // Support classes for MeshCapper
00352 
00353 class Spline3D;
00354 
00371 class PatchCapPoly: public MaxHeapOperators {
00372     public:
00373         int numVerts;
00374         int numVecs;
00375         int *verts; // List of verts in patch mesh corresponding to verts in the spline (1 per vert)
00376         int *vecs;  // List of vecs in patch mesh corresponding to vecs in the spline (1 per vector)
00379         PatchCapPoly() { verts = vecs = NULL; }
00381         CoreExport void Init(Spline3D &spline);
00384         CoreExport ~PatchCapPoly();
00393         CoreExport void SetVert(int index, int vertex);
00402         CoreExport void SetVec(int index, int vector);
00403     };
00404 
00405 // This class is used to apply the PatchCapInfo data to a PatchMesh -- It will modify the mesh as required to
00406 // add the cap.  Simply fill in the vertices, vectors and patches bordering the cap, then call the CapPatch method.
00407 
00420 class PatchCapper: public MaxHeapOperators {
00421     public:
00422         int numPolys;
00423         PatchCapPoly *polys;
00428         CoreExport PatchCapper(BezierShape &shape);
00430         CoreExport ~PatchCapper();
00432         CoreExport PatchCapPoly &operator[](int index);
00463         CoreExport int CapPatchMesh(PatchMesh& mesh, PatchCapInfo& capInfo, BOOL flip, DWORD smooth, Matrix3* tm = NULL, int mtlID = -1);
00464     };
00465 
00466