MeshNormalSpec Class Reference

MeshNormalSpec Class Reference

#include <MeshNormalSpec.h>

Class Description

This class is an interface used to store user-specified normals (such as those created in the Edit Normals modifier).

These normals have very limited pipeline support. They are used for viewport display, but not for rendering.

The MeshNormalSpec contains three types of normals:

  • Unspecified - these are the usual normals that are computed from smoothing groups. All normals are unspecified by default.
  • Specified - these are normals that are intended for use by particular corners of particular faces, without regard to smoothing groups. For instance, you can create a box, apply Edit Normals, select a group of normals at a particular vertex, and click "Unify". Now those three faces are told to specifically use that one unified normal, and they ignore their smoothing groups at that vertex (which would normally tell them they should each have their own normal).
  • Explicit - these are normals that are set to particular values. For instance, if the user wants to use the Edit Normals Move or Rotate commands to set a normal to something other than its default value, it has to be made explicit, so it won't be recomputed based on the face normals. All explicit normals are also considered to be specified..
+ Inheritance diagram for MeshNormalSpec:

Public Member Functions

 MeshNormalSpec ()
 
 ~MeshNormalSpec ()
 
void SetFlag (DWORD fl, bool val=true)
 Sets flags in the MeshNormalSpec. More...
 
void ClearFlag (DWORD fl)
 Clears the flags given. See GetFlag for more details on MeshNormalSpec flags. More...
 
bool GetFlag (DWORD fl) const
 Gets flags in the MeshNormalSpec. More...
 
DllExport void Initialize ()
 Initializes all data members - do not use if already allocated! More...
 
DllExport bool NAlloc (int num, bool keep=TRUE)
 
DllExport void NShrink ()
 shrinks allocation down to actual number of normals. More...
 
DllExport bool FAlloc (int num, bool keep=TRUE)
 
DllExport void FShrink ()
 
DllExport void Clear ()
 Deletes everything. More...
 
DllExport void ClearAndFree ()
 Deletes everything, frees all memory. More...
 
int GetNumFaces () const
 
DllExport bool SetNumFaces (int numFaces)
 
int GetNumNormals () const
 
DllExport bool SetNumNormals (int numNormals)
 
Point3Normal (int normID) const
 
Point3GetNormalArray () const
 
bool GetNormalExplicit (int normID) const
 
void SetNormalExplicit (int normID, bool value)
 
void SetAllExplicit (bool value=true)
 Set all normals to be explicit. More...
 
MeshNormalFaceFace (int faceID) const
 
MeshNormalFaceGetFaceArray () const
 
void SetParent (Mesh *pMesh)
 
DllExport Point3GetNormal (int face, int corner)
 
DllExport void SetNormal (int face, int corner, Point3 &normal)
 
DllExport int GetNormalIndex (int face, int corner)
 
DllExport void SetNormalIndex (int face, int corner, int normalIndex)
 
DllExport int NewNormal (Point3 normal, bool explic=true)
 
DllExport void SetSelection (BitArray &newSelection)
 
BitArrayGetSelection ()
 
void SetDisplayLength (float displayLength)
 
float GetDisplayLength ()
 
DllExport void Display (GraphicsWindow *gw, bool showSel)
 
DllExport bool HitTest (GraphicsWindow *gw, HitRegion *hr, DWORD flags, SubObjHitList &hitList)
 
DllExport Box3 GetBoundingBox (Matrix3 *tm=NULL, bool selectedOnly=false)
 
DllExport void ClearNormals ()
 This method dumps all unspecified normals. Best to use only from within CheckNormals. More...
 
DllExport void BuildNormals ()
 Fills in the mpSpecNormal data by building all the unspecified normals, and computing non-explicit ones. More...
 
DllExport void ComputeNormals ()
 This method just recomputes the directions of non-explicit normals, without rebuilding the normal list. More...
 
