thinkingParticles 7.3

Spline Input Functions

The splinepool input of the ExpressionME-L Node allows for programmatic access to Spline objects (Shape Objects) in 3ds Max. You can use various functions to create highly optimized thinkingParticle Splines. Nearly every aspect of a spleane generation can be accessed/modified. This can be useful for creating a wide range of visual effects that involve splines.

 

splinepool_in_spline

The purpose of this function is to create thinkingParticles splines based on particles in a simulation. If this function is called without any parameters, it will create an empty spline that is ready to have knots added to it. The function also enables the user to set the spline type to one of the following: Bzier Curve (spline), Corner, or Automatic.

Calls:

//create a new empty spline
//return is either -1 for fail, or the newly created spline_id 
    spline_id = splinepool_in_spline();

//create a spline with a defined spline id
    splinepool_in_spline(in_spline_id);

//add a knot particle id at the end of a spline
    splinepool_in_spline(in_spline_id, in_add_pid);

//add a knot particle id and set the knot type to corner. Knot types are:
// 1) knot_type_auto (default) 2) knot_type_corner 3)knot_type_spline
    splinepool_in_spline(in_spline_id, in_add_pid, knot_type_corner);

//add a knot particle id at a specific position on the spline, index starts at 0
//spline knots can created in random order, sorting will be automatic smallest to largest 
    splinepool_in_spline(in_spline_id, in_add_pid, in_knot_type, in_knot_id);

Parameters:

Parameter Description
empty  splinepool_in_spline() will create an empty spline 
in_spline_id supply a spline id to create or add a knot
in_add_pid knot particle index to add to the spline, a particle can only exist at one spline
in_knot_type     knot type (see table below)
in_knot_insert_id knot sort id, for random order insert. This lets you specify an order to insert a knot. Usually knots are automatically added at the end of the spline!

knot_types

Parameter Description
knot_type_corner creates a corner knot type (straight line)
knot_type_spline creates a bezier spline type
knot_type_auto     creates an automatic type of spline (smooth)

Output:

Return Description
scalar -1: failed, success returnes the newly created spline ID

 

splinepool_in_branch

This function is used to create a branch from an existing spline knot (particle) and extend the spline length. The function automatically snaps the first branch knot to the particle position of the existing spline knot and creates a new spline (branch) to start with. Tracking the branching knot will be automatically performed by the spline function. The function also allows the user to retrieve the ID of the last spline that was created by a previous call to this function. Adding knots to a branch is identical to the method described above (splinepool_in_spline()), and spline knots are automatically added based on new particle positions.

Calls:

//add an empty branch spline on a knot particle
//this function returns the new branch spline index or -1 when failed (particle is not a knot)
    spline_id = splinepool_in_branch(in_knot_pid);

//this function creates a branch and sets the first knot at the same time
//this function returns the new branch spline index or -1 when faild
//the first branch knot particle will automatically be snapped and tracked to the in_knot_pid
    spline_id = splinepool_in_branch(in_knot_pid, in_add_pid);

//same function as above, in addition you can specify the knot type
    spline_id = splinepool_in_branch(in_knot_pid, in_add_pid, in_knot_type);

Parameters:

Parameter Description
in_knot_pid the particle index of a spline knot to add a branch (start a new spline) 
in_add_pid the first knot particle to start a branch, will be snapped and tracked to the in_knot_pid
in_knot_type     the knot type of the in_add_pid

Output:

Return Description
scalar -1: failed, success: returns the branch spline id, to add additional knots use the splinepool_in_spline function.

 

splinepool_in_get

This function is used to retrieve various information related to the splines created using the splinepool system. This function can be used to get the total number of splines, the total number of knots, the ID of the spline associated with a particle, the ID of the last created spline, the ID of the last created knot, the ID of the last knot, the lead particle (the particle to draw the spline to), the knot type, the length of the spline (either total including branch or the individual spline), UVW coordinate at the knot of the spline, and the vertex color of the knot.

Calls:

//get the total number of splines in the pool (including branches)
    numberofsplines = splinepool_get(spool_nsplines)
   
//get the last created spline id
    spline_id = splinepool_get(spool_sid);
    
//get the last created knot id
    knot_id = splinepool_get(spool_kid);

//get spline length in absolute generic coordinates
    length = splinepool_in_get(spool_length, in_spline_id);

//get spline leader particle id (last particle)  
    pid = splinepool_in_get(spool_lead_pid, in_spline_id);

//get the number of knots in a spline
//in_spline_id is the index of the spline which falls between 0 and numberofsplines-1
    numberofknots = splinepool_in_get(spool_nknots, in_spline_id);

//get knot particle id
    pid = splinepool_in_get(spool_knot_pid, in_spline_id, in_knot_id);

//get knot type
    knot_type = splinepool_in_get(spool_knot_type, in_spline_id, in_knot_id);

//get knot uvw if set; return 1 if set; return 0 if not set
    splinepool_in_get(spool_knot_uvw, in_spline_id, in_knot_id, out_uvw[3]);

//get knot vertex color if set; return 1 if set; return 0 if not set
    splinepool_in_get(spool_knot_vcol, in_spline_id, in_knot_id, out_color[3]);

//particle id to spline_id
//if the particle is a spline knot the spline id will be returned otherwise -1    
    spline_id = splinepool_in_get(spool_pid2spline, in_pid);

