The GeomObject class is the base class for all geometries. Instances of this class are stored in the geom attribute of the world objects and can be shared among them.
Return the local axis aligned bounding box. The bounding box is given with respect to the local transformation L (which is not what you get from the transform slot of the world object).
Draw the geometry using OpenGL commands.
Return the multiplicity of UNIFORM variables.
Return the multiplicity of VARYING variables.
Return the multiplicity of VERTEX variables.
Return the multiplicity of FACEVARYING variables.
Return the multiplicity of FACEVERTEX variables.
Return a constraint object for primitive variable slots or None if the size of the slot should be unconstrained. This method is called when a new primitive variable is created. The returned constraint object is used for the array slot that holds the values of the variable. storage is the storage class of the new variable which will be one of UNIFORM, VARYING, VERTEX, FACEVARYING or FACEVERTEX. The method will never be called when CONSTANT or USER variables are created.
Attaches a new primitive variable to the geometry.
storage specifies the storage class, i.e. how many values are actually stored. It must be one of CONSTANT, UNIFORM, VARYING, VERTEX, FACEVARYING, FACEVERTEX or USER. The exact number of values depends on the actual geometry. However, CONSTANT is always exactly one value for the entire geometry and USER is a user defined number specified in user_n.
type is the type of the variable and must be one of INT, FLOAT, STRING, COLOR, POINT, VECTOR, NORMAL, MATRIX and HPOINT. If multiplicity is greater than 1, then an array with that size is created.
Creating a new variable will always create a new slot of that name as well. The slot is always an ArraySlot (even for CONSTANT variables). After you have created a variable you can use the corresponding slot to manipulate the values of the variable.
Here is an example of a “varying int ” variable that’s created on a sphere geometry. This means, the variable will consist of four 3-tuples of integers (one for each parametric corner).
>>> from cgkit.all import * >>> sg=SphereGeom() >>> sg.newVariable("foo", VARYING, INT, multiplicity=3) >>> for v in sg.iterVariables(): print v ... ('foo', cgkit._core.VarStorage.VARYING, cgkit._core.VarType.INT, 3) >>> s=sg.slot("foo") >>> s=(1,2,3) >>> for f in s: print f ... (0, 0, 0) (1, 2, 3) (0, 0, 0) (0, 0, 0)
Delete the primitive variable with the specified name.
Delete all primitive variables.
Search for a particular primitive variable and return its descriptor. None is returned if a variable called name cannot be found. The return value is a 4-tuple (name, storage class, type, multiplicity) describing the variable. See the newVariable() method for a description of the individual elements.
Return an iterator that iterates over all existing primitive variables. The iterator will return the same 4-tuple as returned by findVariable().
Convert the geometry into another type of geometry. targetgeom is another GeomObject that will receive the result of the conversion. If the conversion is not possible, a NotImplementedError exception is thrown.
In the following example, a box geometry is converted into a triangle mesh:
>>> bg=BoxGeom(segmentsx=3, segmentsy=3, segmentsz=3) >>> tm=TriMeshGeom() >>> bg.convert(tm) >>> print len(tm.verts) 56 >>> print len(tm.faces) 108