GrowFX 2.0 User Manual

MAXScript Access

Constructor:

growfx2 ...
An example:

gfx = growfx2 name:"Tree_01" position:[10,10,0]


MAXScript properties and methods for GrowFX Full and Demo versions

Properties:

<growfx2>.LineOnly : Boolean default: true

When true, activates "paths as lines" display mode in the Viewport, otherwise activates the Mesh display mode in the Viewport.


<growfx2>.Manual : Boolean default: false
<growfx2>.IconSize : Float default: 0.0
<growfx2>.Seed : Integer default: (random value)
<growfx2>.CountPath : Integer : Read only
<growfx2>.GfxFileName : String
<growfx2>.ShowLineNumbers : Boolean default: false
<growfx2>.ShowLineFullNumbers : Boolean default: false

Preference parameters:
<growfx2>.UnitCalc : Float default: 10.0
<growfx2>.DisableAllMetaMeshes : Boolean default: false
<growfx2>.VectorsSize : Float default: 10.0
<growfx2>.ShowEdges : Boolean default: true
<growfx2>.SelectionMesh : Boolean default: true
<growfx2>.HideIcon : Boolean default: false
<growfx2>.RandomWireColor : Boolean default: true
<growfx2>.PathSegsLimit : Integer default: 1000
<growfx2>.DensityLimit : Integer default: 1000
<growfx2>.DistrCountLimit : Integer default: 1000
<growfx2>.MeshSegsLimit : Integer default: 1000
<growfx2>.MetaVertsLimit : Integer default: 100000

Global Meta Settings:
<growfx2>.MetaSettings_MaxIterations : Integer default: 10000
<growfx2>.MetaSettings_MinSizeFaces : Float default: 0.005
<growfx2>.MetaSettings_GenerateUVWMapping : Boolean default: true
<growfx2>.MetaSettings_RebuildExtralargeFaces : Boolean default: false
<growfx2>.MetaSettings_RebuildExtrasmallFaces : Boolean default: false


Methods:

<growfx2>.SavePreset <pathfile_name_string>
<growfx2>.LoadPreset <pathfile_name_string>

Save and Open preset files.


<growfx2>.Update()

Updates the GrowFX internal caches and viewport display to account for all the changes made by other functions in this kit.


<growfx2>.NewSeed()

Generate a new random seed.


<growfx2>.getNumSequences()

Returns the number of sequences. It equals the number of objects that are used in the distributors (the GrowFX icon, points, surfaces, etc.).


<growfx2>.getNumLines <sequence_index_integer>

Returns the number of lines for the specified sequence, index are 1-based.


<growfx2>.GenerateOneMesh <sequence_index_integer> <line_index_integer>

After calling this function, GrowFX generates a mesh for only the specified line, indexes are 1-based.


<growfx2>.ResetOneMesh()

Resets the state of the previous function.


<growfx2>.CreateSeparateSplines()

Creates separate splines for each path line. This method does not working in the Demo version!


<growfx2>.CreateHierarchyMeshes <is_group_by_pathcolor>

Returns an array of Editable poly nodes of the elements in the hierarchy.

is_group_by_pathcolor : boolean - when true, the algorithm will group adjacent branches if they have the same path color.


<growfx2>.CreateHierarchySplines <is_group_by_pathcolor>

Returns an array of Editable spline nodes of the elements in the hierarchy.

is_group_by_pathcolor : boolean - when true, the algorithm will group adjacent branches if they have the same path color.


<growfx2>.SetCopyright <copyright_string> <url_string> <password_string> <is_Lock_NodeGraph_Boolean>

Sets your own Copyright. For more information see Abouts rollout.

<url_string> must include protocol "http:\\" or "https:\\".


For example:

gfx.SetCopyright "My Name" "https:\\example.com" "1234" true



Node Editor

Properties:

<growfx2>.ShowNodeInfo : Boolean default: false

When true - displays additional information on nodes in the node editor that can be useful when programming MaxScript code, such as connector indexes, parameter indexes and node coordinates.


<growfx2>.GridSpacing : Float default: 45.0

Specifies the spacing between grid lines in the Node Editor's viewport.


<growfx2>.ShowGrid : Boolean default: true

Get/Set the visibility of the grid lines in the Node Editor's viewport.


<growfx2>.SnapGrid : Boolean default: true

Get/Set the state of the grid snap option in the Node Editor's viewport.


Methods:

<growfx2>.addNode <type_node> <name_string> <X_position_integer> <Y_position_integer>

Creates a new node.

The <type_node> must be one of the following name values:

