Interface: simpleFaceManager

new.gif NEW in 3ds Max 9: This Interface provides basic Per-Face data storage abilities.

 

Methods:

<Interface>addChannel <object>object type:<enum> id:<DWORD array> name:<string>

object Validated by Validator function

type enums: {#integer|#index|#float|#boolean|#point2|#point3}

type default value: #integer

id default value: #()

id Validated by Validator function

name default value: undefined

Adds a new per-face data channel to the specified object of the given type using a user-defined ID and name.

The ID can be generated using the genClassID() method and has the same form as the class IDs of scripted plug-ins.

For example:

obj = Plane length:60.0 width:60.0 widthsegs: 1 lengthsegs: 2

convertto obj Editable_Poly

idA = genClassID returnValue:true

channelA = simpleFaceManager.AddChannel obj type: #integer id:idA

channelA.name = "The Integer Channel"

channelA.SetValues #(5,2)

idB = genClassID returnValue:true

channelB = simpleFaceManager.AddChannel obj type: #float id:idB

channelB.name = "The Float Channel"

channelB.SetValues #(3.1459,7.236)

 

<void>removeChannel <object>object <DWORD array>id

id Validated by Validator function

Removes the channel with the specified ID from the given object.

<Interface>getChannel <object>object <DWORD array>id

object Validated by Validator function

id Validated by Validator function

Returns the simpleFaceChannel MixinInterface of the channel with the specified ID from the given object.

For example:

--continuing from the previous example on this page:

theInt = simpleFaceManager.getChannel obj idA

 

<Interface by value array>getChannels <object>object

object Validated by Validator function

Returns an array of simpleFaceChannel MixinInterface of all channels in the given object.

For example:

--continuing from the previous example on this page:

SimpleFaceManager.getChannels obj

#(<MixinInterface:simpleFaceChannel>, <MixinInterface:simpleFaceChannel>)

 

Interface: simpleFaceChannel

new.gif NEW in 3ds Max 9: This MixinInterface is exposed by the SimpleFaceData class and provides access to the Per-Face data in a specific channel.

Properties:

.name : string : Read|Write

Get/set the name of the data channel.

.id : DWORD by value array : Read

Get the unique ID of the channel.

.type : enum : Read

type enums: {#integer|#index|#float|#boolean|#point2|#point3}

Get the type of the data stored in the channel.

.numFaces : DWORD : Read

Get the number of faces or polygons in the channel.

 

For example:

--continuing from the previous example on this page:

theInt = simpleFaceManager.getChannel obj idA

<MixinInterface:simpleFaceChannel>

theInt.name

"The Integer Channel"

theInt.type

#integer

theInt.numfaces

2

 

Methods:

<fpvalue by value>getValue <index>face

face Validated by Validator function

Get the value of the indexed face.

For example:

--continuing from the previous example:

theInt.getValue 1

5

theInt.getValue 2

2

theInt.getValue 3

-- Runtime error: Invalid face index.

 

<boolean>setValue <index>face <value>value

face Validated by Validator function

value Validated by Validator function

Set the value of the indexed face.

For example:

--continuing from the previous example:

theInt.setValue 1 6

true

 

<fpvalue by value>getValues()

Get all the values of the channel.

For example:

--continuing from the previous example:

theInt.getValues()

#(6, 2)

 

<boolean>setValues <value>values

values Validated by Validator function

Set all the values of the channel to the values in the specified array.

For example:

--continuing from the previous example:

theInt.setValues #(10,12)

true

theInt.getValues()

#(10, 12)

 

<fpvalue by value>getValueBySelection <bitArray>faces

faces Validated by Validator function

Get the values of the faces specified by the set bits of the bitArray argument. If all specified faces contain the same value, that value will be returned. If the specified faces contain different values, the return value will be undefined.

For example:

--continuing from the previous example:

theInt.getValueBySelection #{1}

10

theInt.getValueBySelection #{1..2}

undefined

 

<boolean>setValueBySelection <bitArray>faces <value>value

faces Validated by Validator function

value Validated by Validator function

Set the value of all faces specified by the set bits of the bitArray argument to the same value specified in the second argument.

For example:

--continuing from the previous example:

theInt.setValueBySelection #{1..2} 42

true

theInt.getValues()

#(42, 42)

theInt.getValueBySelection #{1..2} --now we can the value of both faces!

42

 

The Per-Face data will survive topology changes and class conversions. For example, if you would convert the plane from the above example to Editable Mesh, the channels will be preserved and each of the four faces in the new mesh will inherit the data from the respective polygons in the Editable Poly:

For example:

convertToMesh obj

$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000]

SimpleFaceManager.getChannels obj --check that all channels are still there

#(<MixinInterface:simpleFaceChannel>, <MixinInterface:simpleFaceChannel>)

theInt=(SimpleFaceManager.getChannels obj)[1] --get the first one

<MixinInterface:simpleFaceChannel>

theInt.numfaces --check the number of faces - now we have 4 triangles

4

theInt.getValues() --see that the original values were propagated

#(42, 42, 42, 42)

convertTo obj Editable_Poly --convert back to Editable Poly

$Editable_Poly:Plane01 @ [0.000000,0.000000,0.000000]

theInt.numfaces --the data has been consolidated

2

When converting from Editable Mesh to Editable Poly, multiple triangles with different per-face data could be consolidated into a single polygonal face. In this case, the LAST value of a face added to the polygon will be used.

For example:

convertToMesh obj

$Editable_Mesh:Plane01 @ [0.000000,0.000000,0.000000]

theInt.numfaces --check the number of faces - now we have 4 triangles

4

theInt.setValues #(1,2,3,4) --set different values for the 4 triangles

true

convertTo obj Editable_Poly --convert to Editable Poly

$Editable_Poly:Plane01 @ [0.000000,0.000000,0.000000]

theInt.getValues() --get the consolidated data - it is #(2,4) and not #(1,3)

#(2,4)

When changing topology by tessellating existing faces, the new faces will inherit the values of the original face.

For example:

polyop.tessellateByFace obj 1 --tessellate the first face into 4 new faces

OK

theInt.numfaces --check the total number of faces in the data channel

5

--note that because of the way Editable Poly updates polygon lists when

--changing topology, the previous face 2 becomes face 1,

--while the new 4 polygons from the tessellation have been given

--indices 2,3,4 and 5.

theInt.getValues() --get the new data:

#(4, 2, 2, 2, 2)