Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 129
ExamplesProceduralsPointRender
Ben Toogood edited this page Jun 13, 2013
·
2 revisions
This cookbook example demonstrates how to create and render a Cortex PointsPrimitive. The procedural creates a points primitive and fills it with a specified number of points, within a specified bounding box.
opengl
renderman
fromIECoreimport*fromrandomimport*defgeneratePoints( bbox, npoints ):
seed(0)
size=bbox.size()
pdata=V3fVectorData()
foriinrange(npoints):
pdata.append( V3f( random() *size.x+bbox.min.x,
random() *size.y+bbox.min.y,
random() *size.z+bbox.min.z ) )
returnPointsPrimitive( pdata )
classpointRender(ParameterisedProcedural) :
def__init__(self) : ParameterisedProcedural.__init__( self, "Description here." )
bbox=Box3fParameter( "bbox", "Bounds for points.", Box3f(V3f(0), V3f(1)) )
npoints=IntParameter( "npoints", "Number of points.", 100, minValue=0, maxValue=10000 )
width=FloatParameter( "width", "Point width", 0.05 )
self.parameters().addParameters( [ bbox, npoints, width ] )
self.__points=Noneself.__npoints=Noneself.__bbox=NonedefgeneratePoints(self, args): ifargs['npoints'].value!=self.__npointsorargs['bbox'].value!=self.__bbox:
self.__points=generatePoints( args['bbox'].value, args['npoints'].value )
self.__npoints=args['npoints'].valueself.__bbox=args['bbox'].valuereturnself.__pointsdefdoBound(self, args) : self.generatePoints(args)
returnself.__points.bound()
defdoRenderState(self, renderer, args) : passdefdoRender(self, renderer, args) : self.generatePoints(args)
self.__points['width'] =PrimitiveVariable( PrimitiveVariable.Interpolation.Constant, args['width'] )
self.__points.render( renderer )
registerRunTimeTyped( pointRender )- Introduction
- General Functionality
- Data Handling
- Parameters and Ops
- Point Primitives
- Mesh Primitives
- Image Primitives
- Procedurals
- Cortex & Python
- Cortex & Maya
- Cortex & Houdini