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.
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 [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)
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