V-ART
Public Member Functions | Protected Attributes | List of all members
VART::Scene Class Reference

A set of objects, lights and cameras. More...

#include <scene.h>

Inheritance diagram for VART::Scene:
VART::XmlScene

Public Member Functions

 Scene ()
 
virtual ~Scene ()
 Destructor. More...
 
std::list< const Light * > GetLights ()
 
std::list< Camera * > GetCameras ()
 Returns a list of cameras. More...
 
void AddLight (Light *newLight)
 Adds a light to the list of lights. More...
 
void AddLight (const Light &newLight)
 Adds a light to the list of lights. More...
 
void AddCamera (Camera *newCamera)
 Add a camera to the list of cameras. More...
 
void AddObject (SceneNode *newObjectPtr)
 Add a object to the scene. More...
 
void Unreference (const SceneNode *sceneNodePtr)
 Removes an object from scene graph. More...
 
const LightGetLight (const std::string &lightName)
 Finds a light by its name. More...
 
const CameraGetCamera (const std::string &cameraName)
 Finds an camera by its description. More...
 
void SetCamera (const std::string &cameraName)
 Sets the current camera by its description. More...
 
std::list< SceneNode * > GetObjects ()
 
SceneNodeGetObject (const std::string &objectName) const
 Searches an object by its description. More...
 
SceneNodeGetObjectRec (const std::string &objectName) const
 Recursively searches an object by its description. More...
 
const ColorGetBackgroundColor ()
 Returns the background color. More...
 
void SetBackgroundColor (Color color)
 Sets the background color. More...
 
virtual bool DrawOGL (Camera *cameraPtr=NULL) const
 Sets projection and draws graphics objects using OpenGL commands. More...
 
bool DrawLightsOGL () const
 Set lights using OpenGL commands. More...
 
CameraGetCurrentCamera () const
 Returns the current camera in the scene or NULL if no camera exists. More...
 
const CameraUseNextCamera ()
 
const CameraUsePreviousCamera ()
 
void SetCamerasAspectRatio (const std::string &cameraDescription, float newAspectRatio)
 Set the aspect ratio of camera by its description. More...
 
void SetAllCamerasAspectRatio (float newAspectRatio)
 Set the aspect ratio of all cameras. More...
 
void ChangeAllCamerasViewVolume (float horScale, float verScale)
 Changes the view volume of all cameras. More...
 
bool ComputeBoundingBox ()
 Computes the axis aligned bounding box of all objects. More...
 
const BoundingBoxGetBoundingBox () const
 Returns the scene bounding box. Attention: uses the ComputeBoundingBox method to refresh value of bounding box. More...
 
void SetBBoxVisibility (bool value)
 Sets the bounding box visibility. More...
 