#NPath, #NDistr, #NDistrPoint, #NDistrPath, #NDistrPathPos, #NDistrSurf, #NDirRandom, #NDirVector, #NDirNoise, #NDirDeviation, #NDirSpline, #NDirHardBend, #NDirWind, #NDirCopy, #NDirAlignCh, #NDirRadial, #NDirSpiral, #NDirZigzag, #NDirTwist, #NDirReact, #NDirPathReact, #NDirObjSlice, #NDirVecOrient, #NDirSESlice, #NDirOptimize, #NDirEraser, #NDirTrim, #NDirOverrideSteps, #NDirShape, #NMeshCyl, #NMeshMeta, #NMeshLeafs, #NMeshIG, #NMeshSTDLeafs, #NAffect, #NUVWMap, #NChaosMatID, #NVertexColorCE, #NVertexColorCP, #NVertexColorIP, #NCurve, #NPathPos, #NIGElement, #NValue, #NRandom, #NSwitch, #NMath, #NGroup, #NAttrPos, #NAttrDist;
name_string: name of node;
X_position_integer: x-position on the Node editor viewport;
Y_position_integer: y-position on the Node editor viewport;

<growfx2>.addPublicNode <node_index_integer> <connector_index_integer> <name_string> <X_position_integer> <Y_position_integer>

Creates a new Public node from the indexed connector of the specified node.

name_string: name of node;
X_position_integer: x-position on the Node editor viewport;
Y_position_integer: y-position on the Node editor viewport;

To create a Public node with the type "Caption", you need to set <node_index_integer> or <connector_index_integer> equals 0.


<growfx2>.addCurveNode <node_index_integer> <connector_index_integer> <curve_as_factor_boolean> <name_string> <X_position_integer> <Y_position_integer>

Creates a new Curve node from the indexed connector of the specified node.

curve_as_factor_boolean: When true, connects a new Curve node with Curve as Factor mode. Otherwise, it will be connected with Curve as Value mode (Float or Universe), depending on the type of parameter that this curve node will connect to. For more information see Curve node;
name_string: name of node;
X_position_integer: x-position on the Node editor viewport;
Y_position_integer: y-position on the Node editor viewport;

<growfx2>.getNumNodes()

Returns number of nodes as an integer.


<growfx2>.getNodeName <node_index_integer>

Returns the name of node.


<growfx2>.setNodeName <node_index_integer> <new_name_string>

Sets the new name of node.


<growfx2>.getNodeOn <node_index_integer>

Returns true if node is on.


<growfx2>.setNodeOn <node_index_integer> <is_on_boolean>

Sets On or Off of the specified node.


<growfx2>.getNodeType <node_index_integer>

Returns the type of node.


<growfx2>.getNumConnectors <node_index_integer>

Returns number of connectors in the specified node as an integer.


<growfx2>.getConnectorType <node_index_integer> <connector_index_integer>

Returns the type of connector in the specified node for the indexed connector.

Returns one of the following name values:

  • #NCOnOff - on/off connector for all nodes;
  • #NCCommand - connector from command button;
  • #NCPathDistrFrom - from Path node to Distributor nodes (red connector on the top);
  • #NCPathDistrTo - from Path node to child Distributor nodes (red connector bottom right);
  • #NCPathDir - from Path node to Modifier nodes;
  • #NCPathMesh - from Path node to Mesh Builder nodes;
  • #NCPathAMDir - from Path node to After Mesh Modifier nodes;
  • #NCDistrIn - input to Distributor nodes from Path node (red connector top left);
  • #NCDistrOut - from Distributor node to Path node (red connector bottom);
  • #NCDirIn - input to Modifier node;
  • #NCDirOut - output from Modifier node on the bottom to next Modifier node;
  • #NCRefDistrs - input to Modifier node right to connect multiple referenced Distributor nodes (used in Deviation direction node);
  • #NCRefDistr - input to Modifier node right to connect one referenced Distributor node (used in Align children node);

  • #NCMeshIn - input to Mesh Builder nodes;
  • #NCMeshUVW - output from Mesh Builder node to UVW Mapping node;
  • #NCMeshCMID - output from Mesh Builder node to Chaos Material ID node;
  • #NCMeshVC - output from Mesh Builder node to Vertex Color nodes;

  • #NCAffectFrom - output from any affect Parameters to Affect nodes;

  • #NCAffectIn - input to Input parameter of Affect node;
  • #NCAffectOut - output from Affect node;

  • #NCParam_A - input to any parameter from Affect node only;
  • #NCParam_APM - input to any parameter from Affect, Public or Math nodes;
  • #NCParam_PM - input to any parameter from Public or Math nodes;
  • #NCParam_P - input to any parameter from Public node only;

  • #NCPublicOut - output from Public node;
  • #NCMathOut - output from Value, Random Generator or Math nodes;

  • #NCSwitchIn - input to Switch node;
  • #NCSwitchOut - output from Switch node;

  • #NCUVWIn - input to UVW Mapping node;
  • #NCCMIDIn - input to Chaos Material ID node;
  • #NCVCIn - input to Vertex Color node;
  • #NCVCOut - output from Vertex Color node to next Vertex Color node;
  • #NCCurve - output from any parameter to Curve node;
  • #NCCurveOut - output from Curve node;
  • #NCPathPos - input to Positions list of Path position distributor node;
  • #NCPathPosOut - output from Path Position node to Positions list of Path position distributor node;
  • #NCIGElem - input to Geometry Objects list of Instanced geometry node;
  • #NCIGElemOut - output from Instanced geometry element node;

