source: golgotha/src/maxtool/sdk_inc/captypes.h @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
  • Property svn:keywords set to Id
File size: 7.7 KB
Line 
1/**********************************************************************
2 *<
3        FILE: captypes.h
4
5        DESCRIPTION: Capping type defintions
6
7        CREATED BY: Tom Hudson
8
9        HISTORY: Created 12 October 1995
10
11 *> Copyright (c) 1995, All Rights Reserved.
12 **********************************************************************/
13
14#ifndef __CAPTYPES_H_
15
16#define __CAPTYPES_H_
17
18// Just in case...
19class PolyShape;
20class BezierShape;
21
22// Capping types supported
23#define CAPTYPE_MORPH 0         // AKA 3D Studio DOS capping
24#define CAPTYPE_GRID 1          // Max's very own capping
25
26// Capping information classes:
27// These classes provide information on how a cap is put together, based on the following:
28//
29// For Mesh caps, you get a list of created triangular faces, where the vertex indices are
30// either original vertices on the PolyShape, newly created vertices inside the shape, or
31// newly created vertices on the edge of a shape.  New vertices are only created for GRID
32// type capping.  Cap info is always stored in unflipped form -- That is, faces are oriented
33// in a counterclockwise order as viewed from the shape's "front", or positive Z.
34//
35// New free vertices are listed in the MeshCapInfo's "newVerts" table, a simple Point3 table.
36// The "newVert" member of the MeshCapVert class points to the entry in the newVerts table.
37//
38// New edge vertices are stored with the polygon and segment number where they reside, along
39// with a position on that segment (0-1) where they reside.  This information allows the cap
40// user to divide adjacent faces as needed.
41//
42// For Patch caps, you can only cap using MORPH type capping.  GRID capping is meant for Mesh
43// caps, where distorting a non-subdivided cap would result in serious surface discontinuities.
44// Patches are automatically subdivided, so GRID capping is unnecessary there.
45//
46
47// CapFace flags
48#define CF_ABLINE (1<<0)
49#define CF_BCLINE (1<<1)
50#define CF_CALINE (1<<2)
51
52class CapFace {
53        public:
54                int va; // Index of vertex a
55                int vb; // Index of vertex b
56                int vc; // Index of vertex c
57                DWORD flags;
58                CapFace() {}
59                CapFace(int a, int b, int c, DWORD f) { va=a; vb=b; vc=c; flags=f; }
60        };
61
62// Mesh cap vertices:
63// These can be original vertices from the PolyShape or new free vertices
64// in the center of the PolyShape.
65
66#define MCV_ORIGINAL    0
67#define MCV_FREE                1
68
69class MeshCapVert {
70        public:
71                int type;               // See above
72                int poly;               // The polygon number
73                int index;              // The index of the vertex
74                int newVert;    // The index of the new vertex
75                MeshCapVert() {}
76                MeshCapVert(int t, int p, int i, int nv=0) { type=t; poly=p; index=i; newVert=nv; }
77        };
78
79typedef Tab<CapFace> CapFaceTab;
80typedef Tab<MeshCapVert> MeshCapVertTab;
81typedef Tab<Point3> Point3Tab;
82
83// The information class for mesh capping (MORPH or GRID)
84
85class MeshCapInfo {
86        public:
87                CapFaceTab faces;
88                MeshCapVertTab verts;
89                Point3Tab newVerts;
90                MeshCapInfo &operator=(MeshCapInfo &from) { faces=from.faces; verts=from.verts; newVerts=from.newVerts; return *this; }
91                CoreExport void Init(PolyShape *shape);
92                CoreExport void FreeAll();
93        };
94
95// Support classes for MeshCapper
96
97class PolyLine;
98
99class MeshCapPoly {
100        public:
101                int numVerts;
102                int *verts;     // List of verts in mesh corresponding to verts in the PolyLine (1 per vert)
103                MeshCapPoly() { verts = NULL; }
104                CoreExport void Init(PolyLine &line);
105                CoreExport ~MeshCapPoly();
106                CoreExport void SetVert(int index, int vertex);
107        };
108
109// This class is used to apply the MeshCapInfo data to a mesh -- It will modify the mesh as required to
110// add the cap.  Simply fill in the vertices and faces bordering the cap, then call the CapMesh method.
111
112class MeshCapper {
113        public:
114                int numPolys;
115                MeshCapPoly *polys;
116                CoreExport MeshCapper(PolyShape &shape);
117                CoreExport ~MeshCapper();
118                CoreExport MeshCapPoly &operator[](int index);
119                CoreExport int CapMesh(Mesh &mesh, MeshCapInfo &capInfo, BOOL flip, DWORD smooth, Matrix3 *tm=NULL);
120        };
121
122// Patch capping
123
124class CapPatch {
125        public:
126                int type;               // PATCH_TRI or PATCH_QUAD
127                int verts[4];
128                int vecs[8];
129                int interior[4];
130                CapPatch() {}
131                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) {
132                        type=PATCH_TRI; verts[0]=va; verts[1]=vb; verts[2]=vc; vecs[0]=vab; vecs[1]=vba; vecs[2]=vbc, vecs[3]=vcb;
133                        vecs[4]=vca; vecs[5]=vac; interior[0]=i1; interior[1]=i2; interior[2]=i3; }
134                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) {
135                        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;
136                        vecs[4]=vcd; vecs[5]=vdc; vecs[6]=vda, vecs[7]=vad;  interior[0]=i1; interior[1]=i2; interior[2]=i3; interior[3]=i4; }
137        };
138
139// Patch cap vertices:
140// These can be original vertices from the BezierShape or new free vertices
141// in the center of the BezierShape.
142
143#define PCVERT_ORIGINAL 0
144#define PCVERT_FREE             1
145
146class PatchCapVert {
147        public:
148                int type;
149                int poly;               // The polygon number (ORIGINAL or EDGE)
150                int index;              // The index of the vertex (ORIGINAL) or the segment for the EDGE vertex
151                PatchCapVert() {}
152                PatchCapVert(int t, int p, int i) { type=t; poly=p; index=i; }
153        };
154
155// Patch cap vectors:
156// When a patch cap is generated, new interior vectors will be generated within the patch, and patch
157// edges within the cap will have new vectors.  Patch edges along the edges of the originating bezier
158// shape will use existing vectors.  This class provides information on which is which.
159
160#define PCVEC_ORIGINAL  0
161#define PCVEC_NEW               1
162
163class PatchCapVec {
164        public:
165                int type;               // See above
166                int poly;               // Polygon number for ORIGINAL
167                int index;              // Index for ORIGINAL or into newVecs table (see below)
168                PatchCapVec() {}
169                PatchCapVec(int t, int p, int i) { type=t; poly=p; index=i; }
170        };
171
172typedef Tab<CapPatch> CapPatchTab;
173typedef Tab<PatchCapVert> PatchCapVertTab;
174typedef Tab<PatchCapVec> PatchCapVecTab;
175
176// The information class for patch capping
177
178class PatchCapInfo {
179        public:
180                CapPatchTab patches;
181                PatchCapVertTab verts;
182                PatchCapVecTab vecs;
183                Point3Tab newVerts;
184                Point3Tab newVecs;
185                PatchCapInfo &operator=(PatchCapInfo &from) { patches=from.patches; verts=from.verts; vecs=from.vecs; newVerts=from.newVerts; newVecs=from.newVecs; return *this; }
186                CoreExport void Init(BezierShape *shape);
187                CoreExport void FreeAll();
188        };
189
190// Support classes for MeshCapper
191
192class Spline3D;
193
194class PatchCapPoly {
195        public:
196                int numVerts;
197                int numVecs;
198                int *verts;     // List of verts in patch mesh corresponding to verts in the spline (1 per vert)
199                int *vecs;      // List of vecs in patch mesh corresponding to vecs in the spline (1 per vector)
200                PatchCapPoly() { verts = vecs = NULL; }
201                CoreExport void Init(Spline3D &spline);
202                CoreExport ~PatchCapPoly();
203                CoreExport void SetVert(int index, int vertex);
204                CoreExport void SetVec(int index, int vector);
205        };
206
207// This class is used to apply the PatchCapInfo data to a PatchMesh -- It will modify the mesh as required to
208// add the cap.  Simply fill in the vertices, vectors and patches bordering the cap, then call the CapPatch method.
209
210class PatchCapper {
211        public:
212                int numPolys;
213                PatchCapPoly *polys;
214                CoreExport PatchCapper(BezierShape &shape);
215                CoreExport ~PatchCapper();
216                CoreExport PatchCapPoly &operator[](int index);
217                CoreExport int CapPatchMesh(PatchMesh &mesh, PatchCapInfo &capInfo, BOOL flip, DWORD smooth, Matrix3 *tm=NULL);
218        };
219
220
221#endif // __CAPTYPES_H_
Note: See TracBrowser for help on using the repository browser.