Class IUnwrapMod2

3DS Max Plug-In SDK

Class IUnwrapMod2

Description:

This class is only available in release 5 or later.

 

The new class allows for Normal, Flatten, and Unfold mapping. You can bring them up through a dialog or through a script command. All these tools basically work the same. They are either applied to the current selected faces or the whole object if no faces are selected.

As this class has been fully developed with the new Function-Published System (FPS), all of its methods have a one-to-one correspondence with MaxScript commands. For the sake of brevity, references to MaxScript commands mean that there is an attendant C++ method in iunwrap.h that is prepended by lowercase fn. Examples of this are as follows ( MaxScript and its attendant C++ method):

 

copy fpCopy();

normalMapNoParams fnNormalMapNoParams().

 

 

There are three distinct modes of unmapping:

 

Normal Mapping

Normal Mapping is mapping based solely are the normals provided. This is identically to box mapping except you customize what normals you want to project on. There are three methods to apply a "normalMap" which applies a normal map based on the parameters passed in (see the methods below) , "normalMapNoParams" which applies a normal map using the default setting, and "normalMapDialog" which brings up a dialog that lets you set the setting. Right now there are 6 types of default mapping Back/Front, Left/Right, Top/Bottom, Box Mapping No Top, Box Mapping, and Diamond mapping. Just apply the mapping to a teapot to see the differences they are pretty obvious once you see the effect. Parameters in the Normal Mapping dialog are:

 

  • Mapping Type which are the 6 mapping types listed above.

  • Spacing which determines how much space there is between each cluster.

  • Normalize Cluster will normalize the cluster from 0 to 1

  • Rotate Clusters will rotate the clusters so they take the least amount of area.

  • Align By Width will sort the clusters by there width otherwise it will use their heights.

 

Hitting the Save As Default will take the current setting and set them as defaults for the next time you bring up the dialog and when you use the script command "normalMapNoParams”.

Flatten Mapping

Flatten Mapping is similar to normal mapping, except it uses an angle threshold to define the clusters and the clusters will always be contiguous faces. This type of mapping will generate mapping that does not overlap so it is useful for baking textures and lighting. Just like normal mapping this comes in 3 flavors "flattenMap" which applies a normal map based on the parameters passed in (see the methods below) , "flattenMapNoParams" which applies a map using the default setting, and "flattenMapDialog" which brings up a dialog that lets you set the setting. The parameters for the Flatten Map Dialog are:

Face Angle Threshold - when building contiguous faces this the angle used to determine whether a face is part of that cluster. The larger this angle the larger the cluster will be, but you will get more distortion since the texture faces area will start deviating from there geometric face area.  

  • Spacing which determines how much space there is between each cluster.

  • Normalize Cluster will normalize the cluster from 0 to 1

  • Rotate Clusters will rotate the clusters so they take the least amount of area.

  • Fill Holes will fill clusters with holes. It places smaller cluster in the gaps of larger clusters.

 

Unfold Mapping

Unfold Mapping where as the Normal and Flatten Mapping basically use a lot of planar mapping to get their results, this is an actual unfolding algorithm. It guarantees that all texture faces will have the exact same proportions as their geometric equivalents, but you may get faces that overlap. This type of mapping is only good on meshes that are very regular things like cylinders etc. This has the same type of function calls as the above "unfoldMap" which applies an unfold map based on the parameters passed in (see the methods below) , "unfoldMapNoParams" which applies a map using the default setting, and "unfoldMapDialog" which brings up a dialog that lets you set the setting. The parameters for the Unfold Map Dialog are:

  • Unfold Type which consists of Walk to closest face and Walk to farthest face. This determines the order of which face gets unfolded. Under almost all conditions you want to walk to the closest face.

  • Normalize Cluster will normalize the cluster from 0 to 1

 

 

Copy/Paste allows you to copy a texture face/faces from one part or mesh to another or to a new mesh. These functions are extremely topology dependant so if you copy faces onto faces that have a different topology or face order you will get unpredictable results. There is a "copy" script which takes the current selected faces and puts them in the copy buffer. There is the "Paste" and "PasteInstance" commands which do the pasting to current selected faces. "Paste" take one parameter called rotate which determines if every time you paste to the same face whether the tvs are reoriented. For instance if you paste a quad onto a another quad there are actually 4 possible ways you can paste it onto it. If rotate is on, every time you paste it will go onto the next variation. "Paste Instance" forces the faces that are being pastes to use the vertices that the copy buffer use (NOTE you cannot paste instance across objects). This similar to doing a regular paste and then selecting all the overlapping vertices and doing a weld. There is no rotate option with this method. As noted above Pasting faces that have a different topology or face order will result in unpredictable results.

 

