Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::Shape Class Referenceabstract

Abstract base class of all shapes. More...

#include <mitsuba/render/shape.h>

+ Inheritance diagram for mitsuba::Shape:

Public Member Functions

virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
Query functions to be implemented in subclasses
virtual std::string getName () const
 Return the name of this shape (e.g. the filename) More...
 
virtual bool isCompound () const
 Is this a compound shape consisting of several sub-objects? More...
 
virtual ShapegetElement (int i)
 Return a sub-element of a compound shape. More...
 
virtual Float getSurfaceArea () const
 Return the shape's surface area. More...
 
virtual AABB getAABB () const =0
 Return a bounding box containing the shape. More...
 
virtual AABB getClippedAABB (const AABB &box) const
 Returns the minimal axis-aligned bounding box of this shape when clipped to another bounding box. More...
 
virtual ref< TriMeshcreateTriMesh ()
 Create a triangle mesh approximation of this shape. More...
 
Ray tracing routines
virtual bool rayIntersect (const Ray &ray, Float mint, Float maxt, Float &t, void *temp) const
 Fast ray intersection test. More...
 
virtual bool rayIntersect (const Ray &ray, Float mint, Float maxt) const
 Fast ray intersection test for visibility queries. More...
 
virtual void fillIntersectionRecord (const Ray &ray, const void *temp, Intersection &its) const
 Given that an intersection has been found, create a detailed intersection record. More...
 
virtual void getNormalDerivative (const Intersection &its, Vector &dndu, Vector &dndv, bool shadingFrame=true) const
 Return the derivative of the normal vector with respect to the UV parameterization. More...
 
void getCurvature (const Intersection &its, Float &H, Float &K, bool shadingFrame=true) const
 Compute the Gaussian and mean curvature at the given surface intersection. More...
 
virtual void adjustTime (Intersection &its, Float time) const
 
virtual const KDTreeBase< AABB > * getKDTree () const
 Return the internal kd-tree of this shape (if any) More...
 
Sampling routines
virtual void samplePosition (PositionSamplingRecord &pRec, const Point2 &sample) const
 Sample a point on the surface of this shape instance (with respect to the area measure) More...
 
virtual Float pdfPosition (const PositionSamplingRecord &pRec) const
 Query the probability density of samplePosition() for a particular point on the surface. More...
 
virtual void sampleDirect (DirectSamplingRecord &dRec, const Point2 &sample) const
 Sample a point on the surface of this shape instance (with respect to the solid angle measure) More...
 
virtual Float pdfDirect (const DirectSamplingRecord &dRec) const
 Query the probability density of sampleDirect() for a particular point on the surface. More...
 
Miscellaneous
bool isMediumTransition () const
 Does the surface of this shape mark a medium transition? More...
 
MediumgetInteriorMedium ()
 Return the medium that lies on the interior of this shape (NULL == vacuum) More...
 
const MediumgetInteriorMedium () const
 Return the medium that lies on the interior of this shape (NULL == vacuum, const version) More...
 
MediumgetExteriorMedium ()
 Return the medium that lies on the exterior of this shape (NULL == vacuum) More...
 
const MediumgetExteriorMedium () const
 Return the medium that lies on the exterior of this shape (NULL == vacuum, const version) More...
 
bool hasSubsurface () const
 Does this shape have a sub-surface integrator? More...
 
SubsurfacegetSubsurface ()
 Return the associated sub-surface integrator. More...
 
const SubsurfacegetSubsurface () const
 Return the associated sub-surface integrator. More...
 
bool isEmitter () const
 Is this shape also an area emitter? More...
 
EmittergetEmitter ()
 Return the associated emitter (if any) More...
 
const EmittergetEmitter () const
 Return the associated emitter (if any) More...
 
void setEmitter (Emitter *emitter)
 Set the emitter of this shape. More...
 
bool isSensor () const
 Is this shape also an area sensor? More...
 
SensorgetSensor ()
 Return the associated sensor (if any) More...
 
const SensorgetSensor () const
 Return the associated sensor (if any) More...
 
bool hasBSDF () const
 Does the shape have a BSDF? More...
 
const BSDFgetBSDF () const
 Return the shape's BSDF. More...
 
BSDFgetBSDF ()
 Return the shape's BSDF. More...
 
void setBSDF (BSDF *bsdf)
 Set the BSDF of this shape. More...
 
virtual size_t getPrimitiveCount () const =0
 Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape. More...
 