void SetBoundingBox (double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
 Sets the bounding box. More...
 
void ToggleBBoxVisibility ()
 Toggles the bounding box visibility. More...
 
size_t GetNumLights () const
 Returns the number of light in the scene. More...
 
void MakeCameraViewAll ()
 Fits the whole scene to drawing region. More...
 
void SetDescription (const std::string &newDescr)
 Sets the scene description. More...
 
const std::string & GetDescription ()
 Returns the scene description. More...
 
std::list< SceneNode * > GetAllSceneJoints ()
 Get all scenenodes of type 'joint' in the scene. More...
 
std::list< SceneNode * > GetAllSceneTypeObject (SceneNode::TypeID type)
 Get all scenenodes of type 'type' in the scene. More...
 
void Pick (int x, int y, std::list< GraphicObj * > *resultListPtr)
 Picks objects from viewport coordinates. More...
 
void XmlPrintOn (std::ostream &os) const
 Outputs XML representation of the scene. More...
 

Protected Attributes

std::list< const Light * > lights
 Separate lights (not treated as common objects) More...
 
std::list< Camera * > cameras
 
std::list< SceneNode * > objects
 
Color background
 

Detailed Description

A set of objects, lights and cameras.

A Scene is a complete viewable object with objects, lights, cameras and background color. Instances of this class should be declared as static objects inside the "main" function (see MemoryObj and ~Scene()). The cameras contained in a scene are "reference" cameras in the sense that they describe especial points of view for that scene. Viewers should have their own camera which changes as the user navigates de scene, not changing the scene's reference cameras.

Definition at line 35 of file scene.h.

Constructor & Destructor Documentation

VART::Scene::Scene ( )

Definition at line 17 of file scene.cpp.

References VART::BoundingBox::SetColor(), and VART::Color::WHITE().

VART::Scene::~Scene ( )
virtual

Destructor.

The scene desctructor is of key importance in V-ART applications because it deallocates memory for every scene node marked as "auto delete" (see MemoryObj). The application programmer should create scenes as late as possible to ensure its destructor will be called before static members of classes are destroyed. This usually means that a scene should be declared inside the "main" function. It should also be declared as an static object.

Definition at line 22 of file scene.cpp.

Member Function Documentation

void VART::Scene::AddCamera ( VART::Camera newCamera)

Add a camera to the list of cameras.

The first added camera is made the current camera. Other cameras are added to end of the list of cameras. Currently, it is not a good idea to share a camera between different scenes, because viewers change the aspect ratio of their scenes.

Definition at line 63 of file scene.cpp.

void VART::Scene::AddLight ( VART::Light newLight)

Adds a light to the list of lights.

This version only copies the light pointer to the internal list. The application programmer should keep the memory space untouched while the scene uses it.

Definition at line 53 of file scene.cpp.

void VART::Scene::AddLight ( const Light newLight)

Adds a light to the list of lights.

This version creates an internal copy of the light, so that the application programmer may free the light's memory space.

Definition at line 57 of file scene.cpp.

References VART::MemoryObj::autoDelete.

void VART::Scene::AddObject ( VART::SceneNode newObjectPtr)

Add a object to the scene.

The object's address is added to the scene's list. The object will be deallocated by the scene destructor if marked as "auto delete". If not, the application programmer is responsible for freeing memory at the end of scene's existence.

Definition at line 69 of file scene.cpp.

void VART::Scene::ChangeAllCamerasViewVolume ( float  horScale,
float  verScale 
)

Changes the view volume of all cameras.

Definition at line 261 of file scene.cpp.

bool VART::Scene::ComputeBoundingBox ( )

Computes the axis aligned bounding box of all objects.

Definition at line 268 of file scene.cpp.

References VART::GraphicObj::ComputeRecursiveBoundingBox(), VART::GraphicObj::GetRecursiveBoundingBox(), and VART::Transform::RecursiveBoundingBox().

bool VART::Scene::DrawLightsOGL ( ) const

Set lights using OpenGL commands.

Lights may be drawn apart from other scene components because they need not be drawn at every rendering cicle.

Returns
false if V-ART was not compiled with OpenGL support.

Definition at line 206 of file scene.cpp.

bool VART::Scene::DrawOGL ( Camera cameraPtr = NULL) const
virtual

Sets projection and draws graphics objects using OpenGL commands.

This method is intended to be executed at every rendering cicle. It does not draw lights (from the "lights" list), because they need not be drawn at every rendering cicle.

Returns
false if V-ART was not compiled with OpenGL support.

Definition at line 176 of file scene.cpp.

References VART::Camera::DrawOGL().

std::list< VART::SceneNode * > VART::Scene::GetAllSceneJoints ( )

Get all scenenodes of type 'joint' in the scene.

Returns
a list of scene nodes of type joint.
Deprecated:
Please use a Joint Collector (see VART::Collector).

Definition at line 358 of file scene.cpp.

References VART::SceneNode::JOINT.

std::list< VART::SceneNode * > VART::Scene::GetAllSceneTypeObject ( SceneNode::TypeID  type)

Get all scenenodes of type 'type' in the scene.

Returns
a list of scene nodes of type 'type'
Deprecated:
Please use a Collector (see VART::Collector).

Definition at line 370 of file scene.cpp.

const VART::Color & VART::Scene::GetBackgroundColor ( )

Returns the background color.

Returns a constant reference to the background color.

Definition at line 167 of file scene.cpp.

const BoundingBox& VART::Scene::GetBoundingBox ( ) const
inline

Returns the scene bounding box. Attention: uses the ComputeBoundingBox method to refresh value of bounding box.

Definition at line 160 of file scene.h.

const VART::Camera * VART::Scene::GetCamera ( const std::string &  cameraName)

Finds an camera by its description.

Definition at line 103 of file scene.cpp.

list< VART::Camera * > VART::Scene::GetCameras ( )

Returns a list of cameras.

Deprecated:
See UseNextCamera and UsePreviousCamera

Definition at line 45 of file scene.cpp.

VART::Camera * VART::Scene::GetCurrentCamera ( ) const

Returns the current camera in the scene or NULL if no camera exists.

Definition at line 221 of file scene.cpp.

const std::string& VART::Scene::GetDescription ( )
inline

Returns the scene description.

Definition at line 185 of file scene.h.

const VART::Light * VART::Scene::GetLight ( const std::string &  lightName)

Finds a light by its name.

Definition at line 93 of file scene.cpp.

list< const VART::Light * > VART::Scene::GetLights ( )

Definition at line 41 of file scene.cpp.

size_t VART::Scene::GetNumLights ( ) const
inline

Returns the number of light in the scene.

Definition at line 173 of file scene.h.

References lights.

SceneNode* VART::Scene::GetObject ( const std::string &  objectName) const

Searches an object by its description.

Only top-level objects are verified (no recursion).

VART::SceneNode * VART::Scene::GetObjectRec ( const std::string &  objectName) const

Recursively searches an object by its description.

Deprecated:
See DescriptionLocator.

Definition at line 151 of file scene.cpp.

References VART::SceneNode::FindChildByName().

list< VART::SceneNode * > VART::Scene::GetObjects ( )

Definition at line 49 of file scene.cpp.

void VART::Scene::MakeCameraViewAll ( )

Fits the whole scene to drawing region.

Changes current camera's position and clipping planes so that the whole scene fits the viewer window.

Definition at line 334 of file scene.cpp.

References VART::Camera::ORTHOGRAPHIC, VART::Camera::PERSPECTIVE, VART::Point4D::X(), and VART::Point4D::Y().

void VART::Scene::Pick ( int  x,
int  y,
std::list< GraphicObj * > *  resultListPtr 
)

Picks objects from viewport coordinates.

Definition at line 382 of file scene.cpp.

void VART::Scene::SetAllCamerasAspectRatio ( float  newAspectRatio)

Set the aspect ratio of all cameras.

Definition at line 254 of file scene.cpp.

void VART::Scene::SetBackgroundColor ( VART::Color  color)

Sets the background color.

Changes the background color attribute. Currently, the viewer uses the background for actual frame buffer filling.

Definition at line 171 of file scene.cpp.

void VART::Scene::SetBBoxVisibility ( bool  value)
inline

Sets the bounding box visibility.

Definition at line 163 of file scene.h.

References VART::BoundingBox::visible.

void VART::Scene::SetBoundingBox ( double  minX,
double  minY,
double  minZ,
double  maxX,
double  maxY,
double  maxZ 
)

Sets the bounding box.

Definition at line 328 of file scene.cpp.

void VART::Scene::SetCamera ( const std::string &  cameraName)

Sets the current camera by its description.

Definition at line 113 of file scene.cpp.

void VART::Scene::SetCamerasAspectRatio ( const std::string &  cameraDescription,
float  newAspectRatio 
)

Set the aspect ratio of camera by its description.

Definition at line 244 of file scene.cpp.

void VART::Scene::SetDescription ( const std::string &  newDescr)
inline

Sets the scene description.

Definition at line 182 of file scene.h.

void VART::Scene::ToggleBBoxVisibility ( )
inline

Toggles the bounding box visibility.

Definition at line 170 of file scene.h.

References VART::BoundingBox::visible.

void VART::Scene::Unreference ( const SceneNode sceneNodePtr)

Removes an object from scene graph.

Removes references to given scene node from list of objects. Not recursive. No memory deallocation is done.

Definition at line 73 of file scene.cpp.

const VART::Camera * VART::Scene::UseNextCamera ( )

Sets the current camera to the next camera in list of cameras.

Returns
Returns a pointer to the new current camera.

Definition at line 228 of file scene.cpp.

const VART::Camera * VART::Scene::UsePreviousCamera ( )

Sets the current camera to the previous camera in the list of cameras.

Returns
Returns a pointer to the new current camera.

Definition at line 236 of file scene.cpp.

void VART::Scene::XmlPrintOn ( std::ostream &  os) const

Outputs XML representation of the scene.

Definition at line 454 of file scene.cpp.

Member Data Documentation

Color VART::Scene::background
protected

Definition at line 212 of file scene.h.

std::list<Camera*> VART::Scene::cameras
protected

Definition at line 210 of file scene.h.

std::list<const Light*> VART::Scene::lights
protected

Separate lights (not treated as common objects)

Definition at line 207 of file scene.h.

Referenced by GetNumLights().

std::list<SceneNode*> VART::Scene::objects
protected

Definition at line 211 of file scene.h.


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