Stitching allows you find all the texture vertices that are assigned to the same geometric vertex and bring them all to the same spot and weld them together. This allows you take faces that geometrically contiguous, but not texture face contiguous and line them up. There is a stitchVerts command which takes parameters, stitchVertsNoParams which uses the current defaults, and a stitchVertsDialog which brings up a dialog to apply a stitch and set defaults. The Stitch Tool params are:

 

  • Align Cluster which if checked and the edges to be stitched are on separate clusters it will try to align the clusters and then stitch the vertices.

  • Bias determines which direction the vertices will move (to or from the source). At a Bias of 0.0 the vertices will move to the source and 1.0 they will move to the target.

 

Note stitching will respect the soft selection.

 

 

Methods:

Nb: the following are MaxScript commands, however, referring to the above qualifier, their C++ method name is the same as in MaxScript but prepended with fn.

 

The format for input/output parameters is as follows:

<output type> <name of function> <input type params 1…n>

 

copy - this takes the selected faces and places them in the copy buffer

paste

rotate TYPE_BOOL if this on, every time you paste to the same selection it will try a different variation

This paste the current copy buffer onto the current face selection.

pasteInstance this forces the faces that are being pastes to use the vertices that the copy buffer use (NOTE you cannot paste instance across objects). This similar to doing a regular paste and then selecting all the overlapping vertices and doing a weld. There is no rotate option with this method.

 

SetDebugLevel

level TYPE_INT level of debug info 0 means no debug info, the higher the value the more spam you will see in your script window

Debugging tool so I can control the amount of debug info that goes to the listener and script window.

 

TYPE_BOOL getTileMap - returns whether the background is tiled.

 

setTileMap

tile TYPE_BOOL - whether or not to tile the background

This allows you set the tile state of the background

 

TYPE_INT getTileMapLimit - returns the max number of tiles to use in a direction

 

setTileMapLimit

limit TYPE_INT - the number of tile to limit in a direction

This allows you to set the tile limit

 

TYPE_FLOAT getTileMapBrightness returns the brightness of the tiles.

 

setTileMapBrightness brightness

TYPE_FLOAT - the brightness of the tiled maps

This allows you to set the brightness of the tiled maps

 

New Maxscript funtions

TYPE_BOOL getShowMap returns the state of the show map button

 

TYPE_VOID setShowMap

showMap TYPE_BOOL the state you want to set the show map button 

Lets you set the state of the show map button 

 

 

 

TYPE_BOOL getLimitSoftSel returns whether the soft selection limit is on/off

 

SetLimitSoftSel

limit TYPE_BOOL state the to set the soft selection limit

Allows you to set the soft selection limit state

 

TYPE_INT getLimitSoftSelRange returns the edge limit for the for the soft selection

 

setLimitSoftSelRange

range TYPE_INT this is how far out in edges that soft selection will expand to

This lets you set the edge limit range for soft selection

 

TYPE_FLOAT getVertexWeight

 index TYPE_INT the index of the vertex you want to inspect

 returns the soft selection weight of a particular vertex

 

setVertexWeight

 index TYPE_INT the index of the vertex you want to change

weight TYPE_FLOAT the soft selection weight you want to set the vertex to

This lets you set the soft selection weight of a particular vertex. Note once you set the weight of a vertex, it is tagged as being modified and will not change value unless you unmodifiy or call setVertexWeight on it again.

 

TYPE_BOOL isWeightModified

 index TYPE_INT the index of the vertex you want to inspect

 This returns whether a vertex is modified or not.

 

modifyWeight

 index TYPE_INT the index of the vertex you want to change

modify TYPE_BOOL the modified state of the vertex

This lets you set the modified state of vertex. If a vertex is modified it ignores regular UI soft selection and the vertex soft selection weight is locked to it current state and can only be changed by the setVertexWeight method.

 

