Primitive SOP

From TouchDesigner 099 Wiki

Summary

The Primitive SOP is like the Point SOP but manipulates a primitive's position, size, orientation, color, alpha, in addition to primitive-specific attributes, such as reversing primitive normals. The Primitive SOP also lets you create custom primitive attributes.

You can also apply parametric affine transformations to a profile by using this SOP. You can also use it to open, close, reverse, and cycle the profile curves.

Note: When applying transformations to a profile, you can only rotate about the Z axis because the projected curve is a planar curve that lives in the domain of the surface. Therefore it wouldn't make any sense to allow rotations in X or Y for profiles.

Transformation of Primitives vs Profiles

A Bezier surface is a single primitive, as is a NURBS surface, while a polygon mesh can consist of hundreds of individual primitives. Care must be taken to ensure the desired result. Profiles can be translated, rotated, and scaled along with 3D primitives. The Z component of translation and scaling is ignored. The X and Y components would be interpreted as U and V values because they apply to the space in which profiles are defined.

Example - Mapping a Texture Inside a Sphere

There are many uses for the Primitive SOP. Normally, if you apply a texture onto a sphere, it is mapped onto the outside surface because the U surface normals point outwards by default. If you wanted to map the texture onto the inside of the sphere instead, you could simply run the sphere geometry through a Primitive SOP, and select Reverse U (i.e. the surface normals) in the Face/Hull page > Vertex menu.

PythonIcon.png primitiveSOP_Class

Parameters - Transform Page

Source Group /group - If there are input groups, specifying a group name in this field will cause this SOP to act only upon the group specified. You can specify profile curves within the group by providing a profile pattern (e.g. *.3 specifies the fourth profile in all spline surfaces).

Tip: By specifying both a primitive and a profile here (example: 0 0.* ), you can affect a transformation of both the parent surface and a profile curve.

Template Group /templateGrp - A subset of template points to transform to.

Do Transformation /doxform - When checked, allows transformations to occur.

Rotate to Template /dorot - A template can be specified using the second input of the Primitive SOP. When set to On, this template can be used to transform each primitive to the location and orientation of the template point. This is similar to what the Copy SOP does except that the actual primitives are transformed, not copies made.

  • Off - Don't rotate.
  • On - The primitive gets rotated as if its normal was (0,0,1), and is meant to point the same direction as the template normal.
  • Match Normals - Rotates the primitive so that its real normal lines up with the normal of the template point.

Transform Order /xOrd - Sets the overall transform order for the transformations. The transform order determines the order in which transformations take place. Depending on the order, you can achieve different results using the exact same values. Choose the appropriate order from the menu.

Rotate Order /rOrd - Sets the order of the rotations within the overall transform order.

Translate /tx /ty /tz - These three fields move the input geometry in the three axes. Profiles use tx and ty only.

Rotation /rx /ry /rz - These three fields rotate the Source geometry in the three axes. Profiles use rz only.

Scale /sx /sy /sz These three fields scale the Source geometry in the three axes. Profiles use sx and sy only.

Pivot /px /py /pz - The pivot point for the transformations. Profiles use px and py only.

Lookat Object /lookat - Selects the object the primitive should point towards. This performs the lookat in object space; if you need to a lookat in world space, use the lookat in the object's Transform page instead.

Tip: In order to get multiple sprites to always be perpendicular to the camera, feed them into a Primitive SOP and specify the camera as your Lookat Object. Then the sprites should always be perpendicular to the camera.

Up Vector /upvectorx /upvectory /upvectorz - Defines the orientation of the primitive along the X, Y, or Z axes.

The Up Vector determines how a primitive orients itself with respect to the target object (specified in Lookat Object). The default value is of 1 in the Y direction. This will produce nice behaviour if you want the object to rotate somewhat in the Z axis as the Lookat Object gets very close and/or passes the target. Scaling the Up Vector will cause the Lookat primitives to remain more upright as they get very close and/or pass the target. The stronger the Up Vector, the more the primitives will want to stay vertical and resist the rotation.

Parameters - Attributes Page

Keep / Add / No Colors /doclr - If Keep is selected, the color attribute is left unchanged. If Add is selected, this parameter changes the color of input primitives according to diffuse color field. If No is selected, the color attribute is removed.

Color /diff - The color to add.

Alpha /alpha - The alpha value to add.

Keep / Add / No Crease /docrease - If Keep is selected, the crease attribute is left unchanged. If Add is selected, this parameter generates a crease attribute for the primitive. If No is selected, the crease attribute is removed.

The Crease /crease - Attribute is used to set edge crease weights for subdivision surfaces (see Subdivide SOP). The Crease Weight attribute for a primitive sets all edges of the polygon to the value specified. On shared edges, the maximum of the two crease weights is used to define the sharpness of the subdivided surface. Crease weights should be larger than 0, with larger values defining sharper edges.

Custom Attrib /custom1 - Creates a custom attribute with this name.

Custom Attrib Size /custom1size - The size of the attribute to create. It'll use however many values from the Value parameter as the size is.

Value /custom1val - The value(s) to assign to the attribute.

Parameters for other custom attributes are the same, but the number is different.

Parameters - Face / Hull Page

Preserve Shape U / V /pshapeu /pshapev - These options only become available once a type of clamping or closure has been selected.

Closure - Change the closure and clamping of a face or hull. The options are:

Close U / V /closeu /closev - Close the primitive in U / V. Select from: Open, Closed Straight, Close Rounded, and Unroll. When you unroll a closed curve you duplicate the wrapped points (you make them unique) and turn the curve into an open curve. The shape of the curve does not change. Same goes for hulls, only there we unique entire rows and cols. This addresses a problem with texturing wrapped surfaces whereby the texture repeats itself in the wrapped portion of the surface.

Clamp U / V /clampu /clampv - Clamp the primitive in U / V. Select from: Clamp, Unclamp.

Vertex /vtxsort

  • No Change - Does not affect the ordering of the vertices.
  • Reverse - Reverses both U and V for hulls, and just U for faces.
    For example:
  • Reverse U - Reverses column order of hulls.
  • Reverse V - Reverses row order of hulls.
  • Swap U and V - Interchanges rows/columns while preserving topology.
  • Shift - Cycles the vertices by "U Offset" and "V Offset".

U / V Offset /vtxuoff /vtxvoff - Cycles face or hull columns / rows when the Shift operation is selected.

Parameters - Meta Page

Meta-surface Weight - When selected, allows meta-surface weighting.

Weight /metaweight - Enter weight of meta-surface here when Meta-surface Weight is selected.

Uses / Works in Relation With

Opening and closing / clamping and unclamping faces and hulls.
Reversing primitives that are facing the opposite direction as adjacent primitives.
Modifying primitive colors.
Applying transforms per-primitive.

Local Variable

$PR - Primitive number.
$NPR - Total number of primitives.
$CEX, $CEY, $CEZ - The centroid of the primitive.
$DX, $DY, $DZ - The direction from the centroid of the SOP to the centroid of the primitive.
$NX, $NY, $NZ - The normal of the primitive. Will be 0 for some primitives like sphere and tube (which don't have normals).
$CR, $CG, $CB - Red, green and blue primitive color.
$CA - Primitive alpha color.
$WEIGHT - The current weight of any meta primitive. For non-meta primitives, this will be 0.
$GI - Primitive group index of the primitive. If the primitive is in more than one group, the index is of the first group it's a member of. Will be -1 if the primitive isn't in a group.
$GCEX, $GCEY, $GCEZ - The centroid of the primitive group this primitive is a member of. This it the same group as the one used for the $GI variable.

See Also