triarrayΒΆ

class triarray

An array of triangles with their variables

The variables can be accessed by their names. The variables names are :

Basic parameters :

  • "P" (point3) : the position of in the primitive space
  • "N" (point3) : the normal of the surface in the primitive space
  • "st" (point3)" : the surface st
  • "color" (point3) : the surface color
  • "alpha" (point3) : the surface opacity
  • "width" (float) : the curve width
Advanced parameters :
  • "P2" .. "P6" (point3) : the Nth position used by the deform motion blur
  • "st2" .. "st8" (point3) : the Nth st surface
  • "color2" .. "color8" (point3) : the Nth surface color
  • "float12" .. "float18" (float) : the Nth float parameter. The first is "width"
  • "Pnd" (point3) : the non deformed position. This is the position in world space of the primitive with all its deformers disabled. This parameter is supposed to be constant along the animation.

Members

Methods:

table result barycentric ( vect/integer triangles , vect coordinates , strings variables ) Get interpolated variables on a set of triangles using barycentric coordinates
int result getcount ( ) Returns the number of triangles
integer result getsubid ( integer triangle ) Get The triangle subid
aabb result gettriangleaabb ( int id , float extend=0 ) Returns the aabb of a triangle
float result gettrianglearea ( int id , string variable="P" ) Returns the metric area of a triangle
table result gettrianglevar ( int id , string name ) Returns a variable of a triangle.
table result gettrianglevars ( int id ) Returns all the variables of a triangle
int result hasvar ( string name ) Returns true if the variable is present in the triarray
nil shade ( string handle , vect/uint triangles , vect points , vect radius , string|nil shadedvars ) Shades a set of points of a triarray using a primitive material.

Documentation

table result barycentric ( vect/integer triangles , vect coordinates , strings variables )

Get interpolated variables on a set of triangles using barycentric coordinates

Arguments:

  • triangles the triangle indices
  • coordinates the barycentric coordinates
  • variables the variable to get, as a list of string

Return:

  • result a list of vect containing the resulting interpolated variables


int result getcount ( )

Returns the number of triangles

Return:

  • result


integer result getsubid ( integer triangle )

Get The triangle subid

Arguments:

  • triangle the triangle index

Return:

  • result the triangle resulting subid


aabb result gettriangleaabb ( int id , float extend=0 )

Returns the aabb of a triangle

Arguments:

  • id The triangle id
  • extend=0 An optional extension to apply to the aabb

Return:

  • result


float result gettrianglearea ( int id , string variable="P" )

Returns the metric area of a triangle

Arguments:

  • id The triangle id
  • variable="P" The variable to use for area computation

Return:

  • result


table result gettrianglevar ( int id , string name )

Returns a variable of a triangle.

The returned table looks like this for the parameter "float12" :

{
    1,    -- Point 1's float12
    0.5,  -- Point 2's float12
    0,    -- Point 3's float12
}

The returned table looks like this for the parameter "P" :

{
    point3 (1, 0, 0),    -- Point 1 P
    point3 (0, 1, 0,    -- Point 2 P
    point3 (0, 0, 1),    -- Point 3 P
}
Arguments:

  • id The triangle id
  • name The variable name to get

Return:

  • result Returns a table with the parameter for each vertices of the triangle or nil if the variable is not present.


table result gettrianglevars ( int id )

Returns all the variables of a triangle

The returned table looks like this :

{
    "P" = 
    {
        point3 (1, 0, 0),    -- Point 1's position
        point3 (0, 1, 0,    -- Point 2's position
        point3 (0, 0, 1),    -- Point 3's position
    }
    "N" = 
    {
        point3 (1, 0, 0),    -- Point 1's normal
        point3 (0, 1, 0),    -- Point 2's normal
        point3 (0, 0, 1),    -- Point 3's normal
    }
    "float12" = 
    {
        1,    -- Point 1's second float
        0,    -- Point 2's second float
        0,    -- Point 3's second float
    }
    [...]
}
Arguments:

  • id The triangle id

Return:

  • result


int result hasvar ( string name )

Returns true if the variable is present in the triarray

Arguments:

  • name The variable name to test

Return:

  • result


nil shade ( string handle , vect/uint triangles , vect points , vect radius , string|nil shadedvars )

Shades a set of points of a triarray using a primitive material.

Arguments:

  • handle The primitive's handle used to get the material
  • triangles An array of triangles id or the triangle id to use with all the points.
  • points 2d vect with the barycentric coordinates
  • radius 1d vect with the radius for each point to shade
  • shadedvars A comma separated list of values to be specifically shaded (like "Ci,Oi,FurLength" ...) or nil to shade all values