DllExport void CheckNormals ()
 This checks our flags and calls BuildNormals, ComputeNormals as needed. More...
 
DllExport MeshNormalSpecoperator= (const MeshNormalSpec &from)
 
DllExport void CopySpecified (const MeshNormalSpec &from)
 
DllExport MeshNormalSpecoperator+= (const MeshNormalSpec &from)
 
DllExport void MyDebugPrint (bool printAll=false)
 
DllExport bool CheckAllData (int numParentFaces)
 
DllExport IOResult Save (ISave *isave)
 
DllExport IOResult Load (ILoad *iload)
 
Interface_ID GetID ()
 
DllExport void DeleteInterface ()
 
DllExport BaseInterfaceGetInterface (Interface_ID id)
 
DllExport BaseInterfaceCloneInterface (void *remapDir=NULL)
 
DllExport void ShallowCopy (IPipelineClient *from, ChannelMask channels)
 
DllExport void DeepCopy (IPipelineClient *from, ChannelMask channels)
 
DllExport void NewAndCopyChannels (ChannelMask channels)
 
DllExport void FreeChannels (ChannelMask channels, int zeroOthers=1)
 
DllExport void ZeroChannels (ChannelMask channels)
 
DllExport void AppendAllChannels (IPipelineClient *from)
 
DllExport bool Transform (Matrix3 &xfm, BOOL useSel=false, BitArray *normalSelection=NULL)
 
DllExport bool Translate (Point3 &translate, BOOL useSel=true, BitArray *normalSelection=NULL)
 
DllExport bool BreakNormals (BOOL useSel=true, BitArray *normalSelection=NULL, BOOL toAverage=false)
 
DllExport bool UnifyNormals (BOOL useSel=true, BitArray *normalSelection=NULL, BOOL toAverage=false)
 
DllExport bool AverageNormals (BOOL useThresh=false, float threshold=0.0f, BOOL useSel=true, BitArray *normalSelection=NULL)
 
DllExport bool SpecifyNormals (BOOL useSel=true, BitArray *normalSelection=NULL)
 
DllExport bool MakeNormalsExplicit (BOOL useSel=true, BitArray *normalSelection=NULL, bool value=true)
 
DllExport bool ResetNormals (BOOL useSel=true, BitArray *normalSelection=NULL)
 
- Public Member Functions inherited from BaseInterface
virtual UtilExport ~BaseInterface ()
 Destructor. More...
 
virtual LifetimeType LifetimeControl ()
 
virtual bool RegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual void UnRegisterNotifyCallback (InterfaceNotifyCallback *incb)
 
virtual BaseInterfaceAcquireInterface ()
 
virtual void ReleaseInterface ()
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 

Additional Inherited Members

- Public Types inherited from BaseInterface
enum  LifetimeType { noRelease, immediateRelease, wantsRelease, serverControlled }
 
- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

MeshNormalSpec ( )
inline
159  : mpFace(NULL), mpNormal(NULL), mNumNormalAlloc(0),
160  mNumFaceAlloc(0), mNumNormals(0), mNumFaces(0), mpParent(NULL), mFlags(0),
161  mDisplayLength(MESH_NORMAL_LENGTH_DEFAULT) { }
#define NULL
Definition: autoptr.h:18
#define MESH_NORMAL_LENGTH_DEFAULT
Definition: MeshNormalSpec.h:116
~MeshNormalSpec ( )
inline
162 { ClearAndFree (); }
DllExport void ClearAndFree()
Deletes everything, frees all memory.

Member Function Documentation

void SetFlag ( DWORD  fl,
bool  val = true 
)
inline

Sets flags in the MeshNormalSpec.

Generally, the only flag that clients should set is the MESH_NORMAL_MODIFIER_SUPPORT flag. See GetFlag for more details.

166 { if (val) mFlags |= fl; else mFlags &= ~fl; }
void ClearFlag ( DWORD  fl)
inline