TYPE_BOOL getGeomSelectElementMode returns whether you are in element mode for face

selection in the viewport.

 

setGeomSelectElementMode

mode TYPE_BOOL - the state that you want to put viewport selection in

Lets you set the viewport element mode.

 

TYPE_BOOL getGeomPlanarThresholdMode return the whether you are in planar select mode.

 

setGeomPlanarThresholdMode

mode TYPE_BOOL the state that you want to put planar selection mode

Lets set the planar selection mode.

 

TYPE_FLOAT getGeomPlanarThreshold return the planar selection angle threshold

 

setGeomPlanarThreshold

angle TYPE_FLOAT the angle threshold

Lets you set the angle threshold for the planar selection mode.

 

TYPE_INT getWindowX returns the current X position of the Unwrap Edit window

 

TYPE_INT getWindowY returns the current Y position of the Unwrap Edit window

 

TYPE_INT getWindowW returns the current width of the Unwrap Edit window

 

TYPE_INT getWindowH returns the current height of the Unwrap Edit window

 

TYPE_BOOL getIgnoreBackFaceCull returns the state of the Ignore Back Face mode

 

setIgnoreBackFaceCull

 ignoreBackFaceCull TYPE_BOOL state of the Ignore Back Faces mode

 Lets you set the Ignore Back Face mode

 

TYPE_BOOL getOldSelMethod returns whether the system is in the old selection mode. Where drag selection always uses back faces and single pick mode ignore back faces.

 

SetOldSelMethod

oldSelMethod TYPE_BOOL the state of the old selection method

This lets you set the system back to the old selection method. Where drag selection always uses back faces and single pick mode ignore back faces.

This will override the Ignore Back Faces mode.

 

SelectByMatID

matID TYPE_INT the matID of the face that you want to select

This lets you select faces by material ids.

 

selectBySG

sg TYPE_INT the smoothing group that you want to select

This lets you select faces by smoothing group

 

TYPE_VOID expandGeomFaceSelection - expands your current viewport face selection

 

TYPE_VOID contractGeomFaceSelection - contracts your current viewport face selection

 

TYPE_BOOL getAlwaysEdit - This returns whether the always edit mode is on. This mode will always bring up the edit dialog when the Unwrap rollup window is displayed.

 

TYPE_VOID setAlwaysEdit

always TYPE_BOOL the state that you want to set the always edit mode to.

This lets you set the always edit mode. This mode will always bring up the edit dialog when the Unwrap rollup window is displayed.

 

TYPE_BOOL getShowVertexConnections this returns whether vertex connection indices are displayed. Vertex Connections are TV vertices that share the same geometric vertices

 

TYPE_VOID setShowVertexConnections

show TYPE_BOOL whether to display the vertex connection data.

This lets you toggle the vertex connection data.

 

TYPE_BOOL getFilterSelected this returns the state of the Filter Selected Faces button

 

TYPE_VOID setFilterSelected

filter TYPE_BOOL the filter state

This lets you set the Filter Selected Faces button

 

TYPE_BOOL getSnap this returns the snap state.

 

TYPE_VOID setSnap

snap TYPE_BOOL the snap state

This lets you set the snap state.

 

TYPE_BOOL getLock this returns the lock selection state

 

TYPE_VOID setLock

lock TYPE_BOOL state of the lock selection.

This lets you set the state of the lock selection

 

TYPE_VOID pack

method TYPE_INT - 0 is a linear packing algorithm fast but not that efficient, 1 is a recursive algorithm slower but more efficient.

spacing TYPE_FLOAT - the gap between cluster in percentage of the edge distance of the square

normalize TYPE_BOOL - whether the clusters will be fit to 0 to 1 space.

rotate TYPE_BOOL - whether a cluster will be rotated so it takes up less space.

fillholes TYPE_BOOL - whether smaller clusters will be put in the holes of the larger cluster.

This lets you pack the texture vertex elements so that they fit within a square space.

 

TYPE_VOID packNoParams - this packs the clusters using the default parameters.

 

TYPE_VOID packDialog - this brings up a dialog that lets the user set the parameters and then packs the clusters.

 

TYPE_INT getTVSubObjectMode sets the current texture subobject mode 1 vertices, 2 edges, 3 faces.

 

