Cortex  10.0.0-a4
Public Member Functions | List of all members
IECore::CapturingRenderer Class Reference

#include <CapturingRenderer.h>

+ Inheritance diagram for IECore::CapturingRenderer:

Public Member Functions

 IE_CORE_DECLARERUNTIMETYPED (CapturingRenderer, Renderer)
 
void setOption (const std::string &name, ConstDataPtr value) override
 
ConstDataPtr getOption (const std::string &name) const override
 Get the value of a previously set option.
 
void camera (const std::string &name, const CompoundDataMap &parameters) override
 
void display (const std::string &name, const std::string &type, const std::string &data, const CompoundDataMap &parameters) override
 
void worldBegin () override
 
void worldEnd () override
 Finishes the world block.
 
void transformBegin () override
 
void transformEnd () override
 Returns to the transform state saved by the last transformBegin() call.
 
void setTransform (const Imath::M44f &m) override
 Sets the current transform.
 
void setTransform (const std::string &coordinateSystem) override
 
Imath::M44f getTransform () const override
 Returns the current transform.
 
Imath::M44f getTransform (const std::string &coordinateSystem) const override
 Returns the transform associated with the named coordinate system.
 
void concatTransform (const Imath::M44f &m) override
 Concatenates the specified transform onto the current transform.
 
void coordinateSystem (const std::string &name) override
 
void attributeBegin () override
 
void attributeEnd () override
 Return to the attribute state saved by the last call to attributeBegin().
 
void setAttribute (const std::string &name, ConstDataPtr value) override
 
ConstDataPtr getAttribute (const std::string &name) const override
 Return the value of the named attribute.
 
void shader (const std::string &type, const std::string &name, const CompoundDataMap &parameters) override
 Specifies a shader to be applied to subsequent primitives.
 
void light (const std::string &name, const std::string &handle, const CompoundDataMap &parameters) override
 Specifies a light to apply to subsequent primitives.
 
void illuminate (const std::string &lightHandle, bool on) override
 Turns the specified light on or off for the current attribute state.
 
void motionBegin (const std::set< float > &times) override
 
void motionEnd () override
 
void points (size_t numPoints, const PrimitiveVariableMap &primVars) override
 Renders a set of points.
 
void disk (float radius, float z, float thetaMax, const PrimitiveVariableMap &primVars) override
 
void curves (const CubicBasisf &basis, bool periodic, ConstIntVectorDataPtr numVertices, const IECore::PrimitiveVariableMap &primVars) override
 Renders a set of curves.
 
void text (const std::string &font, const std::string &text, float kerning=1.0f, const PrimitiveVariableMap &primVars=PrimitiveVariableMap()) override
 Renders some text.
 
void sphere (float radius, float zMin, float zMax, float thetaMax, const PrimitiveVariableMap &primVars) override
 
void image (const Imath::Box2i &dataWindow, const Imath::Box2i &displayWindow, const PrimitiveVariableMap &primVars) override
 
void mesh (ConstIntVectorDataPtr vertsPerFace, ConstIntVectorDataPtr vertIds, const std::string &interpolation, const PrimitiveVariableMap &primVars) override
 
void nurbs (int uOrder, ConstFloatVectorDataPtr uKnot, float uMin, float uMax, int vOrder, ConstFloatVectorDataPtr vKnot, float vMin, float vMax, const PrimitiveVariableMap &primVars) override
 Renders a nurbs surface.
 
void patchMesh (const CubicBasisf &uBasis, const CubicBasisf &vBasis, int nu, bool uPeriodic, int nv, bool vPeriodic, const PrimitiveVariableMap &primVars) override
 Render a patch mesh.
 
void geometry (const std::string &type, const CompoundDataMap &topology, const PrimitiveVariableMap &primVars) override
 Generic call for specifying renderer specify geometry types.
 
void procedural (ProceduralPtr proc) override
 Renders a piece of procedural geometry.
 
void instanceBegin (const std::string &name, const CompoundDataMap &parameters) override
 Starts the description of a portion of a scene to be instanced.
 
void instanceEnd () override
 Ends the description of an instance.
 
void instance (const std::string &name) override
 