Clears the flags given. See GetFlag for more details on MeshNormalSpec flags.

169 { mFlags &= ~fl; }
bool GetFlag ( DWORD  fl) const
inline

Gets flags in the MeshNormalSpec.

Remarks
MeshNormalSpec supports the following flags: MESH_NORMAL_NORMALS_BUILT Indicates that non-specified normals have been constructed using smoothing groups. If not set, non-specified normals may be invalid. MESH_NORMAL_NORMALS_COMPUTED Indicates that non-explicit normals have been computed using geometrically computed face normals. (If not set, only explicit normals may be assumed to be pointing the right direction.) MESH_NORMAL_MODIFIER_SUPPORT This flag should be set by modifiers that want to support the edited normals. See class TriObjectNormalModifier for more details. If this flag is not specifically set in a modifier that alters PART_GEOM or PART_TOPO of a TriObject, any specified normals will be cleared after the modifier is evaluated.
186 { return (mFlags & fl) ? true : false; }
DllExport void Initialize ( )

Initializes all data members - do not use if already allocated!

DllExport bool NAlloc ( int  num,
bool  keep = TRUE 
)
DllExport void NShrink ( )

shrinks allocation down to actual number of normals.

DllExport bool FAlloc ( int  num,
bool  keep = TRUE 
)
DllExport void FShrink ( )
DllExport void Clear ( )

Deletes everything.

DllExport void ClearAndFree ( )

Deletes everything, frees all memory.

int GetNumFaces ( ) const
inline
204 { return mNumFaces; }
DllExport bool SetNumFaces ( int  numFaces)
int GetNumNormals ( ) const
inline
206 { return mNumNormals; }
DllExport bool SetNumNormals ( int  numNormals)
Point3& Normal ( int  normID) const
inline
209 { return mpNormal[normID]; }
Point3* GetNormalArray ( ) const
inline
210 { return mpNormal; }
bool GetNormalExplicit ( int  normID) const
inline
211 { return mNormalExplicit[normID] ? true : false; }
void SetNormalExplicit ( int  normID,
bool  value 
)
inline
212 { mNormalExplicit.Set (normID, value); }
void Set(int i)
Definition: bitarray.h:289
void SetAllExplicit ( bool  value = true)
inline

Set all normals to be explicit.

Parameters
value- If true, all normals will be set to explicit. If false, all normals will be set to non-explicit
216 { if (value) mNormalExplicit.SetAll(); else mNormalExplicit.ClearAll (); }
void SetAll()
Definition: bitarray.h:275
void ClearAll()
Definition: bitarray.h:262
MeshNormalFace& Face ( int  faceID) const
inline
217 { return mpFace[faceID]; }
MeshNormalFace* GetFaceArray ( ) const
inline
218 { return mpFace; }
void SetParent ( Mesh pMesh)
inline
220 { mpParent = pMesh; }
DllExport Point3& GetNormal ( int  face,
int  corner 
)
DllExport void SetNormal ( int  face,
int  corner,
Point3 normal 
)
DllExport int GetNormalIndex ( int  face,
int  corner 
)
DllExport void SetNormalIndex ( int  face,
int  corner,
int  normalIndex 
)
DllExport int NewNormal ( Point3  normal,
bool  explic = true 
)
DllExport void SetSelection ( BitArray newSelection)
BitArray& GetSelection ( )
inline
230 { return mNormalSel; }
void SetDisplayLength ( float  displayLength)
inline
231 { mDisplayLength = displayLength; }
float GetDisplayLength ( )
inline
232 { return mDisplayLength; }
DllExport void Display ( GraphicsWindow gw,
bool  showSel 
)
DllExport bool HitTest ( GraphicsWindow gw,
HitRegion hr,
DWORD  flags,
SubObjHitList hitList 
)
DllExport Box3 GetBoundingBox ( Matrix3 tm = NULL,
bool  selectedOnly = false 
)
DllExport void ClearNormals ( )