//get a interpolated world position on the spline
//in_spline_rel_pos input the relative spline position, 0 is the start and 1 is the end of spline
    splinepool_in_get(spool_pos, in_spline_id, in_spline_rel_pos, out_world_pos[3]);

//get a interpolated tangent on the spline
    splinepool_in_get(spool_tangent, in_spline_id, in_spline_rel_pos, out_tangent[3]);

//get a interpolated velocity on the spline
    splinepool_in_get(spool_velocity, in_spline_id, in_spline_rel_pos, out_velocity[3]);

//get the knot 1D position on the spline in absolute lenght
    scalar spos = splinepool_in_get(spool_knot_spos, in_spline_id, in_knot_id);

//get the knot 1D position on the spline in relative lenght, 0 to 1
    scalar spos_rel = splinepool_in_get(spool_knot_rel_spos, in_spline_id, in_knot_id);

//get the knot tangent 
    splinepool_in_get(spool_knot_tangent, in_spline_id, in_knot_id, out_tangent[3]);

Parameters:

Parameter Description
spool_data_type specify the data to get, find the possible spool_data_types in the table below
in_spline_id the spline index starting from 0  up to the numberofsplines-1
in_knot_id the knot index starting from 0  up to the numberofknots-1
in_pid defines the particle index
out_uvw[3] this variable (vector) stores the returned uvw coordinates
out_color[3] this variable (vector) stores the returned color (R,G,B)
out_world_pos[3] this variable (vector) stores the returned position
out_velocity[3] this variable (vector) stores the returned velocity
out_tangent[3] this variable (vector) stores the returned tangent

spool_data types:

Parameter Description
spool_nsplines number of splines in the pool
spool_nknots number of knots in the spline
spool_length length of a spline in generic absolute     
spool_knot_pid particle id of a knot
spool_knot_type knot type (corner, spline or auto)
spool_knot_uvw texmap uvw coordinates of the knot
spool_knot_vcol vertex color of the knot
spool_knot_spos retrieves a position on the spline (scalar, length)
spool_knot_rel_spos retrieves realtive position on the spline (between 0-1)
spool_knot_tangent retrives the tangent of the knot (orientation), returns a vector
spool_pid2spline particle to spline, returns the spline id when the particle is a knot 
spool_lead_pid the leader partilce id of the spline
spool_sid last created spline index
spool_kid last created knot index
spool_pos retrieves the 3D world coordinate on the spline
spool_out_tangent retrieves an interpolated tangent anywhere on the spline
spool_out_vel retrieves the interpolated the interpolated velocity anywhere on the spline

 

Output:

Return Description
scalar variable return values dependent on the spool_data_type

 

splinepool_in_set

This function is used to set various parameters related to the splines created using the splinepool system. This function can be used to set the lead particle, the knot type, the UVW coordinates, and the vertex color of the spline knots.

Calls:

//set the knot type
    splinepool_in_set(spool_knot_type, in_spline_id, in_knot_id, in_knot_type);
  
//set the knot uvw
    splinepool_in_set(spool_knot_uvw, in_spline_id, in_knot_id, in_uvw[3]);
 
//set the knot vertex color
    splinepool_in_set(spool_knot_vcol, in_spline_id, in_knot_id, in_color[3]);

//set the spline leader particle
//to unset the leader particle use -1 for the in_pid
    splinepool_in_set(spool_lead_pid, in_spline_id, in_pid);

Parameters:

Parameter Description
in_spool_data_type param to set see table below for in_spool_data_type
in_spline_id spline index
in_knot_id knot index
in_knot_type knot type (knot_type_corner...)
in_uvw[3] texmap uvw coordinates
in_color[3] color r,g,b

in_spool_data_type:

Parameter Description
spool_knot_type knot type (corner, spline or auto)
spool_knot_uvw texmap uvw coordinates of the knot
spool_knot_vcol vertex color of the knot
spool_lead_pid the lead particle ID of the spline, to remove the lead particle use -1

Output:

Return Description
scalar 0: failed, 1: success

 

splinepool_in_remove

The purpose of this function is to procedruallt remove a complete spline or specific knots from a spline

Calls:

//remove all splines
    splinepool_in_remove();

//remove the spline with spline_id = 0 - (nsplines-1))
    splinepool_in_remove(in_spline_id);

//remove the knot on spline with spline_id = 0 - (nsplines-1)) and knot_id = 0 - nknots-1
    splinepool_in_remove(in_spline_id, in_knot_id);

//to let the spline particles stay alive add a false (is the same as 0) at the end
//the full call to remove all splines and not the particles
    splinepool_in_remove(-1, -1, false);

//remove the spline with spline_id = 0 - (nsplines-1))
    splinepool_in_remove(in_spline_id, -1, false);

//remove the knot on spline with spline_id = 0 - (nsplines-1)) and knot_id = 0 - nknots-1
    splinepool_in_remove(in_spline_id, in_knot_id, false);

Parameters:

Parameter Description
empty  splinepool_in_remove() will delete all splines
in_spline_id supply a spline id to remove a knot from, -1 will delete all splines
in_knot_id knot index to delete from the spline, -1 deletes all knots and the spline
in_kill_particle    true (default) will kill the knot particle, false - will keep the knot particle 


Output:

Return Description
scalar 0: failed, 1: success 

 

 

 

 

 

©2023, cebas Visual Technology Inc.