TYPE_VOID setTVSubObjectMode

mode TYPE_INT - the subobject mode 1 vertices, 2 edges, 3 faces.

Lets you set the tv subobject mode.

 

TYPE_BITARRAY getSelectedFaces returns the selected face list

 

TYPE_VOID selectFaces

Selection TYPE_BITARRAY selection that you want to make the face selection

This lets you set the face selection

 

TYPE_BOOL IsFaceSelected

Index TYPE_INT the index of the face you want to check

This lets you check to see if a face is selected.

 

TYPE_INT getFillMode - returns the fill mode type for face selections. The fill modes are as follows.

FILL_MODE_OFF   1

FILL_MODE_SOLID   2

FILL_MODE_BDIAGONAL  3

FILL_MODE_CROSS  4

FILL_MODE_DIAGCROSS  5

FILL_MODE_FDIAGONAL  6

FILL_MODE_HORIZONAL  7

FILL_MODE_VERTICAL  8

 

TYPE_VOID setFillMode

mode TYPE_INT - the fill mode that you want to set

This lets you set the fill mode for selected faces.

 

MoveSelected, RotateSelected, RotateSelectedCenter, ScaleSelectedCenter, and ScaleSelected are identical to there vertex counter parts but are applied to the current selection.

TYPE_VOID MoveSelected

Offset TYPE_POINT3

TYPE_VOID RotateSelectedCenter

Angle TYPE_FLOAT

TYPE_VOID RotateSelected

Angle TYPE_FLOAT

Axis TYPE_POINT3

TYPE_VOID ScaleSelectedCenter

Scale TYPE_FLOAT

Dir TYPE_INT

TYPE_VOID ScaleSelected

Scale TYPE_FLOAT

Dir TYPE_INT

Axis TYPE_POINT3

 

TYPE_BITARRAY getSelectedEdges returns the selected edge list

 

TYPE_VOID selectEdges

Selection TYPE_BITARRAY selection that you want to make the edge selection

This lets you set the edge selection

 

TYPE_BOOL IsEdgeSelected

Index TYPE_INT the index of the edge you want to check

This lets you check to see if a face is selected.

 

TYPE_BOOL getDisplayOpenEdges returns whethe open edges will display

 

TYPE_VOID setDisplayOpenEdges

displayOpenEdges TYPE_BOOL the state of the open edge display

This lets you set the open edge display

 

TYPE_POINT3 getOpenEdgeColor returns the color used for the open edges

 

TYPE_VOID setOpenEdgeColor

color TYPE_POINT3 the color to be used for open edges

This lets you set the open edge color

 

TYPE_BOOL getUVEdgeMode returns whether you are in the UV Edge Selection mode. This mode will try to automatically select all the U or V edges when you select an edge. Since this is based on edges, the regular tri mesh may produce incorrect results since the hidden edges are not taken into account.

 

TYPE_VOID setUVEdgeMode

uvEdgeMode TYPE_BOOL the state of the you want to set the UV Edge mode

 This lets you set the UV Edge mode

 

TYPE_VOID uvEdgeSelect - this is a command that will take your current edge selection and try to expand out along the U and V directions. Works best when you only have one edge selected.

 

TYPE_BOOL getOpenEdgeMode returns whether you are in the Open Edge Selection mode. This mode will try to automatically select all the opens edges when you select an open edge.

 

TYPE_VOID setOpenEdgeMode

uvOpenMode TYPE_BOOL the state of the you want to set the Open Edge mode

 This lets you set the Open Edge mode

 

TYPE_VOID openEdgeSelect - this is a command that will take your current selection and try to expand all the open edges in it.

 

TYPE_VOID vertToEdgeSelect - this command takes your vertex selection and converts it to the edge selection.

 

TYPE_VOID vertToFaceSelect - this command takes your vertex selection and converts it to the face selection.

 

TYPE_VOID edgeToVertSelect - this command takes your edge selection and converts it to the vertex selection.

 

TYPE_VOID edgeToFaceSelect - this command takes your edge selection and converts it to the face selection.

 

TYPE_VOID faceToVertSelect - this command takes your face selection and converts it to the vertex selection.

 

TYPE_VOID faceToEdgeSelect - this command takes your face selection and converts it to the edge selection.

 