This method dumps all unspecified normals. Best to use only from within CheckNormals.

DllExport void BuildNormals ( )

Fills in the mpSpecNormal data by building all the unspecified normals, and computing non-explicit ones.

Remarks
Does nothing if normal faces not allocated yet!

Requires an accurate mpParent pointer.
DllExport void ComputeNormals ( )

This method just recomputes the directions of non-explicit normals, without rebuilding the normal list.

Remarks
Requires an accurate mpParent pointer.
DllExport void CheckNormals ( )

This checks our flags and calls BuildNormals, ComputeNormals as needed.

Remarks
Requires an accurate mpParent pointer.
DllExport MeshNormalSpec& operator= ( const MeshNormalSpec from)
DllExport void CopySpecified ( const MeshNormalSpec from)
DllExport MeshNormalSpec& operator+= ( const MeshNormalSpec from)
DllExport void MyDebugPrint ( bool  printAll = false)
DllExport bool CheckAllData ( int  numParentFaces)
DllExport IOResult Save ( ISave isave)
DllExport IOResult Load ( ILoad iload)
Interface_ID GetID ( )
inlinevirtual
Remarks
This method returns the unique interface ID.

Reimplemented from IPipelineClient.

#define MESH_NORMAL_SPEC_INTERFACE
Definition: MeshNormalSpec.h:33
DllExport void DeleteInterface ( )
virtual
Remarks
This method can be used as a direct interface delete request.
Default Implementation:
{ }

Reimplemented from BaseInterface.

DllExport BaseInterface* GetInterface ( Interface_ID  id)
virtual
Remarks
Returns a pointer to the interface whose ID is specified.
Parameters:
Interface_ID id

The ID of the interface to return.
Default Implementation:
{ return NULL; }

Reimplemented from BaseInterface.

DllExport BaseInterface* CloneInterface ( void remapDir = NULL)
virtual
Remarks
This method allows you to clone the base interface.
Parameters:
void* remapDir

The RemapDir passed to the clone method.
Default Implementation:
{ return NULL; }

Reimplemented from BaseInterface.

DllExport void ShallowCopy ( IPipelineClient from,
ChannelMask  channels 
)
virtual

Implements IPipelineClient.

DllExport void DeepCopy ( IPipelineClient from,
ChannelMask  channels 
)
virtual

Implements IPipelineClient.

DllExport void NewAndCopyChannels ( ChannelMask  channels)
virtual

Implements IPipelineClient.

DllExport void FreeChannels ( ChannelMask  channels,
int  zeroOthers = 1 
)
virtual

Implements IPipelineClient.

DllExport void ZeroChannels ( ChannelMask  channels)
virtual

Implements IPipelineClient.

DllExport void AppendAllChannels ( IPipelineClient from)
virtual

Implements IPipelineClient.

DllExport bool Transform ( Matrix3 xfm,
BOOL  useSel = false,
BitArray normalSelection = NULL 
)
DllExport bool Translate ( Point3 translate,
BOOL  useSel = true,
BitArray normalSelection = NULL 
)
DllExport bool BreakNormals ( BOOL  useSel = true,
BitArray normalSelection = NULL,
BOOL  toAverage = false 
)
DllExport bool UnifyNormals ( BOOL  useSel = true,
BitArray normalSelection = NULL,
BOOL  toAverage = false 
)
DllExport bool AverageNormals ( BOOL  useThresh = false,
float  threshold = 0.0f,
BOOL  useSel = true,
BitArray normalSelection = NULL 
)
DllExport bool SpecifyNormals ( BOOL  useSel = true,
BitArray normalSelection = NULL 
)
DllExport bool MakeNormalsExplicit ( BOOL  useSel = true,
BitArray normalSelection = NULL,
bool  value = true 
)
DllExport bool ResetNormals ( BOOL  useSel = true,
BitArray normalSelection = NULL 
)