DD::Image::Scene Class Reference

Inherits DD::Image::Box3.

List of all members.

Public Member Functions

 Scene ()
virtual ~Scene ()
virtual void validate (int sample=0)
virtual void request (const ChannelSet &channels, int count)
MotionVectorType mb_type () const
Scenemb_scene () const
void geo (GeoOp *geo)
GeoOpgeo () const
const GeometryListobject_list () const
GeometryListobject_list ()
std::vector< DrawableGeo > * geo_list ()
unsigned objects () const
GeoInfoobject (unsigned n=0)
int sceneId () const
void time (float t)
float time () const
void format (const Format *f)
const Formatformat () const
void projection_mode (int p)
int projection_mode () const
void max_tessellation (int t)
int max_tessellation () const
const Boxscreen_bbox () const
const ChannelSetchannels () const
const ChannelSetshadow_channels () const
MatrixArraytransforms ()
const Matrix4matrix (int n)
const Matrix4inverse_matrix (int n)
const Matrix4camera_matrix () const
const Matrix4projection_matrix () const
const Matrix4format_matrix () const
MatrixArrayobject_transforms (unsigned n)
void set_shadow_scene (bool s)
bool is_shadow_scene () const
bool transparency () const
void transparency (bool v)
virtual void add_light (LightOp *)
virtual void add_lights (const std::vector< LightOp * > *light_list)
virtual void clear_lights ()
virtual bool evaluate_lights ()
TextureFilterfilter () const
void filter (TextureFilter *v)
void copyInfo (const Scene *scene)
const Quadtree< unsigned > * quadtree ()
bool testRayIntersection (Ray &ray, const VertexContext *vtx=NULL, const Iop *material=NULL)
virtual bool generate_render_primitives ()
unsigned render_primitives () const
unsigned displacement_primitives () const
virtual void add_render_primitive (rPrimitive *, PrimitiveContext *)
virtual void add_clipped_render_primitive (rPrimitive *)
virtual void add_clipped_displacement_render_primitive (rPrimitive *)
rPrimitiverenderable_primitive (unsigned n) const
rPrimitivedisplacement_primitive (unsigned n) const
void buildCircularTriangleList (unsigned from, unsigned to)
virtual void delete_render_primitives ()
virtual void clear_render_primitives ()
virtual void delete_light_context ()
void print_info (const char *title)
void generateObjectTransforms ()

Public Attributes

CameraOpcamera
 The shooting camera.
CameraOp::LensNFunc * lens_func
 Camera projection function to use.
Axis cam_vectors
 Camera PXYZ vectors in world-space.
std::vector< LightContext * > lights
 Lights and their vectors.
std::vector< MatrixArraylight_transforms
 Light transforms.
std::vector< Render * > light_renderers
 Renderer attached to light.
Vector3 ambient
 Ambient RGB color.

Protected Attributes

GeoOpgeo_
GeometryList object_list_
 Geometry object list.
MotionVectorType mb_type_
 Motion vector type.
Scenemb_scene_
 Next scene in time to motionblur to.
Quadtree< unsigned > * quadtree_
 Spatial subdivision tree.
std::vector< rPrimitive
*, STL3DAllocator< rPrimitive * > > 
render_primitives_
 Primitives to render.
std::vector< rPrimitive
*, STL3DAllocator< rPrimitive * > > 
mb_render_primitives_
 Motionblur primitives.
std::vector< rPrimitive
*, STL3DAllocator< rPrimitive * > > 
displacement_primitives_
 Displacement primitives.
std::vector< MatrixArrayobject_transforms_
 Rendering transforms.
MatrixArray transforms_
const Formatformat_
 Output render format.
int projection_mode_
 Point projection mode.
int max_tessellation_
 Threshold to limit recursive subdivision.
bool transparency_
 Transparency setting from renderer.
Box screen_bbox_
 Screen-projected bounding box.
ChannelSet channels_
 Intersected channels of all materials.
ChannelSet shadow_channels_
 shadow channels for all lights
TextureFilterfilter_
bool shadow_scene_
 Is this a shadow scene?
float _time
 Scene time.
std::map< Iop *, Box_materialBoxes
 2D bounding boxes for each material input
RegularGrid * _grid
std::vector< DrawableGeo > _geoList
Lock _lock
int _id
 id for current rendering scene

Friends

class GeoOp
class Render
class DepthMapRender

Detailed Description

We create a Scene structure for every rendering sample. This structure is a snapshot in time of all objects and transforms that are needed to render a certain camera view. To that end it's *very* important to have local copies of renderable primitives, their transforms, the taking camera's transform and all lights that affect this scene.

The Scene contains everything a renderer needs to generate an image.


Constructor & Destructor Documentation

Scene::~Scene ( ) [virtual]

Destructor. Delete and clear the primitives list.

References delete_light_context(), delete_render_primitives(), and quadtree_.


Member Function Documentation

void Scene::validate ( int  sample = 0) [virtual]

Calculate the scene's bounding box which surrounds all of it's constituent objects. We keep two current, the entire scene's bbox in world space, and that same bbox projected into screen space.