TYPE_BOOL getDisplayHiddenEdges return whether hidden edges of a tri mesh are displayed.

 

TYPE_VOID setDisplayHiddenEdges

displayHiddenEdges TYPE_BOOL - the state that you want to the hidden display to be.

This lets you turn on/off whether tri mesh hidden edges are displayed.

 

TYPE_POINT3 getHandleColor - returns the color that will be used to display patch handles.

 

TYPE_VOID setHandleColor

color TYPE_POINT3 - the color that you want to set patch handles to

This lets you set the color that will be used to display patch handles.

 

TYPE_BOOL getFreeFormMode this toggle the free form mode on and off. This mode is similar to the Photoshops free form mode. You select any where inside the bounding rectangle to move the selection. You select the corners to scale the selection, and you you select the edge centers to rotate the selection. You can also move the center cross which is your rotation pivot point.

 

TYPE_VOID setFreeFormMode

freeFormMode TYPE_BOOL the state of the free form mode.

Lets you turn on/off the free from mode.

 

TYPE_POINT3 getFreeFormColor returns the color of the free form gizmo.

 

TYPE_VOID setFreeFormColor

color TYPE_POINT3 the color that you want the gizmo to be

 This lets you set the color of the Free Form Gizmo

 

TYPE_VOID ScaleSelectedXY

ScaleX TYPE_FLOAT the x scale factor

ScaleY TYPE_FLOAT the y scale factor

Axis TYPE_POINT3 the axis to scale around

This lets you nu scale the current selection around an axis

 

TYPE_VOID SnapPivot

Pos TYPE_INT - the pivot position where

 1 is the center

 2 is the lower left of the selection

 3 is the lower center of the selection

 4 is the lower right of the selection

 5 is the right center of the selection

 6 is the upper right of the selection

 7 is the upper center of the selection

 8 is the upper left of the selection

 9 is the left center of the selection

This lets you quickly snap the free form gizmo pivot the bounding rectangle.

 

 

TYPE_POINT3 getPivotOffset - returns the pivot offset of the free form gizmo. This is an offset from the center of the selection.

 

TYPE_VOID setPivotOffset

offset TYPE_POINT3 the offset of the free form gizmo pivot

This lets you set the offset of the free form gizmo pivot.

 

TYPE_POINT3 fnGetSelCenter this returns the selection center so you can compute the pivot offset from a world uv position.

 

TYPE_BOOL getPolygonMode

This returns whether the polygon mode for sub object face mode is on. Polygon Mode will just select across triangles across hidden edges of a triangle.

 

TYPE_VOID setPolygonMode

mode TYPE_BOOL the state you want to set the Polygon Mode

This lets you set the state the of the Polygon Mode

 

TYPE_VOID PolygonSelect

This is command that will take your current selection and expand it to include all polygons.

 

TYPE_VOID sketch

IndexList TYPE_INT_TAB the indices of the points you want to move.

PositionList TYPE_POINT3_TAB the list of a points you want to align your vertices to.

This lets you align texture vertices to a series of points

 

TYPE_VOID sketchNoParams

 This puts you in sketch mode using the default parameters.

 

TYPE_VOID sketchDialog

 This brings up the sketch options dialog.

 

TYPE_VOID sketchReverse

 This will reverse the order of the select vertices that are being used for sketch  when you use the Use Current Selection option.

 

TYPE_INT getHitSize

This returns the hit size whne you do a single click in pixels.

 

TYPE_VOID SetHitSize

size TYPE_INT the size you want to set the hit size to

This lets you set the hit size of a single click.

 

TYPE_BOOL getResetPivotOnSelection

This will return whether the Transform Gizmo will reset when the selection is changed.

 

TYPE_VOID SetResetPivotOnSelection

reset TYPE_BOOL the state you want to set the reset pivot on selection

This lets you set the Reset the Pivot On Selection.

    

TYPE_BOOL getAllowSelectionInsideGizmo

This returns whether a user can select sub objects inside the gizmo or not. If this is FALSE the user is in move mode when inside the gizmo unless they are over the pivot. If this is TRUE the user is in move mode when they are inside and over a selected sub object otherwise they are in select mode.

 

TYPE_VOID Set AllowSelectionInsideGizmo