DataPtr command (const std::string &name, const CompoundDataMap &parameters) override
 
void editBegin (const std::string &editType, const CompoundDataMap &parameters) override
 
void editEnd () override
 Ends the current scene edit.
 
ConstGroupPtr world ()
 
- Public Member Functions inherited from IECore::Renderer
 IE_CORE_DECLARERUNTIMETYPED (Renderer, RunTimeTyped)
 
 IE_CORE_DECLAREPTR (Procedural)
 
 IE_CORE_DECLAREPTR (ExternalProcedural)
 
- Public Member Functions inherited from IECore::RunTimeTyped
 IE_CORE_DECLAREMEMBERPTR (RunTimeTyped)
 
virtual TypeId typeId () const
 
virtual const char * typeName () const
 
virtual bool isInstanceOf (TypeId typeId) const
 
virtual bool isInstanceOf (const char *typeName) const
 
- Public Member Functions inherited from IECore::RefCounted
 IE_CORE_DECLAREMEMBERPTR (RefCounted)
 
void addRef () const
 Add a reference to the current object.
 
void removeRef () const
 Remove a reference from the current object.
 
RefCount refCount () const
 Returns the current reference count.
 

Additional Inherited Members

- Public Types inherited from IECore::RunTimeTyped
typedef RefCounted BaseClass
 A typedef for the class this class derives from. All RunTimeTyped classes define this typedef.
 
- Public Types inherited from IECore::RefCounted
typedef size_t RefCount
 
- Static Public Member Functions inherited from IECore::RunTimeTyped
static TypeId staticTypeId ()
 Returns the TypeId for this class, without needing an instance.
 
static const char * staticTypeName ()
 Returns the type name for this class, without needing an instance.
 
static TypeId baseTypeId ()
 
static const char * baseTypeName ()
 
static bool inheritsFrom (TypeId typeId)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (const char *typeName)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (TypeId type, TypeId baseType)
 Returns true if type inherits from baseType.
 
static bool inheritsFrom (const char *typeName, const char *baseTypeName)
 Returns true if typeName inherits from baseTypeName.
 
static TypeId baseTypeId (TypeId typeId)
 Returns the base type of the given type, or InvalidTypeId if no such base exists.
 
static const std::vector< TypeId > & baseTypeIds (TypeId typeId)
 
static const std::set< TypeId > & derivedTypeIds (TypeId typeId)
 
static TypeId typeIdFromTypeName (const char *typeName)
 
static const char * typeNameFromTypeId (TypeId typeId)
 
static void registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId)
 Allows external modules to register their own type ids.
 
- Protected Types inherited from IECore::RunTimeTyped
typedef std::map< TypeId, TypeIdBaseTypeRegistryMap
 
typedef std::map< TypeId, std::vector< TypeId > > BaseTypesRegistryMap
 
typedef std::map< TypeId, std::set< TypeId > > DerivedTypesRegistryMap
 
typedef tbb::spin_rw_mutex Mutex
 
typedef std::map< TypeId, std::string > TypeIdsToTypeNamesMap
 
typedef std::map< std::string, TypeIdTypeNamesToTypeIdsMap
 
- Static Protected Member Functions inherited from IECore::RunTimeTyped
static BaseTypeRegistryMap & baseTypeRegistry ()
 
static DerivedTypesRegistryMap & derivedTypesRegistry ()
 
static BaseTypesRegistryMap & completeBaseTypesRegistry ()
 
static DerivedTypesRegistryMap & completeDerivedTypesRegistry ()
 
static void derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &)
 
static TypeIdsToTypeNamesMap & typeIdsToTypeNames ()
 
static TypeNamesToTypeIdsMap & typeNamesToTypeIds ()
 
- Static Protected Attributes inherited from IECore::RunTimeTyped
static Mutex g_baseTypeIdsMutex
 
static Mutex g_derivedTypeIdsMutex
 

Detailed Description

The CapturingRenderer doesn't render images at all, but instead turns what it is given into IECore Groups and Primitives which can then be used for further processing. Currently it doesn't support any calls before worldBegin(), as there is no IECore class to represent an entire scene. The world generated by the renderer can be retrieved as an IECore::Group using the world() method.