<growfx2>.createConnection <node1_index_integer> <connector1_index_integer> <node2_index_integer> <connector2_index_integer>

Creates a new connection between two nodes with specific connector indexes. Use the ShowNodeInfo property to find out the index of the connector on the node.


<growfx2>.findNodeByName <name_string>

Finds the first node named name_string, and returns the index of the found node. If not found, it returns 0.

name_string - searched name (case sensitive).


<growfx2>.getNodeParamValue <node_index_integer> <parameter_index_integer>

Returns the value of the indexed parameter in the specified node.


<growfx2>.setNodeParamValue <node_index_integer> <parameter_index_integer> <value_float>

Sets the value of the indexed parameter in the specified node.


<growfx2>.getNodeParamColor <node_index_integer> <parameter_index_integer>

Returns the color value of the indexed color parameter in the specified node.

<growfx2>.setNodeParamColor <node_index_integer> <parameter_index_integer> <color>

Sets the color value of the indexed color parameter in the specified node.


<growfx2>.getValueTypeNode <node_index_integer>

Returns the output value type of the node for the Value, Random generation, or Math nodes.

Returns one of the following name values: #VInteger, #VFloat, #VUniverse, #VTime.


<growfx2>.setValueTypeNode <node_index_integer> <value_type>

Sets the output value type of the specified node for the Value, Random generation, or Math nodes.

The <value_type> must be one of the following name values: #VInteger, #VFloat, #VUniverse, #VTime.


<growfx2>.getOperTypeMathNode <node_index_integer>

Returns the operation type of the specified Math node.

Returns one of the following name values:

  • #MOAdd - A + B;
  • #MOSubtract - A - B;
  • #MOMultiply - A * B;
  • #MODivide - A / B;
  • #MOPov - A ^ B;

<growfx2>.setOperTypeMathNode <node_index_integer> <operation_type>

Sets the operation type of the specified Math node.

The <value_type> must be one of the following name values:

  • #MOAdd - A + B;
  • #MOSubtract - A - B;
  • #MOMultiply - A * B;
  • #MODivide - A / B;
  • #MOPov - A ^ B;

<growfx2>.attachObjectToPublicNode <publicnode_index_integer> <object_node>

Attaches an object node to a specified Public node. The public node must be with an object type.

Returns true if the object was attached successfully, false otherwise.


<growfx2>.attachMapToPublicNode <publicnode_index_integer> <texture_map>

Attaches a texture map to a specified Public node. The public node must be with a Texture map type.

Returns true if the texture map was attached successfully, false otherwise.


Example:

-- Creating a new GrowFX object and set some parameters:
gfx = growfx2 name:"Tree_01" position: [0, 0, 0]
gfx.IconSize = 20
gfx.LineOnly = false     -- Set the Meshes mode display in the viewport.
gfx.ShowNodeInfo = on    -- Display an additional information on nodes.
-- Creating trunk with distributor and mesh builder:
trunk_path = gfx.AddNode #NPath "Trunk" 0 0
trunk_distr = gfx.AddNode #NDistr "Trunk_Distr" 0 -675
trunk_mesh = gfx.AddNode #NMeshCyl "Trunk_Mesh" 0 315
gfx.createConnection trunk_path 2 trunk_distr 20
gfx.createConnection trunk_path 5 trunk_mesh 2

-- Set the Length for the Trunk path:
gfx.setNodeParamValue trunk_path 1 200.0
-- Set the Radius for the Mesh:
gfx.setNodeParamValue trunk_mesh 1 4.0

-- Adding a curve node for the Radius of mesh:
trunk_meshR = gfx.addCurveNode trunk_mesh 4 true "Trunk_MeshR" 270 315

-- Adding Random and Vector modifiers for the Trunk path:
t_dir1 = gfx.AddNode #NDirRandom "t_dir_1" -270 270
gfx.createConnection trunk_path 3 t_dir1 2
t_dir2 = gfx.AddNode #NDirVector "t_dir_2" -270 450
gfx.createConnection t_dir1 9 t_dir2 2
gfx.setNodeParamValue t_dir2 11 100.0

