|
Houdini Development Toolkit - Version 6.5
Side Effects Software Inc. 2004
|
Geometry
Classes & Methods
Container Classes
The geometry libraries are divided among the following major classes:
- GB Geometry Base
- GD Geometry Domain
- GEO Geometry
- GU Geometry Utilities
- GQ Quad Edge
The Geometry Base Class (GB) contains a geometric description consisting
primarily of the following elements:
- A list of point elements
- A list of primitive elements
- A list of point element groups
- A list of primitive element groups
The Geometry Domain Class (GD) is derived from the GB class
and further defines primitives with trimmed surface and surface
domain information.
The Geometry Class (GEO) is derived from GD and further contains:
- A point attribute dictionary
- A primitive attribute dictionary
- A vertex attribute dictionary
- A detail attribute dictionary
The Geometry Utility Class (GU) is derived from GEO and contains
a number of functions for creating and manipulating primitives and points.
The Quad Edge Class (GQ) is closely related to the GU Class and contains
a number of methods containing quad edge algorithms.
Useful Data Structures
Points
A point is defined within the GEO_Point class and contains a position
and attribute data. The position is a UT_Vector4 object and is accessed
with the GEO_Point::getPos() method. Point objects are contained with a
geometry detail point list.
Vertices
A vertex is defined within the GEO_Vertex class and contains a reference to
a point object and attribute data. The point reference is accessed with
the GEO_Vertex::getPt() method which returns a pointer to a GEO_Point object.
The GEO_Vertex::getPos() method returns the UT_Vector4 object contained
within the point it references directly. Note that a point may be referenced
by more than one vertex, creating shared points, but vertices are never shared.
A vertex is contained within a primitive's vertex list.
Primitives
A primitive is defined within the GEO_Primitive class and contains attribute
data and a possible vertex list. Primitives are contained with a geometry
detail primitive list. Each primitive type in Houdini is subclassed from
this class and contains specific data. At this level there are a number of
useful access methods:
- int GEO_Primitive::getPrimitiveId()
This will return an unsigned mask identifying the particular primitive type.
- int GEO_Primitive::evaluatePoint( UT_Vector4 &pos, float u, float v = 0,
unsigned du=0, unsigned dv=0) const
This powerful method will assign pos with the position of the primitive
surface at any parametric location (u = 0..1, v = 0..1). Setting du
or dv will evaluate a derivative instead.
- GEO_Vertex &GEO_Primitive::getVertex(unsigned index)
This method will return a vertex from the primitive's vertex list.
- unsigned GEO_Primitive::getVertexCount()
Return the number of vertices contained within a primitive.
Groups
A group is a set of either primitive or point references (GB_PrimitiveGroup,
GB_PointGroup). Groups can be classified as either ordered or unordered and
are contained with a geometry detail group list. A geometry detail contains
methods dealing with primitive groups (similiar for point groups):
- GB_PrimitiveGroup *newPrimitiveGroup(const char *name, int internal = 0,
char *=0)
This will create a primitive group within the detail. If internal is
set to non-zero, the group will not be displayed or saved. The
internal groups are used within Houdini by certain functions.
To test whether a group is internal or not, it is possible to use the
getInternal() method on the group.
- destroyPrimitiveGroup(GB_PrimitiveGroup *grp)
Remove the group (but not its contents!)
Summary Example
This example function will show how the previous concepts can be used
to divide a detail's primitives into two groups: Primitives above the xy plane, and the primitives below. Note in this example the groups created are not
mutually exclusive since some primitives may have vertices above and below
the xy plane.
void
sort_prims(GEO_Detail *gdp)
{
GB_PrimitiveGroup *above_group, *below_group;
GEO_Primitive *prim;
int i;
int numv;
GEO_Vertex *vtx;
UT_Vector4 pos;
//
// create two groups for containing the primitive references
//
above_group = gdp->newPrimitiveGroup("above");
below_group = gdp->newPrimitiveGroup("below");
//
// this macro will iterate through each primitive in a geometry detail
//
FOR_ALL_PRIMITIVES(gdp, prim)
{
numv = prim->getVertexCount();
for (i = 0; i < numv; i++) // examine each vertex
{
vtx = &prim->getVertex(i);
pos = vtx->getPos(); // examine the vertex point reference
if (pos.z() <= 0) // examine the z component
below_group->add(prim);
else
above_group->add(prim);
}
}
}
Enhancements
The function can be modified to sort only polygons with the line:
if (prim->getPrimitiveId() == GEOPRIMPOLY)...
The sort can look at only the center of each primitive (regardless
or vertices) with:
prim->evaluatePoint(pos, 0.5, 0.5);
For information on how to create and manipulate specific primitives
refer to the Primitives section.
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