This reference page is linked to from the following overview topics: Shape and Spline Principal Classes, Capping a Shape with a Mesh, Capping a Shape with a Patch.
A multi-polygon shape class.
This class is used in the caching of bezier shapes. This is used for doing a one time interpolation of a bezier shape into a form that is the same shape but doesn't require any further interpolation. In this way the system can do the complex calculations once, store the shape into this PolyShape representation, and not have to go through the cubic spline calculations to figure out where the points are in the future. This class maintains an array of PolyLines. As an example, this is used in the Extrude modifier. First, it generates a PolyShape from the bezier shape it is extruding. Next, this PolyShape is used to generate the mesh.
#include <polyshp.h>
Public Member Functions |
|
CoreExport | PolyShape () |
Constructor. |
|
CoreExport | PolyShape (PolyShape &from) |
Constructor. |
|
CoreExport | ~PolyShape () |
Destructor. |
|
CoreExport void | Init () |
CoreExport void | NewShape () |
This deletes all the lines from the
PolyShape and clears the shape
out. |
|
CoreExport BOOL | SetNumLines (int count, BOOL keep=TRUE) |
Sets the number of polygons used by the poly
shape. |
|
CoreExport PolyLine * | NewLine () |
Creates a new PolyLine
and appends it to the end of the list of lines maintained by this
PolyShape. |
|
CoreExport void | Append (PolyLine &l) |
Appends the specified PolyLine
to the end of the lines list. |
|
CoreExport void | Insert (int where, PolyLine &l) |
Inserts the specified PolyLine
at the input location. |
|
CoreExport void | Delete (int where) |
Deletes the specified PolyLine
from the lines list. |
|
CoreExport PolyShape & | operator= (PolyShape &from) |
Assignment operator. |
|
CoreExport PolyShape & | operator= (BezierShape &from) |
Assignment operator. |
|
CoreExport void | BuildBoundingBox (void) |
Builds a bounding box surrounding every line
in the lines list. |
|
CoreExport void | InvalidateGeomCache (BOOL unused) |
Invalidates the cache of each line in the
PolyShape. |
|
CoreExport void | InvalidateCapCache () |
Invalidates the morph, and grid cap caches.
|
|
CoreExport Box3 | GetBoundingBox (Matrix3 *tm=NULL) |
Returns the bounding box of the
PolyLines in this PolyShape. |
|
CoreExport void | GetDeformBBox (TimeValue t, Box3 &box, Matrix3 *tm, BOOL useSel) |
Computes the bounding box of this PolyShape. |
|
CoreExport void | Render (GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat) |
CoreExport BOOL | Select (GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit=FALSE) |
CoreExport void | Snap (GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm) |
CoreExport void | Snap (GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm, DWORD flags) |
CoreExport void | Transform (Matrix3 &tm) |
Transforms the vertices of each PolyLine
in this PolyShape by the specified
matrix. |
|
CoreExport int | MakeCap (TimeValue t, MeshCapInfo &capInfo, int capType) |
This method may be called to fill in the
MeshCapInfo
passed with the appropriate capping information. |
|
CoreExport int | MakeCap (TimeValue t, PatchCapInfo &capInfo) |
This method may be called to fill in the
PatchCapInfo
passed with the appropriate capping information. |
|
CoreExport int | Make3DSCap (MeshCapInfo &capInfo, DWORD options=0) |
CoreExport int | MakeGridCap (MeshCapInfo &capInfo) |
CoreExport void | Dump (MCHAR *title=NULL) |
This may be called to display information
about the PolyShape to the debug window
via DebugPrint(). |
|
CoreExport void | UpdateCachedHierarchy () |
CoreExport ShapeHierarchy & | OrganizeCurves (TimeValue t, ShapeHierarchy *hier=NULL) |
This methods looks at the shape
organization, and puts together a shape hierarchy. |
|
CoreExport void | UpdateSels () |
This is a very important call to make.
|
|
CoreExport void | Reverse (int poly, BOOL keepZero=FALSE) |
Reverses the PolyLine
whose index is passed. |
|
CoreExport void | Reverse (BitArray &reverse, BOOL keepZero=FALSE) |
Reverses the splines of this shape if the
corresponding bit in reverse is set. |
|
CoreExport MtlID | GetMatID (int poly, int piece) |
Returns the material ID for the specified
segment of the specified poly. |
|
CoreExport BitArray | VertexTempSel (int poly) |
Constructs a vertex selection list based on
the current selection level of the specified poly. |
|
CoreExport void | ShallowCopy (PolyShape *ashape, ChannelMask channels) |
CoreExport void | DeepCopy (PolyShape *ashape, ChannelMask channels) |
CoreExport void | NewAndCopyChannels (ChannelMask channels) |
CoreExport void | FreeChannels (ChannelMask channels, int zeroOthers=1) |
CoreExport IOResult | Save (ISave *isave) |
CoreExport IOResult | Load (ILoad *iload) |
CoreExport bool | Delete (const unsigned int *indices, unsigned int n) |
Deletes multiple lines at once. |
|
CoreExport void | Append (PolyLine *lines, unsigned int n, bool useSwap=false) |
Append multiple lines at once. |
|
Public Attributes |
|
int | numLines |
The number of lines in the polyshape.
|
|
PolyLine * | lines |
The array of lines. |
|
DWORD | flags |
Currently not used. |
|
Box3 | bdgBox |
Stores the bounding box surrounding each
PolyLine
in the shape. |
|
DWORD | selLevel |
The selection level. |
|
DWORD | dispFlags |
Display Attribute Flags. |
|
Selections
|
|
ShapeVSel | vertSel |
selected vertices |
|
ShapeSSel | segSel |
selected segments |
|
ShapePSel | polySel |
selected polygons |
|
Capping Caches
|
|
MeshCapInfo | morphCap |
The morph cap information. |
|
BOOL | morphCapCacheValid |
Determines if the morph cap is valid.
|
|
MeshCapInfo | gridCap |
The grid cap information. |
|
BOOL | gridCapCacheValid |
Determines if the grid cap is valid.
|
|
PatchCapInfo | patchCap |
The patch cap information. |
|
BOOL | patchCapCacheValid |
Determines if the patch cap is valid.
|
|
ShapeHierarchy | cachedHier |
Hierarchy cache. |
|
BOOL | hierCacheValid |
Determines if the hierarchy cache is valid.
|
CoreExport PolyShape | ( | ) |
Constructor.
The number of lines is set to 0, the lines array is set to NULL, the flags and display flags are set to 0, the selection level is set to SHAPE_OBJECT, the geometry cache is invalidated, and the masterObject is set to NULL.
CoreExport ~PolyShape | ( | ) |
Destructor.
CoreExport void Init | ( | ) |
This function is a special version used by the constructors and should not be called by plug-in developers. If you need to clear out a PolyShape use NewShape().
CoreExport void NewShape | ( | ) |
CoreExport BOOL SetNumLines | ( | int | count, |
BOOL | keep = TRUE |
||
) |
Sets the number of polygons used by the poly shape.
count | The number of lines. |
keep | If set to true, any old lines are copied to the new storage. They are freed otherwise. Defaults to true. |
CoreExport PolyLine* NewLine | ( | ) |
CoreExport void Append | ( | PolyLine & | l | ) |
CoreExport void Insert | ( | int | where, |
PolyLine & | l | ||
) |
Inserts the specified PolyLine at the input location.
CoreExport void Delete | ( | int | where | ) |
Deletes the specified PolyLine from the lines list.
where | The index into the lines list specifying which line to delete. |
CoreExport PolyShape& operator= | ( | BezierShape & | from | ) |
Assignment operator.
Note that this operator does not offer as much control as calling the method on the BezierShape itself named MakePolyShape(). That version allows you to specify the number of steps and an optimize parameter. These options are not available on this simple assignment operator.
CoreExport void BuildBoundingBox | ( | void | ) |
Builds a bounding box surrounding every line in the lines list.
The bounding box is returned through the bdgBox data member.
CoreExport void InvalidateGeomCache | ( | BOOL | unused | ) |
Invalidates the cache of each line in the PolyShape.
The bounding box is set to empty. This method also invalidates the capping caches.
unused | This parameter is not used. |
CoreExport void InvalidateCapCache | ( | ) |
Invalidates the morph, and grid cap caches.
Returns the bounding box of the PolyLines in this PolyShape.
The optional TM allows the box to be calculated in any space.
tm | The points of the PolyLines in this PolyShape are transformed by this matrix prior to the bounding box computations. optional TM allows the box to be calculated in any space. |
Computes the bounding box of this PolyShape.
CoreExport void Render | ( | GraphicsWindow * | gw, |
Material * | ma, | ||
RECT * | rp, | ||
int | compFlags, | ||
int | numMat | ||
) |
This method is used internally.
CoreExport BOOL Select | ( | GraphicsWindow * | gw, |
Material * | ma, | ||
HitRegion * | hr, | ||
int | abortOnHit =
FALSE |
||
) |
This method is used internally.
CoreExport void Snap | ( | GraphicsWindow * | gw, |
SnapInfo * | snap, | ||
IPoint2 * | p, | ||
Matrix3 & | tm | ||
) |
This method is used internally.
CoreExport void Snap | ( | GraphicsWindow * | gw, |
SnapInfo * | snap, | ||
IPoint2 * | p, | ||
Matrix3 & | tm, | ||
DWORD | flags | ||
) |
This method is used internally.
CoreExport void Transform | ( | Matrix3 & | tm | ) |
CoreExport int MakeCap | ( | TimeValue | t, |
MeshCapInfo & | capInfo, | ||
int | capType | ||
) |
This method may be called to fill in the MeshCapInfo passed with the appropriate capping information.
See Working with * Patches for more details on capping. This method is used for meshes. The method below is used for patches.
tThis | should be passed as the current time. You may retrieve this using Interface::GetTime() (See Class Interface). |
capInfo | This information is filled in by this method. (See Class MeshCapInfo). |
capType | The cap type. See Shape Capping Types. |
CoreExport int MakeCap | ( | TimeValue | t, |
PatchCapInfo & | capInfo | ||
) |
This method may be called to fill in the PatchCapInfo passed with the appropriate capping information.
This method is used for patches. Note that it is generally not recommended to try to create patch caps from PolyShapes. The patch cap uses bezier information, so it is much better to use a BezierShape to make a patch cap. It is very inefficient to do this with a PolyShape.
t | This should be passed as the current time. You may retrieve this using Interface::GetTime() (See Class Interface). |
capInfo | This information is filled in by this method. (See Class PatchCapInfo). |
CoreExport int Make3DSCap | ( | MeshCapInfo & | capInfo, |
DWORD | options = 0 |
||
) |
This method is used internally.
CoreExport int MakeGridCap | ( | MeshCapInfo & | capInfo | ) |
This method is used internally.
CoreExport void Dump | ( | MCHAR * | title = NULL |
) |
CoreExport void UpdateCachedHierarchy | ( | ) |
This method is used internally.
CoreExport ShapeHierarchy& OrganizeCurves | ( | TimeValue | t, |
ShapeHierarchy * | hier = NULL |
||
) |
This methods looks at the shape organization, and puts together a shape hierarchy.
This provides information on how the shapes are nested. For example on a donut object with two circles, this method determines which circle is inside the other one.
t | This parameter is not used. |
hier | If non-NULL the result is store here (in addition to being returned). (See Class ShapeHierarchy). |
CoreExport void UpdateSels | ( | ) |
This is a very important call to make.
Whenever you have changed the PolyShape, for example after you are done adding polygons to the shape or have changed the number of points in a shape, you should call this method. This method updates a set of embedded selection set data within the shape. This selection set data tells what polygons are selected, what segments are selected, and what control points are selected. This resets the sizes of the selection bit arrays for this shape.
CoreExport void Reverse | ( | int | poly, |
BOOL | keepZero =
FALSE |
||
) |
Reverses the PolyLine whose index is passed.
poly | The spline to reverse. |
keepZero | This should normally be passed as "true". If set to true, and the polyline is closed, this method will make sure that vertex zero is the same on the reversed version as on the non-reversed version. Otherwise, if set to false, the last vertex becomes the first vertex, and the first vertex becomes the last. This is an important distinction for the lofter because it always wants vertex zero to be in the same place. |
CoreExport void Reverse | ( | BitArray & | reverse, |
BOOL | keepZero =
FALSE |
||
) |
Reverses the splines of this shape if the corresponding bit in reverse is set.
The BitArray has one bit for each polyline.
reverse | If the bit is set the spline is reversed; otherwise it is left
alone. =FALSE This should normally be passed as TRUE. If set to true, and the polyline is closed, this method will make sure that vertex zero is the same on the reversed version as on the non-reversed version. Otherwise, if set to false, the last vertex becomes the first vertex, and the first vertex becomes the last. This is an important distinction for the lofter because it always wants vertex zero to be in the same place. |
CoreExport MtlID GetMatID | ( | int | poly, |
int | piece | ||
) |
Returns the material ID for the specified segment of the specified poly.
poly | The zero based index of the poly. |
piece | The zero based index of the segment. |
CoreExport BitArray VertexTempSel | ( | int | poly | ) |
Constructs a vertex selection list based on the current selection level of the specified poly.
For example if the selection level is at object level all the bits are set. If the selection level is at vertex level only the selected vertex bits are set. See Class BitArray.
poly | The poly whose selection level is constructed. |
CoreExport void ShallowCopy | ( | PolyShape * | ashape, |
ChannelMask | channels | ||
) |
This method is used internally in data flow evaluation in the pipeline.
CoreExport void DeepCopy | ( | PolyShape * | ashape, |
ChannelMask | channels | ||
) |
This method is used internally in data flow evaluation in the pipeline.
CoreExport void NewAndCopyChannels | ( | ChannelMask | channels | ) |
This method is used internally in data flow evaluation in the pipeline.
CoreExport void FreeChannels | ( | ChannelMask | channels, |
int | zeroOthers =
1 |
||
) |
This method is used internally in data flow evaluation in the pipeline.
This method is used internally in saving to the MAX file.
This method is used internally in loading from the MAX file.
CoreExport bool Delete | ( | const unsigned int * | indices, |
unsigned int | n | ||
) |
Deletes multiple lines at once.
This is faster than deleting one by one using Delete(), because the internal bookkeeping only needs to be done once. Lines are deleted in reverse order, from highest index to lowest index. If the array of indices is not properly sorted (in ascending order), or if the indices are not unique, the results will be undefined: the wrong lines may be deleted, or more likely 'false' will be returned, leaving you with a ShapeObject in an undefined state.
indices | Point to an array of indices to delete. Indices should be unique, and sorted in ascending order. of entries in the indices array. |
CoreExport void Append | ( | PolyLine * | lines, |
unsigned int | n, | ||
bool | useSwap =
false |
||
) |
Append multiple lines at once.
This is faster than appending one by one using Append(), because the internal bookkeeping only needs to be done once.
lines | Array of lines to append. |
n | Number of entries in the lines array. |
useSwap | Should PolyLine::Swap() be used instead of operator = ? Using Swap() is faster, and should be used if you are just going to discard the contents of the lines array. |
int numLines |
The number of lines in the polyshape.
The array of lines.
DWORD flags |
Currently not used.
Stores the bounding box surrounding each PolyLine in the shape.
selected vertices
selected segments
selected polygons
DWORD selLevel |
DWORD dispFlags |
Display Attribute Flags.
The morph cap information.
BOOL morphCapCacheValid |
Determines if the morph cap is valid.
The grid cap information.
BOOL gridCapCacheValid |
Determines if the grid cap is valid.
The patch cap information.
BOOL patchCapCacheValid |
Determines if the patch cap is valid.
Hierarchy cache.
BOOL hierCacheValid |
Determines if the hierarchy cache is valid.