virtual size_t getEffectivePrimitiveCount () const =0
 Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape. More...
 
void copyAttachments (Shape *shape)
 Copy attachments (BSDF, Emitter, ..) from another shape. More...
 
ConfigurableObject interface
virtual void configure ()
 Called once after constructing the object. More...
 
virtual void serialize (Stream *stream, InstanceManager *manager) const
 Serialize this shape to a stream. More...
 
void addChild (const std::string &name, ConfigurableObject *child)
 Add a child (e.g. a emitter/sub surface integrator) to this shape. More...
 
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
- Public Member Functions inherited from mitsuba::ConfigurableObject
virtual void setParent (ConfigurableObject *parent)
 Notify the ConfigurableObject instance about its parent object. More...
 
void addChild (ConfigurableObject *child)
 Add an unnamed child. More...
 
const std::string & getID () const
 Return the identifier associated with this instance (or "unnamed") More...
 
void setID (const std::string &name)
 Set the identifier associated with this instance. More...
 
const PropertiesgetProperties () const
 Return the properties object that was originally used to create this instance. More...
 
- Public Member Functions inherited from mitsuba::SerializableObject
 SerializableObject (Stream *stream, InstanceManager *manager)
 Unserialize a serializable object. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 
virtual std::string toString () const
 Return a human-readable string representation of the object's contents. More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::ConfigurableObject
static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::SerializableObject
static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

 Shape (const Properties &props)
 Create a new shape. More...
 
 Shape (Stream *stream, InstanceManager *manager)
 Unserialize a shape. More...
 
virtual ~Shape ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from mitsuba::ConfigurableObject
virtual ~ConfigurableObject ()
 Virtual destructor. More...
 
 ConfigurableObject (const Properties &props)
 Construct a configurable object. More...
 
 ConfigurableObject (Stream *stream, InstanceManager *manager)
 Unserialize a configurable object. More...
 
- Protected Member Functions inherited from mitsuba::SerializableObject
 SerializableObject ()
 Construct a serializable object. More...
 
virtual ~SerializableObject ()
 Virtual deconstructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

std::string m_name
 
ref< BSDFm_bsdf
 
ref< Subsurfacem_subsurface
 
ref< Emitterm_emitter
 
ref< Sensorm_sensor
 
ref< Mediumm_interiorMedium
 
ref< Mediumm_exteriorMedium
 
- Protected Attributes inherited from mitsuba::ConfigurableObject
Properties m_properties
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Detailed Description

Abstract base class of all shapes.

Constructor & Destructor Documentation

mitsuba::Shape::Shape ( const Properties props)
protected

Create a new shape.

mitsuba::Shape::Shape ( Stream stream,
InstanceManager manager 
)
protected

Unserialize a shape.

virtual mitsuba::Shape::~Shape ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

void mitsuba::Shape::addChild ( const std::string &  name,
ConfigurableObject child 
)
virtual

Add a child (e.g. a emitter/sub surface integrator) to this shape.

Reimplemented from mitsuba::ConfigurableObject.

void mitsuba::Shape::addChild ( ConfigurableObject child)
inline

Add an unnamed child.

virtual void mitsuba::Shape::adjustTime ( Intersection its,
Float  time 
) const
virtual

Adjust an intersection record to a different time value

virtual void mitsuba::Shape::configure ( )
virtual

Called once after constructing the object.

Reimplemented from mitsuba::ConfigurableObject.

Reimplemented in mitsuba::TriMesh.

void mitsuba::Shape::copyAttachments ( Shape shape)

Copy attachments (BSDF, Emitter, ..) from another shape.

virtual ref<TriMesh> mitsuba::Shape::createTriMesh ( )
virtual

Create a triangle mesh approximation of this shape.

This function is used by the realtime preview and certain integrators, which rely on hardware rasterization.

The default implementation simply returns NULL.

Reimplemented in mitsuba::TriMesh.

virtual void mitsuba::Shape::fillIntersectionRecord ( const Ray ray,
const void *  temp,
Intersection its 
) const
virtual

Given that an intersection has been found, create a detailed intersection record.

Remarks
This function is not directly exposed in Python. It is implicitly called as part of rayIntersect.
virtual AABB mitsuba::Shape::getAABB ( ) const
pure virtual

Return a bounding box containing the shape.

Implemented in mitsuba::TriMesh.

const BSDF* mitsuba::Shape::getBSDF ( ) const
inline

Return the shape's BSDF.

BSDF* mitsuba::Shape::getBSDF ( )
inline