Member Function Documentation

void IECore::CapturingRenderer::attributeBegin ( )
overridevirtual

Push a new attribute state onto the attribute stack. This is identical to the current state, but subsequent calls to setAttribute() will be discarded by the matching attributeEnd().

Implements IECore::Renderer.

void IECore::CapturingRenderer::camera ( const std::string &  name,
const CompoundDataMap parameters 
)
overridevirtual

Creates a named camera at the position defined by the current transform. The camera looks down negative Z, with screen space left to right being positive X and screen space top to bottom being positive Y. The last camera specified before worldBegin() is considered to be the camera for rendering through - other cameras may be used in implementation specific ways by Renderer subclasses.

Standard Parameters

The following standard parameters should be supported by all implementations wherever possible - they are largely based on the RenderMan specification :
\li <b>"resolution" V2iData</b><br>
The resolution of any output images. Should default to 640x480 if not specified.
  • "pixelAspectRatio" FloatData
    The xSize/ySize aspect ratio for a pixel.
  • "screenWindow" Box2fData
    The region in screen space which is mapped to the output resolution. If unspecified then this should default to -1,1 in the smallest image dimension and the other dimension should be sized appropriately to preserve pixel aspect ratio.
  • "cropWindow" Box2fData
    The region in raster space which should actually be rendered - this allows just a section of the full resolution to be rendered. Note that raster space runs from 0,0 at the top left to 1,1 at the bottom right. Defaults to 0,0 1,1 if not specified.
  • "projection" StringData
    The projection that determines how camera coordinates are converted to screen space coordinates. Implementations should support "perspective" and "orthographic", with orthographic being the default if not specified.
  • "projection:fov" FloatData
    In the case of the "projection" parameter specifying a perspective projection, this specifies the field of view (in degrees) which is visible between -1 and 1 in screen space. Defaults to 90 degrees if unspecified.
  • "clippingPlanes" V2fData
    The near and far clipping planes. Defaults to 0.01, 100000 if unspecified.
  • "shutter" V2fData
    The time interval for which the shutter is open - this is used in conjunction with the times passed to motionBegin() to specify motion blur. Defaults to 0,0 if unspecified.

Implements IECore::Renderer.

DataPtr IECore::CapturingRenderer::command ( const std::string &  name,
const CompoundDataMap parameters 
)
overridevirtual

Generic call for executing arbitrary renderer commands. This is intended to allow derived classes to support calls such as RiMakeTexture via calls of the form renderer->command( "ri:makeTexture", ... ).

Renderers supporting arbitrary clipping planes should implement a "clippingPlane" command which must be issued before worldBegin(), and which makes a clipping plane using the current transformation.

Todo:
Make a dedicated virtual clippingPlane() method for the next major version.

Implements IECore::Renderer.

void IECore::CapturingRenderer::coordinateSystem ( const std::string &  name)
overridevirtual

Creates a named coordinate system from the current transform. Coordinate systems are scoped by attributeBegin/attributeEnd blocks.

Implements IECore::Renderer.

void IECore::CapturingRenderer::disk ( float  radius,
float  z,
float  thetaMax,
const PrimitiveVariableMap primVars 
)
overridevirtual

Renders a disk of the specified radius on the xy plane, at the specified z value. If the "rightHandedOrientation" attribute is true then the normal faces down positive z, otherwise it faces down negative z.

Implements IECore::Renderer.

void IECore::CapturingRenderer::display ( const std::string &  name,
const std::string &  type,
const std::string &  data,
const CompoundDataMap parameters 
)
overridevirtual

Specifies an image to be output from the renderer. In the case of file outputs name specified the filename. type specifies the type of output to create and data specifies the data to be output, for instance "rgba". parameters provides an implementation specific set of parameters to control other aspects of the image created. It is only valid to call this before worldBegin.

Implements IECore::Renderer.

void IECore::CapturingRenderer::editBegin ( const std::string &  editType,
const CompoundDataMap parameters 
)
overridevirtual

Starts a new scene edit of the specified type. The standard functions above for declaring the scene can then be used to perform the edit.

