-
Notifications
You must be signed in to change notification settings - Fork 124
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
from IECore import *
from random import *
def generatePoints( bbox, npoints ):
seed(0)
size = bbox.size()
pdata = V3fVectorData()
for i in range(npoints):
pdata.append( V3f( random() * size.x + bbox.min.x,
random() * size.y + bbox.min.y,
random() * size.z + bbox.min.z ) )
return PointsPrimitive( pdata )
class pointRender(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 = None
self.__npoints = None
self.__bbox = None
def generatePoints(self, args):
if args['npoints'].value!=self.__npoints or args['bbox'].value!=self.__bbox:
self.__points = generatePoints( args['bbox'].value, args['npoints'].value )
self.__npoints = args['npoints'].value
self.__bbox = args['bbox'].value
return self.__points
def doBound(self, args) :
self.generatePoints(args)
return self.__points.bound()
def doRenderState(self, renderer, args) :
pass
def doRender(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