Return the shape's BSDF.

virtual const Class* mitsuba::Shape::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from mitsuba::ConfigurableObject.

Reimplemented in mitsuba::TriMesh.

virtual AABB mitsuba::Shape::getClippedAABB ( const AABB box) const
virtual

Returns the minimal axis-aligned bounding box of this shape when clipped to another bounding box.

This is extremely important to construct decent kd-trees. The default implementation just takes the bounding box returned by getAABB() and clips it to box.

void mitsuba::Shape::getCurvature ( const Intersection its,
Float H,
Float K,
bool  shadingFrame = true 
) const

Compute the Gaussian and mean curvature at the given surface intersection.

Parameters
itsIntersection record associated with the query
HParameter used to store the mean curvature
KParameter used to store the Gaussian curvature
shadingFrameSpecifies whether to compute the curvature based on the geometric normal or the shading normal of the surface
Remarks
In Python, the signature of this function is H, K = shape.getCurvature(its, shadingFrame)
virtual size_t mitsuba::Shape::getEffectivePrimitiveCount ( ) const
pure virtual

Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape.

Includes instanced geometry

Implemented in mitsuba::TriMesh.

virtual Shape* mitsuba::Shape::getElement ( int  i)
virtual

Return a sub-element of a compound shape.

When expanding shapes, the scene will repeatedly call this function with increasing indices. Returning NULL indicates that no more elements are available.

Emitter* mitsuba::Shape::getEmitter ( )
inline

Return the associated emitter (if any)

const Emitter* mitsuba::Shape::getEmitter ( ) const
inline

Return the associated emitter (if any)

Medium* mitsuba::Shape::getExteriorMedium ( )
inline

Return the medium that lies on the exterior of this shape (NULL == vacuum)

const Medium* mitsuba::Shape::getExteriorMedium ( ) const
inline

Return the medium that lies on the exterior of this shape (NULL == vacuum, const version)

Medium* mitsuba::Shape::getInteriorMedium ( )
inline

Return the medium that lies on the interior of this shape (NULL == vacuum)

const Medium* mitsuba::Shape::getInteriorMedium ( ) const
inline

Return the medium that lies on the interior of this shape (NULL == vacuum, const version)

virtual const KDTreeBase<AABB>* mitsuba::Shape::getKDTree ( ) const
virtual

Return the internal kd-tree of this shape (if any)

This function is used by the kd-tree visualization in the interactive walkthrough. The default implementation simply returns NULL.

Remarks
This function is not exposed in Python
virtual std::string mitsuba::Shape::getName ( ) const
virtual

Return the name of this shape (e.g. the filename)

virtual void mitsuba::Shape::getNormalDerivative ( const Intersection its,
Vector dndu,
Vector dndv,
bool  shadingFrame = true 
) const
virtual

Return the derivative of the normal vector with respect to the UV parameterization.

This can be used to compute Gaussian and principal curvatures, amongst other things.

Parameters
itsIntersection record associated with the query
dnduParameter used to store the partial derivative of the normal vector with respect to u
dndvParameter used to store the partial derivative of the normal vector with respect to v
shadingFrameSpecifies whether to compute the derivative of the geometric normal or the shading normal of the surface
Remarks
In Python, the signature of this function is dndu, dndv = shape.getNormalDerivative(its, shadingFrame)

Reimplemented in mitsuba::TriMesh.

virtual size_t mitsuba::Shape::getPrimitiveCount ( ) const
pure virtual

Return the number of primitives (triangles, hairs, ..) contributed to the scene by this shape.

Does not include instanced geometry

Implemented in mitsuba::TriMesh.

Sensor* mitsuba::Shape::getSensor ( )
inline

Return the associated sensor (if any)

const Sensor* mitsuba::Shape::getSensor ( ) const
inline

Return the associated sensor (if any)

Subsurface* mitsuba::Shape::getSubsurface ( )
inline

Return the associated sub-surface integrator.

const Subsurface* mitsuba::Shape::getSubsurface ( ) const
inline

Return the associated sub-surface integrator.

virtual Float mitsuba::Shape::getSurfaceArea ( ) const
virtual

Return the shape's surface area.

Assumes that the object is not undergoing some kind of time-dependent scaling.

The default implementation throws an exception

Reimplemented in mitsuba::TriMesh.

bool mitsuba::Shape::hasBSDF ( ) const
inline

Does the shape have a BSDF?

bool mitsuba::Shape::hasSubsurface ( ) const
inline