Todo:
Better define the semantics of this function as we implement it for different renderers.

Implements IECore::Renderer.

void IECore::CapturingRenderer::image ( const Imath::Box2i &  dataWindow,
const Imath::Box2i &  displayWindow,
const PrimitiveVariableMap primVars 
)
overridevirtual

Renders an image.

Todo:
Clarify the intended use of dataWindow and displayWindow.

Implements IECore::Renderer.

void IECore::CapturingRenderer::instance ( const std::string &  name)
overridevirtual

Instantiates a previously described instance at the current transform position, and using the current attribute state.

Implements IECore::Renderer.

void IECore::CapturingRenderer::mesh ( ConstIntVectorDataPtr  vertsPerFace,
ConstIntVectorDataPtr  vertIds,
const std::string &  interpolation,
const PrimitiveVariableMap primVars 
)
overridevirtual

Renders a mesh. The geometric normal of a face will be facing camera if the winding order of its vertices is anticlockwise from the point of view of the camera and the "rightHandedOrientation" attribute is true. If the "rightHandedOrientation" attribute is false then faces whose vertices wind /clockwise/ with respect to the camera are considered forward facing instead.

Implements IECore::Renderer.

void IECore::CapturingRenderer::motionBegin ( const std::set< float > &  times)
overridevirtual

Starts a new motion block. You should then make times.size() calls to one of the primitive or transform functions to specify the motion for the block.

Implements IECore::Renderer.

void IECore::CapturingRenderer::motionEnd ( )
overridevirtual

Ends a motion block. Should be called when times.size() calls to an appropriate primitive or transform function have been made following a motionBegin() call.

Implements IECore::Renderer.

void IECore::CapturingRenderer::setAttribute ( const std::string &  name,
ConstDataPtr  value 
)
overridevirtual
Implementation specific procedural attributes :
  • "cp:procedural:reentrant" BoolData true
    When true, procedurals may be evaluated in multiple parallel threads. When false they will be evaluated from the thread they were specified from.

Implements IECore::Renderer.

void IECore::CapturingRenderer::setOption ( const std::string &  name,
ConstDataPtr  value 
)
overridevirtual
Implementation specific options :
  • "cp:objectFilter" StringVectorData []
    Use this to specify a list of object filters. Procedurals and primitives where the "name" renderer attribute does not match one of the filters will be skipped. The "name" attribute is interpreted as a path, and if a path is requested, all parents of that path will be output as well. For example, if you set the option to [ "/root/leftArm/thumb" ], "/root", "/root/leftArm" and "/root/leftArm/thumb" will be output. Objects without a name will always be output. The filters also support wildcards, so you can specify things like "/root/wheel*Rim/bolt", "/root/torso/rib*", and "/root/*", the last of which will output "/root" and all its descendants.

Implements IECore::Renderer.

void IECore::CapturingRenderer::setTransform ( const std::string &  coordinateSystem)
overridevirtual

Sets the current transform to a coordinate system previously created with a call to coordinateSystem().

Implements IECore::Renderer.

void IECore::CapturingRenderer::sphere ( float  radius,
float  zMin,
float  zMax,
float  thetaMax,
const PrimitiveVariableMap primVars 
)
overridevirtual

Renders a sphere of the specified radius. zMin and zMax are measured as a proportion of the radius - so no matter what the radius, the default values will always give a full sphere. If the "rightHandedOrientation" attribute is true then the normals point outwards, otherwise they point inwards.

Todo:
Give this the default values it talks about.

Implements IECore::Renderer.

void IECore::CapturingRenderer::transformBegin ( )
overridevirtual

Push a new transform state identical to the current one. Modifications can then be made locally before calling transformEnd() to return to the previous transform state.

Implements IECore::Renderer.

ConstGroupPtr IECore::CapturingRenderer::world ( )

Returns the world that was captured.

Todo:
If we had a class for representing whole Scenes (including stuff before worldBegin) then we could have a scene() method instead.
void IECore::CapturingRenderer::worldBegin ( )
overridevirtual

Starts the world block and resets the current transform to the identity.

Implements IECore::Renderer.


The documentation for this class was generated from the following file: