iEditNormals.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: iEditNormals.h
00004 
00005     DESCRIPTION:   Edit Normals Modifier SDK Interface
00006 
00007     CREATED BY: Steve Anderson
00008 
00009     HISTORY: created January 2002
00010 
00011  *> Copyright (c) 2002, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 
00015 #include "iFnPub.h"
00016 #include "point3.h"
00017 // forward declarations
00018 class MNMesh;
00019 class MNNormalSpec;
00020 
00021 // Edit Normals Selection Levels - selection is always some set of normals
00022 // (vertex/face selLevels are just rules for hit testing - select normals by vertex, or by face.)
00023 enum editNormalSelLevel
00024 {
00025     EN_SL_OBJECT,
00026     EN_SL_NORMAL,
00027     EN_SL_VERTEX,
00028     EN_SL_EDGE,
00029     EN_SL_FACE
00030 };
00031 
00032 // Edit Normals Parameters:
00033 enum editNormalParameters
00034 {
00035     en_display_length,
00036     en_ignore_backfacing,
00037     en_select_by,
00038     en_show_handles
00039 };
00040 
00041 #define EDIT_NORMALS_MOD_INTERFACE Interface_ID(0x2b572ad6,0x7cf86ae2)
00042 
00043 // "Mixin" Interface methods:
00044 enum editNormalsModMethods { enfn_get_sel_level, enfn_set_sel_level, enfn_move,
00045     enfn_rotate, enfn_break, enfn_unify, enfn_reset, enfn_specify,
00046     enfn_make_explicit, enfn_copy, enfn_paste,
00047     enfn_select, enfn_get_selection, enfn_set_selection,
00048     enfn_convert_vertex_selection, enfn_convert_edge_selection,
00049     enfn_convert_face_selection, enfn_get_num_normals,
00050     enfn_get_num_faces, enfn_get_normal, enfn_set_normal,
00051     enfn_get_normal_explicit, enfn_set_normal_explicit,
00052     enfn_get_face_degree, enfn_get_normal_id, enfn_set_normal_id,
00053     enfn_get_num_vertices, enfn_get_vertex_id, enfn_get_vertex,
00054     enfn_get_num_edges, enfn_get_edge_id, enfn_get_edge_vertex,
00055     enfn_get_face_edge_side, enfn_get_edge_face, enfn_get_edge_normal,
00056     enfn_get_face_normal_specified, enfn_set_face_normal_specified,
00057     enfn_rebuild_normals, enfn_recompute_normals, enfn_average,
00058     enfn_average_global, enfn_average_two };
00059 
00060 // Enum of enums, for methods which accept enum parameters
00061 enum editNormalsModEnums { enprop_sel_level };
00062 
00077 #pragma warning(push)
00078 #pragma warning(disable:4100)
00079 class IEditNormalsMod : public FPMixinInterface
00080 {
00081 public:
00082     #pragma warning(push)
00083     #pragma warning(disable:4238)
00084     BEGIN_FUNCTION_MAP
00085         // Selection Level Access
00086         PROP_FNS(enfn_get_sel_level, EnfnGetSelLevel, enfn_set_sel_level, EnfnSetSelLevel, TYPE_INT);
00087 
00088         // Transforms
00089         FNT_1(enfn_move, TYPE_bool, EnfnMove, TYPE_POINT3_BR);
00090         FNT_1(enfn_rotate, TYPE_bool, EnfnRotate, TYPE_QUAT_BR);
00091 
00092         // Operations
00093         FN_3(enfn_break, TYPE_bool, EnfnBreakNormals, TYPE_BITARRAY, TYPE_INODE, TYPE_bool);
00094         FN_3(enfn_unify, TYPE_bool, EnfnUnifyNormals, TYPE_BITARRAY, TYPE_INODE, TYPE_bool);
00095         FN_2(enfn_reset, TYPE_bool, EnfnResetNormals, TYPE_BITARRAY, TYPE_INODE);
00096         FN_2(enfn_specify, TYPE_bool, EnfnSpecifyNormals, TYPE_BITARRAY, TYPE_INODE);
00097         FN_2(enfn_make_explicit, TYPE_bool, EnfnMakeNormalsExplicit, TYPE_BITARRAY, TYPE_INODE);
00098         FN_2(enfn_copy, TYPE_bool, EnfnCopyNormal, TYPE_INDEX, TYPE_INODE);
00099         FN_2(enfn_paste, TYPE_bool, EnfnPasteNormal, TYPE_BITARRAY, TYPE_INODE);
00100         FN_4(enfn_average, TYPE_bool, EnfnAverageNormals, TYPE_bool, TYPE_FLOAT, TYPE_BITARRAY, TYPE_INODE);
00101         FN_2(enfn_average_global, TYPE_bool, EnfnAverageGlobalNormals, TYPE_bool, TYPE_FLOAT);
00102         FN_4(enfn_average_two, TYPE_bool, EnfnAverageTwoNormals, TYPE_INODE, TYPE_INDEX, TYPE_INODE, TYPE_INDEX);
00103 
00104         // Selection set access
00105         FN_1(enfn_get_selection, TYPE_BITARRAY, EnfnGetSelection, TYPE_INODE);
00106         FN_2(enfn_set_selection, TYPE_bool, EnfnSetSelection, TYPE_BITARRAY_BR, TYPE_INODE);
00107         FN_4(enfn_select, TYPE_bool, EnfnSelect, TYPE_BITARRAY_BR, TYPE_bool, TYPE_bool, TYPE_INODE);
00108         VFN_3(enfn_convert_vertex_selection, EnfnConvertVertexSelection, TYPE_BITARRAY_BR, TYPE_BITARRAY_BR, TYPE_INODE);
00109         VFN_3(enfn_convert_edge_selection, EnfnConvertEdgeSelection, TYPE_BITARRAY_BR, TYPE_BITARRAY_BR, TYPE_INODE);
00110         VFN_3(enfn_convert_face_selection, EnfnConvertFaceSelection, TYPE_BITARRAY_BR, TYPE_BITARRAY_BR, TYPE_INODE);
00111 
00112         // Normal access
00113         FN_1(enfn_get_num_normals, TYPE_INT, EnfnGetNumNormals, TYPE_INODE);
00114         FNT_2(enfn_get_normal, TYPE_POINT3, EnfnGetNormal, TYPE_INDEX, TYPE_INODE);
00115         VFNT_3(enfn_set_normal, EnfnSetNormal, TYPE_INDEX, TYPE_POINT3_BR, TYPE_INODE);
00116         FN_2(enfn_get_normal_explicit, TYPE_bool, EnfnGetNormalExplicit, TYPE_INDEX, TYPE_INODE);
00117         VFN_3(enfn_set_normal_explicit, EnfnSetNormalExplicit, TYPE_INDEX, TYPE_bool, TYPE_INODE);
00118 
00119         // Normal face access
00120         FN_1(enfn_get_num_faces, TYPE_INT, EnfnGetNumFaces, TYPE_INODE);
00121         FN_2(enfn_get_face_degree, TYPE_INT, EnfnGetFaceDegree, TYPE_INDEX, TYPE_INODE);
00122         FN_3(enfn_get_normal_id, TYPE_INDEX, EnfnGetNormalID, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00123         VFN_4(enfn_set_normal_id, EnfnSetNormalID, TYPE_INDEX, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00124         FN_3(enfn_get_face_normal_specified, TYPE_bool, EnfnGetFaceNormalSpecified, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00125         VFN_4(enfn_set_face_normal_specified, EnfnSetFaceNormalSpecified, TYPE_INDEX, TYPE_INDEX, TYPE_bool, TYPE_INODE);
00126 
00127         // Vertex access
00128         FN_1(enfn_get_num_vertices, TYPE_INT, EnfnGetNumVertices, TYPE_INODE);
00129         FN_3(enfn_get_vertex_id, TYPE_INDEX, EnfnGetVertexID, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00130         FNT_2(enfn_get_vertex, TYPE_POINT3_BV, EnfnGetVertex, TYPE_INDEX, TYPE_INODE);
00131 
00132         // Edge access
00133         FN_1(enfn_get_num_edges, TYPE_INT, EnfnGetNumEdges, TYPE_INODE);
00134         FN_3(enfn_get_edge_id, TYPE_INDEX, EnfnGetEdgeID, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00135         FN_3(enfn_get_face_edge_side, TYPE_INDEX, EnfnGetFaceEdgeSide, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00136         FN_3(enfn_get_edge_vertex, TYPE_INDEX, EnfnGetEdgeVertex, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00137         FN_3(enfn_get_edge_face, TYPE_INDEX, EnfnGetEdgeFace, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00138         FN_4(enfn_get_edge_normal, TYPE_INDEX, EnfnGetEdgeNormal, TYPE_INDEX, TYPE_INDEX, TYPE_INDEX, TYPE_INODE);
00139 
00140         // Cache rebuilders - shouldn't normally be necessary - above methods do this work as needed.
00141         VFN_1(enfn_rebuild_normals, EnfnRebuildNormals, TYPE_INODE);
00142         VFN_1(enfn_recompute_normals, EnfnRecomputeNormals, TYPE_INODE);
00143     END_FUNCTION_MAP
00144     #pragma warning(pop)
00145 
00146     FPInterfaceDesc *GetDesc ();
00147 
00148     // Selection level accessors:
00153     virtual int EnfnGetSelLevel () { return EN_SL_OBJECT; }
00158     virtual void EnfnSetSelLevel (int selLevel) { }
00159 
00160     // Transform commands:
00166     virtual bool EnfnMove (Point3& offset, TimeValue t) { return false; }
00172     virtual bool EnfnRotate (Quat & rotation, TimeValue t) { return false; }
00173 
00174     // Operations:
00211     virtual bool EnfnBreakNormals (BitArray *normalSelection=NULL, INode *pNode=NULL, bool toAverage=false) { return false; }
00233     virtual bool EnfnUnifyNormals (BitArray *normalSelection=NULL, INode *pNode=NULL, bool toAverage=false) { return false; }
00250     virtual bool EnfnResetNormals (BitArray *normalSelection=NULL, INode *pNode=NULL) { return false; }
00265     virtual bool EnfnSpecifyNormals (BitArray *normalSelection=NULL, INode *pNode=NULL) { return false; }
00280     virtual bool EnfnMakeNormalsExplicit (BitArray *normalSelection=NULL, INode *pNode=NULL) { return false; }
00294     virtual bool EnfnCopyNormal (int normalID, INode *pNode=NULL) { return false; }
00310     virtual bool EnfnPasteNormal (BitArray *normalSelection=NULL, INode *pNode=NULL) { return false; }
00318     virtual bool EnfnAverageNormals (bool useThresh=false, float threshold=0.0f, BitArray *normalSelection=NULL, INode *pNode=NULL) { return false; }
00323     virtual bool EnfnAverageGlobalNormals (bool useThresh=false, float threshold=0.0f) { return false; }
00331     virtual bool EnfnAverageTwoNormals (INode *pNode1, int normID1, INode *pNode2, int normID2) { return false; }
00332 
00333     // Selection accessors
00344     virtual BitArray *EnfnGetSelection (INode *pNode=NULL) { return NULL; }
00360     virtual bool EnfnSetSelection (BitArray & selection, INode *pNode=NULL) { return false; }
00382     virtual bool EnfnSelect (BitArray & selection, bool invert=false, bool select=true, INode *pNode=NULL) { return false; }
00400     virtual void EnfnConvertVertexSelection (BitArray & vertexSelection, BitArray & normalSelection, INode *pNode=NULL) { }
00417     virtual void EnfnConvertEdgeSelection (BitArray & edgeSelection, BitArray & normalSelection, INode *pNode=NULL) { }
00433     virtual void EnfnConvertFaceSelection (BitArray & faceSelection, BitArray & normalSelection, INode *pNode=NULL) { }
00434 
00435     // Accessors for the normals:
00446     virtual int EnfnGetNumNormals (INode *pNode=NULL) { return 0; }
00447     // Direct access to the normals themselves:
00463     virtual Point3 *EnfnGetNormal (int normalID, INode *pNode=NULL, TimeValue t=0) { return NULL; }
00487     virtual void EnfnSetNormal (int normalID, Point3 &direction, INode *pNode=NULL, TimeValue t=0) { }
00488     // Control whether a given normal is built from smoothing groups or set to an explicit value
00503     virtual bool EnfnGetNormalExplicit (int normID, INode *pNode=NULL) { return false; }
00504     // (Also makes the normal specified for all faces using this normal.)
00523     virtual void EnfnSetNormalExplicit (int normID, bool value, INode *pNode=NULL) { }
00524 
00525     // Normals can be used by multiple faces, even at different vertices.
00526     // So we require access to both face and normal information.
00527     // Access to the normals that are assigned to each face:
00539     virtual int EnfnGetNumFaces (INode *pNode=NULL) { return 0; }
00552     virtual int EnfnGetFaceDegree (int face, INode *pNode=NULL) { return 0; }
00568     virtual int EnfnGetNormalID (int face, int corner, INode *pNode=NULL) { return 0; }
00587     virtual void EnfnSetNormalID (int face, int corner, int normalID, INode *pNode=NULL) { }
00588 
00589     // Control whether a corner of a face uses an specified normal ID, or builds normals based on smoothing groups.
00606     virtual bool EnfnGetFaceNormalSpecified (int face, int corner, INode *pNode=NULL) { return false; }
00628     virtual void EnfnSetFaceNormalSpecified (int face, int corner, bool specified, INode *pNode=NULL) { }
00629 
00630     // Access to vertices - often important for proper normal handling to have access to the vertex the normal is based on.
00643     virtual int EnfnGetNumVertices (INode *pNode=NULL) {return 0; }
00662     virtual int EnfnGetVertexID (int face, int corner, INode *pNode=NULL) { return 0; }
00680     virtual Point3 EnfnGetVertex (int vertexID, INode *pNode=NULL, TimeValue t=0) { return Point3(0,0,0); }
00681 
00682     // Access to edges
00695     virtual int EnfnGetNumEdges (INode *pNode=NULL) { return 0; }
00712     virtual int EnfnGetEdgeID (int faceIndex, int sideIndex, INode *pNode=NULL) { return 0; }
00734     virtual int EnfnGetFaceEdgeSide (int faceIndex, int edgeIndex, INode *pNode=NULL) { return 0; }
00750     virtual int EnfnGetEdgeVertex (int edgeIndex, int end, INode *pNode=NULL) { return 0; }
00771     virtual int EnfnGetEdgeFace (int edgeIndex, int side, INode *pNode=NULL) { return 0; }
00793     virtual int EnfnGetEdgeNormal (int edgeIndex, int end, int side, INode *pNode=NULL) { return 0; }
00794 
00795     // Rebuild all non-specified normals from smoothing groups
00796     // Note that this can change the number of normals in some cases, and often changes their order.
00810     virtual void EnfnRebuildNormals (INode *pNode=NULL) { }
00811     // Recompute - computes nonexplicit normals from face normals.
00824     virtual void EnfnRecomputeNormals (INode *pNode=NULL) { }
00825 
00826     // Direct accessors to MNMesh and MNNormalSpec classes - unpublished for now.
00845     virtual MNMesh *EnfnGetMesh (INode *pNode=NULL, TimeValue t=0) { return NULL; }
00866     virtual MNNormalSpec *EnfnGetNormals (INode *pNode=NULL, TimeValue t=0) { return NULL; }
00867 };
00868 #pragma warning(pop) // C4100
00869 
00870