[SESI logo]

Houdini Development Toolkit - Version 6.5

Side Effects Software Inc. 2004

Geometry

Primitive Base Class

Houdini supports a number of new primitive types.
These types are broken into a hierarchy of class types:

The GEO_Primitive class contains a number of public methods, the most significant of which are:

  • unsigned getPrimitiveId()
    This will return an unsigned mask identifying the particular primitive type. Each mask is a unique bit listed in GEO_PrimType.h

  • UT_Vector3 computeNormal()
    This will return the primitives' normal, (not to be confused with a point normal). For certain types (ie sphere) this operation is ill-defined and returns (0,0,0).

  • void reverse()
    This will reverse a primitive's vertex list, negating the primitive normal. In the case of GEO_Hull reverseU() and reverseV() are available.

  • void addPointRefToGroup(GB_PointGroup &grp)
    This will add all points referenced by the primitive into the given pointgroup. This is useful for collecting all points referenced by one or more primitives.

  • GEO_Detail *getParent() const
    This will return the container class of which this primitive is a member.

  • int isPointUsed(GB_Element *pt) const
    This will return 1 if and only if the primitive contains the point.

  • unsigned getVertexCount() const
    This will return the number of vertices contained in the primitive.

  • GEO_Primitive *copy(void) const
    This will return a similar primitive containing the same data and attributes as the original.

  • void transform(const UT_Matrix4 &)
    This will apply(multiply) a transformation matrix to each point in a primitive.

  • int vertexApply(int (*func)(GB_Vertex &vtx, void *), void *data = 0)
    This applies the function 'func' to each vertex of the primitive, stopping when the function returns a non-zero value. It returns the value of the last function applied. Note this function may be used to create functions similar to transform, addPointRefToGroup, getVertexCount, etc, when the primitive contains no shared points.

  • virtual int evaluatePoint(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const virtual int evaluateNormalVector(UT_Vector3 &nml, float u, float v=0) const
    These evaluate the position, the derivative or the normal at domain point (u,v), where u and v must be in the [0,1] range. "v" and "dv" are ignored when dealing with one-dimensional types such as circles and polygons. Both methods return 0 if OK and -1 otherwise. The normal is not normalized.

  • Primitive Instantiation Classes

    None of the leaf GEO primitive classes can be instantiated. To build a primitive within the geometry detail you must use the GU library.

    A GU primitive is multiply derived from GEO_Primitive and GU_Primitive. The GU hierarchy is listed below:

    Each leaf in the hierarchy, aside from GU_Curve and GU_TPSurf, can be instantiated by calling either its constructor or the class static ::build() method.

    The constructor does not sufficiently initialize the data structure, and is meant to be used mostly internally. Therefore, we strongly recommend that you always use the ::build() method for instantiation.

    The code below illustrates how to create a closed, 4 point polygon:

    GU_Detail gdp; GU_PrimPoly *poly; if (poly = GU_PrimPoly::build(&gdp, 4, GU_POLY_CLOSED)) { // Assign some value to each vertex: for (int i = 0; i < poly->getVertexCount(); i++) (*poly)(i).getPos().assign(i,0,0,1); }

    To delete a primitive, you need to delete it from the gdp which contains it. Calling "delete prim;" is dangerous as the primitive will not be removed from the gdp. Instead, to delete a primitive created by the previous code, use:

    gdp->deletePrimitive(poly); Note that you do not have to explicitly call "delete poly;" yourself, as the deletePrimitive method will do that for you.

    GU_Primitive is a verb class that defines basic utility operations to be implemented by the derived classes. The most significant GU_Primitive methods are:

  • virtual GEO_Primitive *convert(GU_ConvertParms &parms, GB_PointGroup *usedpts = 0) = 0
    This converts the primitive to the specified type and deletes the original.

  • virtual GEO_Primitive *convertNew(GU_ConvertParms &parms) = 0
    This adds a new primitive by converting the original to the specified type. The original is preserved.

  • virtual void normal(int noff) const = 0
    This computes the normals of the points referenced by the primitive, and stores the result at the given offset in the point normal attribute.

  • If you are working with a GEO_Primitive pointer but want to call a GU_Primitive method, you must use the GEO_Primitive::castTo() method before doing so. The reason is that all GU primitives are multiply derived from GEO_Primitive and GU_Primitive, and GU_Primitive appears last in the inheritance list: GEO_Primitive *prim; ((GU_Primitive*)prim->castTo())->normal(0);
    Although GU_Primitive contains a fair number of utility methods, most high level operations are defined in GU_Detail (geometry detail), the container of all primitives, points, groups, and attributes.
    Table of Contents
    Operators | Surface Operations | Particle Operations | Composite Operators | Channel Operators
    Material & Texture | Objects | Command and Expression | Render Output |
    Mantra Shaders | Utility Classes | Geometry Library | Image Library | Clip Library
    Customizing UI | Questions & Answers

    Copyright © 2004 Side Effects Software Inc.
    477 Richmond Street West, Toronto, Ontario, Canada M5V 3E7