Difference between revisions of "Prim Class"

From TouchDesigner Documentation
Jump to: navigation, search
(Prim Class Auto Create)
(Prim Class Auto Create)
Line 8: Line 8:
 
     |class=Prim
 
     |class=Prim
 
     |name=center
 
     |name=center
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=Get or set the barycentric coordinate of this primitive. It is expressed as a named 4-tuple (x,y,z,w).
 
     |text=Get or set the barycentric coordinate of this primitive. It is expressed as a named 4-tuple (x,y,z,w).
Line 15: Line 15:
 
     |class=Prim
 
     |class=Prim
 
     |name=max
 
     |name=max
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The maximum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).
 
     |text=The maximum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).
Line 22: Line 22:
 
     |class=Prim
 
     |class=Prim
 
     |name=min
 
     |name=min
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The minimum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w)
 
     |text=The minimum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w)
Line 29: Line 29:
 
     |class=Prim
 
     |class=Prim
 
     |name=normal
 
     |name=normal
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The calculated normal vector of this primitive, expressed as a named 4-tuple (x,y,z,w).
 
     |text=The calculated normal vector of this primitive, expressed as a named 4-tuple (x,y,z,w).
Line 36: Line 36:
 
     |class=Prim
 
     |class=Prim
 
     |name=owner
 
     |name=owner
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The OP to which this object belongs.
 
     |text=The OP to which this object belongs.
Line 43: Line 43:
 
     |class=Prim
 
     |class=Prim
 
     |name=size
 
     |name=size
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The size of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).
 
     |text=The size of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).
Line 50: Line 50:
 
     |class=Prim
 
     |class=Prim
 
     |name=weight
 
     |name=weight
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The associated weight of the primitive.  Only certain primitives, such as those created by the Metaball SOP can modify this value from its default of 2.0.
 
     |text=The associated weight of the primitive.  Only certain primitives, such as those created by the Metaball SOP can modify this value from its default of 2.0.
Line 57: Line 57:
 
     |class=Prim
 
     |class=Prim
 
     |name=index
 
     |name=index
     |returns=
+
     |type=
 
     |set=0
 
     |set=0
 
     |text=The primitive index in the list.
 
     |text=The primitive index in the list.
Line 65: Line 65:
 
|items=
 
|items=
 
 
 +
{{ClassMethod
 +
    |class=Prim
 +
    |name=eval
 +
    |call=eval(u, v)
 +
    |returns=
 +
    |text=: -> Position
 +
Evaluate the position on the primitive given the u,v coordinates. u,v should be in the range [0,1]. Polygons and curves ignore the v parameter.
 +
center = op('box1').prim[0].eval(0.5, 0.5)
 +
}}
 
{{ClassMethod
 
{{ClassMethod
 
     |class=Prim
 
     |class=Prim
Line 74: Line 83:
 
Note: after this call, other existing Prim objects in this SOP may no longer be valid.
 
Note: after this call, other existing Prim objects in this SOP may no longer be valid.
 
  destroyPoints - (Keyword, Optional) If True, its points are destroyed as well, if false, they are simply detached.  The argument is True by default.
 
  destroyPoints - (Keyword, Optional) If True, its points are destroyed as well, if false, they are simply detached.  The argument is True by default.
}}
 
{{ClassMethod
 
    |class=Prim
 
    |name=eval
 
    |call=eval(u, v)
 
    |returns=
 
    |text=: -> Position
 
Evaluate the position on the primitive given the u,v coordinates. u,v should be in the range [0,1]. Polygons and curves ignore the v parameter.
 
center = op('box1').prim[0].eval(0.5, 0.5)
 
 
}}}}
 
}}}}
 
<section end=HELPBODY />
 
<section end=HELPBODY />
 
{{History}}
 
{{History}}
 
{{#invoke:Category|list|Python Reference}}
 
{{#invoke:Category|list|Python Reference}}

Revision as of 15:11, 15 September 2017

A Prim describes an instance to a single geometry primitive. They are accessible through the SOP.prims member.


Members[edit]

center(Read Only):

Get or set the barycentric coordinate of this primitive. It is expressed as a named 4-tuple (x,y,z,w).

max(Read Only):

The maximum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).

min(Read Only):

The minimum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w)

normal(Read Only):

The calculated normal vector of this primitive, expressed as a named 4-tuple (x,y,z,w).

owner(Read Only):

The OP to which this object belongs.

size(Read Only):

The size of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).

weight(Read Only):

The associated weight of the primitive. Only certain primitives, such as those created by the Metaball SOP can modify this value from its default of 2.0.

index(Read Only):

The primitive index in the list.

Methods[edit]

eval(u, v):

: -> Position

Evaluate the position on the primitive given the u,v coordinates. u,v should be in the range [0,1]. Polygons and curves ignore the v parameter.

center = op('box1').prim[0].eval(0.5, 0.5)

destroy(destroyPoints=True):

:

Destroy and remove the actual primitive this object refers to. This operation is only valid when the primitive belongs to a scriptSOP. Note: after this call, other existing Prim objects in this SOP may no longer be valid.

destroyPoints - (Keyword, Optional) If True, its points are destroyed as well, if false, they are simply detached. The argument is True by default.

TouchDesigner Build:

An Operator Family that reads, creates and modifies 3D polygons, curves, NURBS surfaces, spheres, meatballs and other 3D surface data.