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.
| ) |
| ) |
| ) |
| ) |
| ) |
| ) |
| ) |
| ) |
| storage) |
UNIFORM, VARYING, VERTEX,
FACEVARYING or FACEVERTEX. The method will never be called
when CONSTANT or USER variables are created.
| name, storage, type, multiplicity=1, user_n=0) |
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 [3]" 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]=(1,2,3)
>>> for f in s: print f
...
(0, 0, 0)
(1, 2, 3)
(0, 0, 0)
(0, 0, 0)
| name) |
| ) |
| name) |
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.
| ) |
| targetgeom) |
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