select TYPE_BOOL - the state you want to set the Allow Selection Inside Gizmo to be

This lets you set the Allow Selection Inside Gizmo flag

 

TYPE_VOID SaveCurrentSettingsAsDefault

This takes the current state of Unwrap UVW and save it to the plugin cfg directory into a file called unwrapUVW.ini. The next time the user creates an Unwrap UVW modifier this ini file will be used to set the defaults.

 

TYPE_VOID LoadDefault

 This will load the unwrapUVW.ini defaults into the current Unwrap UVW modifier.

 

TYPE_BOOL getShowShared

This returns whether shared sub objects are displayed. Shared sub objects are texture vertices or edges that share the same geometric vertex or edge.

 

TYPE_VOID setShowShared

select TYPE_BOOL whether to display shared sub objects or not.

This lets you toggle the Show Shared flag.

 

TYPE_POINT3 getSharedColor

 This returns the color that will be used to show shared sub objects.

 

TYPE_VOID setSharedColor

color TYPE_POINT3 the color to be used for shared sub objects

This lets you set the color to be used for shared sub objects.

 

TYPE_VOID showIcon

index TYPE_INT index of the icon to be display/hidden. The icons are as follows:

 1 - Move Mode

 2 - Rotate Mode

 3 - Scale Mode

 4 - Transform Mode

 5 - Mirror Tool

 6 - Expand Selection

 7 - Contract Selection

 8 - Soft Selection Falloff

 9 - Soft Selection Space

 10 - Soft Selection Strength

 11 - Break

 12 - Target Weld

 13 - Weld Selected

 14 - Update Map

 15 - Show Map

 16 - UV/VW/UW space

 17 - Properties Dialog

 18 - Map Drop List

 19 - U Spinner

 20 - V Spinner

 21 - W Spinner

 22 - Lock Sub Object

 23 - Hide/Show

 24 - Freeze/Thaw

 25 - Filter Selected

 26 - Mat Ids

 27 - Pan Mode

 28 - Zoom Mode

 29 - Zoom Region Mode

 30 - Fit Command

 31 - Snap

show TYPE_BOOL whether to show or hide this icon

This lets you turn on/off icons in the Unwrap UVW Edit dialog

 

TYPE_BOOL getSyncSelectionMode

Returns whether the viewport and the dialog selections are synced 

 

TYPE_VOID setSyncSelectionMode

sync TYPE_BOOL 

Lets you set whether the viewport and the dialog selections are synced 

 

TYPE_VOID syncTVSelection

This is a commmand the synces the dialog to the viewport 

 

TYPE_VOID syncGeomSelection

This is a commmand the synces the viewport to the dialog 

 

TYPE_POINT3 getBackgroundColor

returns the color of the background in the dialog 

 

TYPE_VOID setBackgroundColor

color TYPE_POINT3 

Lets you set the color of the background in the dialog 

 

TYPE_VOID updateMenuBar

Forces the menu bar to update 

 

TYPE_BOOL getBrightnessAffectsCenterTile

This returns whether the brightness value affects the center tile 

 

TYPE_VOID setBrightnessAffectsCenterTile

bright TYPE_BOOL 

This lets you set whether the brightness value affects the center tile 

 

TYPE_BOOL getBlendTileToBackground

This returns whether the tiled images are blended to the background color or black 

 

TYPE_VOID setBlendTileToBackground

blend TYPE_BOOL, 

This lets you set whether the tiled images are blended to the background color or black 

 

TYPE_BOOL getPaintSelectMode

This returns whether you are in paint select mode 

 

TYPE_VOID setPaintSelectMode

paint TYPE_BOOL, 

This lets you set whether you are in paint select mode 

 

TYPE_INT getPaintSelectSize

Returns the size of the paint select brush this is clamped between 1 and 15. 

 

TYPE_VOID setPaintSelectSize

size TYPE_INT 

This lets you set the size of the paint select brush this is clamped between 1 and 15. 

 

TYPE_VOID PaintSelectIncSize

This increments the brush size by one 

 

TYPE_VOID PaintSelectDecSize

This decrements the brush size by one 

 

TYPE_INT GetTickSize

 Returns the size of a selected vertex tick

 

TYPE_VOID SetTickSize

size TYPE_INT size of the tick

This lets you set the size of a vertex tick