-- Creating branches of 1 level:
b1_path = gfx.AddNode #NPath "B_1" 810 0
b1_distr = gfx.AddNode #NDistrPath "B1_Distr" 810 -900
b1_mesh = gfx.AddNode #NMeshCyl "B1_Mesh" 810 315
gfx.createConnection b1_path 2 b1_distr 32
gfx.createConnection b1_path 5 b1_mesh 2
gfx.createConnection trunk_path 12 b1_distr 2
b1_meshR = gfx.addCurveNode b1_mesh 4 true "B1_MeshR" 1080 315
gfx.setNodeParamValue b1_path 1 80.0
gfx.setNodeParamValue b1_distr 10 15.0

-- Adding an Affect node for branches:
aff1 = gfx.AddNode #NAffect "Aff_LB1" 1080 -810
gfx.createConnection b1_distr 5 aff1 2
b1_AffF = gfx.addCurveNode aff1 6 false "B1_AffF" 1350 -675
gfx.createConnection aff1 11 b1_path 6

-- Adding a Random and Vector modifiers for branches:
t_dir3 = gfx.AddNode #NDirRandom "t_dir_3" 540 270
gfx.createConnection b1_path 3 t_dir3 2
t_dir4 = gfx.AddNode #NDirVector "t_dir_4" 540 450
gfx.createConnection t_dir3 9 t_dir4 2

-- Creating a Caption Public node:
pub_1 = gfx.addPublicNode 0 0 "Tree parameters" -450 -200

-- Creating a Public node to control the Length of the Trunk path:
pub_2 = gfx.addPublicNode trunk_path 6 "Height" -450 0

-- Creating fruits path on the end of branches:
b2_path = gfx.AddNode #NPath "Fruits" 1845 0
-- Set the Length and Steps = 5:
gfx.setNodeParamValue b2_path 1 5.0
gfx.setNodeParamValue b2_path 3 5.0
-- Adding a Path Position distributor:
b2_distr = gfx.AddNode #NDistrPathPos "B2_Distr" 1845 -900
b2_distrpos1 = gfx.AddNode #NPathPos "B2_DistrPos1" 1575 -675
gfx.createConnection b2_distr 5 b2_distrpos1 2
gfx.createConnection b2_path 2 b2_distr 23
gfx.createConnection b1_path 12 b2_distr 2

-- Adding a Vector modifier for fruits:
t_dir5 = gfx.AddNode #NDirVector "t_dir_5" 1575 270
gfx.createConnection b2_path 3 t_dir5 2
gfx.setNodeParamValue t_dir5 11 -100.0
-- Adding an Instanced geometry mesh for fruits:
b2_mesh = gfx.AddNode #NMeshIG "B1_Mesh2" 1845 360
gfx.createConnection b2_path 5 b2_mesh 2

b2_ig1 = gfx.AddNode #NIGElement "B2_IG1" 1575 630
gfx.createConnection b2_mesh 7 b2_ig1 2
gfx.setNodeParamValue b2_mesh 1 100.0

-- Creating a Public node to attach the fruit object:
pub_3 = gfx.addPublicNode b2_ig1 3 "IG_1" 1350 800
-- Creating some fruit:
fruits = sphere name:"Fruit" position:[100, 100, 0] radius:7
-- Attach a fruit to the Public node:
gfx.attachObjectToPublicNode pub_3 fruits

-- Update the GrowFX object:
gfx.Update()

The example above will generate the following node graph:



Cache Mode Properties

<growfx2>.CacheMode : Boolean default: false
<growfx2>.CacheFileName : String : Read only
<growfx2>.NumThreads : Integer default: (number of cores on the current PC)
<growfx2>.RecordCurrentFrame : Boolean default: false
<growfx2>.RecordAnimation : Boolean default: true
<growfx2>.CacheStartFrame : Timevalue default: 0
<growfx2>.CacheEndFrame : Timevalue default: 100
<growfx2>.PlaybackStartFrame : Timevalue default: 0
<growfx2>.PlaybackSpeedFactor : Float default: 1.0
<growfx2>.PlaybackLoopAnimation : Boolean default: true

Cache Mode methods:

NewCacheFile <string_path_filename>

Specifies the name of the new cache file. Returns true if the file was successfully prepared, false if it failed.


LoadCacheFile <string_path_filename>

Loads the specified cache file. Returns true if the cache file was found and loaded successfully.


RecordCache()

Records the cache data of the given GrowFX object to the disk.


ResetCache()

Resets the cache data.


DeleteCache()

Deletes the cache file from the disk.




TOP