References _materialBoxes, cam_vectors, camera, DD::Image::GeoInfoRenderState::castShadow, DD::Image::IopInfoOwner::channels(), channels_, clamp(), DD::Image::Box::clear(), DD::Image::Box::contains(), DD::Image::Iop::displacement_bound(), DD::Image::GeoInfo::display3d, DD::Image::Box3::empty(), DD::Image::Box3::expand(), DD::Image::Box3::f(), DD::Image::Primitive::face_vertices(), DD::Image::Primitive::faces(), DD::Image::IopInfoOwner::format(), DD::Image::Primitive::get_face_vertices(), DD::Image::Box::h(), DD::Image::IopInfoOwner::info(), DD::Image::Box3::inside(), DD::Image::CameraOp::LENS_ORTHOGRAPHIC, DD::Image::CameraOp::LENS_PERSPECTIVE, lights, DD::Image::GeoInfo::material, DD::Image::GeoInfo::matrix, DD::Image::MatrixArray::matrix(), MAX(), DD::Image::Box::merge(), MIN(), DD::Image::Box3::n(), object_list_, DD::Image::Box3::project(), projection_mode_, DD::Image::Box3::r(), DD::Image::GeoInfo::render_mode, DD::Image::Iop::request(), screen_bbox_, DD::Image::Box::set(), DD::Image::MatrixArray::set_object_matrix(), shadow_channels_, shadow_scene_, DD::Image::GeometryList::size(), DD::Image::Box3::t(), DD::Image::Box3::transform(), transforms_, DD::Image::Op::validate(), DD::Image::GeoInfo::validate(), DD::Image::Primitive::vertex_shader(), DD::Image::Box::w(), DD::Image::Box::x(), and DD::Image::Box::y().

Referenced by DD::Image::Render::_validate().

void Scene::add_light ( LightOp l) [virtual]

Add a LightOp to the Scene's light list.

References light_renderers, light_transforms, and lights.

Referenced by add_lights().

void Scene::add_lights ( const std::vector< LightOp * > *  light_list) [virtual]

Add LightOps from a LightOp list.

References add_light().

void Scene::clear_lights ( ) [virtual]
bool Scene::evaluate_lights ( ) [virtual]

Transform the Scene's lights into the scene's camera(eye) space. The renderer needs a local copy of the light transforms because the lights can be used in multiple scenes and it's cheaper to pre-transform them than to do it during rendering. This call is separate from generate_primitives() so that Materials can generate their shader previews. If the call is aborted early because of a user interrupt, return false so the calling function can abort too.

References DD::Image::Op::aborted(), DD::Image::Op::invalidate(), light_renderers, light_transforms, lights, DD::Image::Box3::n(), DD::Image::Op::node_disabled(), DD::Image::Op::parent(), DD::Image::Box3::r(), DD::Image::Iop::request(), DD::Image::MatrixArray::set_camera_matrix(), DD::Image::MatrixArray::set_format_matrix(), DD::Image::MatrixArray::set_object_matrix(), DD::Image::MatrixArray::set_projection_matrix(), and DD::Image::Op::validate().

Referenced by DD::Image::Render::evaluate_lights().

void Scene::copyInfo ( const Scene scene)
bool Scene::generate_render_primitives ( ) [virtual]

Create renderable primitives from the GeoInfo's primitive list. A primitive may not be directly renderable and may need tessellation(subdivision) into simpler primitives - a NURBS surface for example. Usually these primitives will create triangles, and this generally will only need to be done to support a scanline rendering algorithm as raytracing usually intersect tests directly on implicit surfaces.

Because this routine can be time intensive, we check frequently for user aborts so we can clean up and bail out quickly.

References DD::Image::Op::aborted(), DD::Image::GeoInfoRenderState::castShadow, delete_render_primitives(), mb_scene_, DD::Image::Box3::n(), object_list_, object_transforms_, DD::Image::GeoInfo::render_mode, shadow_scene_, DD::Image::GeometryList::size(), and DD::Image::GeoInfo::validate().

Referenced by DD::Image::Render::generate_render_primitives(), and DD::Image::DepthMapRender::generate_render_primitives().

void Scene::add_render_primitive ( rPrimitive p,
PrimitiveContext ptx 
) [virtual]

Add an unclipped primitive to the renderable list. This call calls clip() on the primitive. If you know the primitive is completely visible, use add_clipped_render_primitive() instead. This is usually called directly from a rPrimitive to either add a reference to a copy of itself, or to add a sub-primitive during tessellation. rPrimitives should not add a reference to themselves as the Scene deletes all its rPrimitive pointers after rendering.

The pointer 'p' is deleted after rendering is complete!****

References DD::Image::Iop::displacement_bound(), and DD::Image::GeoInfo::material.

Referenced by DD::Image::Point::tessellate(), DD::Image::Mesh::tessellateFace(), and DD::Image::ParticlesSprite::tessellateSprite().

void Scene::add_clipped_render_primitive ( rPrimitive p) [virtual]

Add an already clipped primitive to the renderable list. This is usually called directly from a rPrimitive to either add a reference to a copy of itself, or to add a sub-primitive during tessellation. rPrimitives should not pass a reference to itself as the Scene deletes all its rPrimitive pointers after rendering.

The pointer 'p' is deleted after rendering is complete!****

References render_primitives_.

Referenced by DD::Image::rPoint::add_to_render().

void Scene::delete_render_primitives ( ) [virtual]

Delete all added renderable primitives and their associated allocations.

References displacement_primitives_, mb_render_primitives_, DD::Image::Box3::n(), quadtree_, and render_primitives_.

Referenced by generate_render_primitives(), DD::Image::Render::generate_render_primitives(), and ~Scene().

void Scene::delete_light_context ( ) [virtual]

Delete all allocated light context.

References lights.

Referenced by clear_lights(), and ~Scene().


Member Data Documentation