Does this shape have a sub-surface integrator?

virtual bool mitsuba::Shape::isCompound ( ) const
virtual

Is this a compound shape consisting of several sub-objects?

bool mitsuba::Shape::isEmitter ( ) const
inline

Is this shape also an area emitter?

bool mitsuba::Shape::isMediumTransition ( ) const
inline

Does the surface of this shape mark a medium transition?

bool mitsuba::Shape::isSensor ( ) const
inline

Is this shape also an area sensor?

virtual Float mitsuba::Shape::pdfDirect ( const DirectSamplingRecord dRec) const
virtual

Query the probability density of sampleDirect() for a particular point on the surface.

Parameters
dRecA direct sampling record, which specifies the query location. Note that this record need not be completely filled out. The important fields are p, n, ref, dist, d, measure, and uv.
pAn arbitrary point used to define the solid angle measure
virtual Float mitsuba::Shape::pdfPosition ( const PositionSamplingRecord pRec) const
virtual

Query the probability density of samplePosition() for a particular point on the surface.

This method will generally return the inverse of the surface area.

Parameters
pRecA position record, which will be used to return the sampled position, as well as auxilary information about the sample.

Reimplemented in mitsuba::TriMesh.

virtual bool mitsuba::Shape::rayIntersect ( const Ray ray,
Float  mint,
Float  maxt,
Float t,
void *  temp 
) const
virtual

Fast ray intersection test.

Check whether the shape is intersected by the given ray. Some temporary space (MTS_KD_INTERSECTION_TEMP-4 bytes) is, supplied which can be used to cache information about the intersection. The function fillIntersectionRecord() can later use this information to fill in a detailed intersection record.

Remarks
In Python, this function also calls fillIntersectionRecord and has the signature intersection = shape.rayIntersect(ray, mint, maxt)
virtual bool mitsuba::Shape::rayIntersect ( const Ray ray,
Float  mint,
Float  maxt 
) const
virtual

Fast ray intersection test for visibility queries.

Check whether the shape is intersected by the given ray. No details about the intersection are returned, hence the function is only useful for visibility queries. For most shapes, this will simply call forward the call to rayIntersect. When the shape actually contains a nested kd-tree, some optimizations are possible.

Remarks
This function is not exposed in Python
virtual void mitsuba::Shape::sampleDirect ( DirectSamplingRecord dRec,
const Point2 sample 
) const
virtual

Sample a point on the surface of this shape instance (with respect to the solid angle measure)

The sample density should ideally be uniform in direction as seen from the reference point dRec.p.

This general approach for sampling positions is named "direct" sampling throughout Mitsuba motivated by direct illumination rendering techniques, which represent the most important application.

When no implementation of this function is supplied, the Shape class will revert to the default approach, which piggybacks on sampleArea(). This usually results in a a suboptimal sample placement, which can manifest itself in the form of high variance

Parameters
dRecA direct sampling record that specifies the reference point and a time value. After the function terminates, it will be populated with the position sample and related information
sampleA uniformly distributed 2D vector
virtual void mitsuba::Shape::samplePosition ( PositionSamplingRecord pRec,
const Point2 sample 
) const
virtual

Sample a point on the surface of this shape instance (with respect to the area measure)

The returned sample density will be uniform over the surface.

Parameters
pRecA position record, which will be used to return the sampled position, as well as auxilary information about the sample.
sampleA uniformly distributed 2D vector

Reimplemented in mitsuba::TriMesh.

virtual void mitsuba::Shape::serialize ( Stream stream,
InstanceManager manager 
) const
virtual

Serialize this shape to a stream.

Reimplemented from mitsuba::ConfigurableObject.

Reimplemented in mitsuba::TriMesh.

void mitsuba::Shape::setBSDF ( BSDF bsdf)
inline

Set the BSDF of this shape.

void mitsuba::Shape::setEmitter ( Emitter emitter)
inline

Set the emitter of this shape.

Member Data Documentation

ref<BSDF> mitsuba::Shape::m_bsdf
protected
ref<Emitter> mitsuba::Shape::m_emitter
protected
ref<Medium> mitsuba::Shape::m_exteriorMedium
protected
ref<Medium> mitsuba::Shape::m_interiorMedium
protected
std::string mitsuba::Shape::m_name
protected
ref<Sensor> mitsuba::Shape::m_sensor
protected
ref<Subsurface> mitsuba::Shape::m_subsurface
protected
Class* mitsuba::Shape::m_theClass
static

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