V-ART
|
A set of objects, lights and cameras. More...
#include <scene.h>
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 Light * | GetLight (const std::string &lightName) |
Finds a light by its name. More... | |
const Camera * | GetCamera (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 () |
SceneNode * | GetObject (const std::string &objectName) const |
Searches an object by its description. More... | |
SceneNode * | GetObjectRec (const std::string &objectName) const |
Recursively searches an object by its description. More... | |
const Color & | GetBackgroundColor () |
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... | |
Camera * | GetCurrentCamera () const |
Returns the current camera in the scene or NULL if no camera exists. More... | |
const Camera * | UseNextCamera () |
const Camera * | UsePreviousCamera () |
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 BoundingBox & | GetBoundingBox () 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 |
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.
VART::Scene::Scene | ( | ) |
Definition at line 17 of file scene.cpp.
References VART::BoundingBox::SetColor(), and VART::Color::WHITE().
|
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.
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.
void VART::Scene::AddLight | ( | VART::Light * | newLight | ) |
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.
void VART::Scene::ChangeAllCamerasViewVolume | ( | float | horScale, |
float | verScale | ||
) |
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 |
|
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.
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.
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.
const VART::Color & VART::Scene::GetBackgroundColor | ( | ) |
|
inline |
const VART::Camera * VART::Scene::GetCamera | ( | const std::string & | cameraName | ) |
list< VART::Camera * > VART::Scene::GetCameras | ( | ) |
Returns a list of cameras.
VART::Camera * VART::Scene::GetCurrentCamera | ( | ) | const |
|
inline |
const VART::Light * VART::Scene::GetLight | ( | const std::string & | lightName | ) |
list< const VART::Light * > VART::Scene::GetLights | ( | ) |
|
inline |
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.
Definition at line 151 of file scene.cpp.
References VART::SceneNode::FindChildByName().
list< VART::SceneNode * > VART::Scene::GetObjects | ( | ) |
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 | ||
) |
void VART::Scene::SetAllCamerasAspectRatio | ( | float | newAspectRatio | ) |
void VART::Scene::SetBackgroundColor | ( | VART::Color | color | ) |
|
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 | ||
) |
void VART::Scene::SetCamera | ( | const std::string & | cameraName | ) |
void VART::Scene::SetCamerasAspectRatio | ( | const std::string & | cameraDescription, |
float | newAspectRatio | ||
) |
|
inline |
|
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 | ) |
const VART::Camera * VART::Scene::UseNextCamera | ( | ) |
const VART::Camera * VART::Scene::UsePreviousCamera | ( | ) |
void VART::Scene::XmlPrintOn | ( | std::ostream & | os | ) | const |
|
protected |
Separate lights (not treated as common objects)
Definition at line 207 of file scene.h.
Referenced by GetNumLights().