3Depict
|
The scene class brings together elements such as objects, lights, and cameras. More...
#include <scene.h>
Public Member Functions | |
Scene () | |
Constructor. More... | |
virtual | ~Scene () |
Destructor. More... | |
void | setVisControl (VisController *v) |
Set the vis control. More... | |
void | draw (bool noUpdateCam=false) |
Draw the objects in the active window. May adjust cameras and compute bounding as needed. More... | |
void | drawOverlays (bool noCamUpdate=false) const |
Draw the normal overlays. More... | |
void | clearAll () |
clear rendering vectors More... | |
void | clearObjs () |
Clear drawing objects vector. More... | |
void | clearRefObjs () |
Clear the reference object vector. More... | |
bool | hasOverlays () const |
Do we have overlay items? More... | |
void | getLightPos (float *f) const |
Obtain the scene's light coordinates in camera relative space. More... | |
void | setLightPos (const float *f) |
Obtain the scene's light coordinates in camera relative space. More... | |
void | setAspect (float newAspect) |
Set the aspect ratio of the output window. Required. More... | |
float | getAspect () const |
retrieve aspect ratio (h/w) of output win More... | |
void | addDrawable (const DrawableObj *) |
Add a drawable object. More... | |
void | addRefDrawable (const DrawableObj *) |
Add a drawable to the reference only section. More... | |
bool | setProgressAnimation (const std::vector< std::string > &animFiles) |
void | resetProgressAnim () |
void | removeDrawable (unsigned int) |
remove a drawable object More... | |
void | setActiveCam (Camera *c) |
Set the active camera directly. More... | |
void | setActiveCamByClone (const Camera *c) |
set the active camera More... | |
Camera * | getActiveCam () |
get the active camera More... | |
Point3D | getActiveCamLoc () const |
get the active camera's location More... | |
void | setTempCam () |
Construct (or refresh) a temporary camera. More... | |
Camera * | getTempCam () |
Return pointer to active camera. Must init a temporary camera first! (use setTempCam) More... | |
void | commitTempCam () |
Make the temp camera permanent. More... | |
void | discardTempCam () |
Discard the temporary camera. More... | |
bool | haveTempCam () const |
Are we using a temporary camera? More... | |
Camera * | cloneActiveCam () const |
Clone the active camera. More... | |
void | ensureVisible (unsigned int direction) |
Modify the active camera position to ensure that scene is visible. More... | |
void | finaliseCam () |
Call if user has stopped interacting with camera briefly. More... | |
unsigned int | glSelect (bool storeSelection=true) |
perform an openGL selection rendering pass. Return More... | |
void | clearDevices () |
Clear the current selection devices. More... | |
void | applyDevice (float startX, float startY, float curX, float curY, unsigned int keyFlags, unsigned int mouseflags, bool permanent=true) |
Apply the device given the following start and end. More... | |
bool | isInteractionLocked () const |
void | lockInteraction (bool amLocking=true) |
Prevent user interaction. More... | |
void | setSelectionMode (bool selMode) |
Set selection mode true=select on, false=select off. More... | |
void | setHoverMode (bool hMode) |
Set the hover mode to control drawing. More... | |
void | setLastHover (unsigned int hover) |
Return the last object over which the cursor was hovered. More... | |
unsigned int | getLastSelected () const |
Get the last selected object from call to glSelect() More... | |
unsigned int | getLastHover () const |
Return the last object over which the cursor was hovered. More... | |
unsigned int | duplicateCameras (std::vector< Camera *> &cams) const |
Duplicates the internal camera vector. return value is active camera. More... | |
void | getEffects (std::vector< const Effect *> &effects) const |
Get a copy of the effects pointers. More... | |
void | setAlpha (bool newAlpha) |
Set whether to use alpha blending. More... | |
void | setLighting (bool newLight) |
Set whether to enable lighting. More... | |
void | setWorldAxisVisible (bool newAxis) |
Set whether to enable the XYZ world axes. More... | |
bool | getWorldAxisVisible () const |
Get whether the XYZ world axes are enabled. More... | |
void | setWinSize (unsigned int x, unsigned int y) |
Set window size. More... | |
BoundCube | getBound () const |
Get the scene bounding box. More... | |
void | setBackgroundColour (float newR, float newG, float newB) |
Set the background colour. More... | |
void | getBackgroundColour (float &newR, float &newG, float &newB) const |
void | computeSceneLimits () |
Computes the bounding box for the scene. More... | |
void | setEffects (bool enable) |
Set whether to use effects or not. More... | |
void | setEffectVec (std::vector< Effect *> &e) |
Set the effect vector. More... | |
unsigned int | addEffect (Effect *e) |
Add an effect. More... | |
void | removeEffect (unsigned int uniqueEffectID) |
Remove a given effect. More... | |
void | clearEffects () |
Clear effects vector. More... | |
Static Public Member Functions | |
static std::string | getGlVersion () |
Public Attributes | |
DrawProgressCircleOverlay | progressCircle |
The scene class brings together elements such as objects, lights, and cameras.
Scene::Scene | ( | ) |
Constructor.
References DrawableObj::setTexPool().
|
virtual |
Destructor.
References ANIMATE_PROGRESS_BASENAME, ANIMATE_PROGRESS_NUMFRAMES, clearAll(), DrawableObj::clearTexPool(), computeSceneLimits(), BoundCube::isValid(), progressCircle, Effect::setBoundingCube(), DrawAnimatedOverlay::setFadeInTime(), DrawAnimatedOverlay::setRepeatTime(), DrawAnimatedOverlay::setShowDelayTime(), DrawAnimatedOverlay::setTexture(), DrawableObj::setUseAlphaBlending(), and stream_cast().
void Scene::addDrawable | ( | const DrawableObj * | obj | ) |
Add a drawable object.
Pointer must be set to a valid (allocated) object. !Scene will delete upon call to clearAll, clearObjs or !upon destruction
References BoundCube::expand(), DrawableObj::getBoundingBox(), and BoundCube::isValid().
Referenced by getAspect().
unsigned int Scene::addEffect | ( | Effect * | e | ) |
Add an effect.
References ASSERT, UniqueIDHandler::genId(), and UniqueIDHandler::size().
Referenced by setEffects(), and setEffectVec().
void Scene::addRefDrawable | ( | const DrawableObj * | obj | ) |
Add a drawable to the reference only section.
References ASSERT, BoundCube::expand(), DrawableObj::getBoundingBox(), and BoundCube::isValid().
Referenced by getAspect().
void Scene::applyDevice | ( | float | startX, |
float | startY, | ||
float | curX, | ||
float | curY, | ||
unsigned int | keyFlags, | ||
unsigned int | mouseflags, | ||
bool | permanent = true |
||
) |
Apply the device given the following start and end.
References ASSERT, CAM_LOOKAT, computeSceneLimits(), Point3D::crossProd(), Point3D::dotProd(), getActiveCam(), BoundCube::getCentroid(), Camera::getOrigin(), VisController::getSelectionDevices(), Camera::getUpDirection(), Camera::getViewDirection(), TreeState::isRefreshing(), Point3D::normalise(), TreeState::setAbort(), TreeState::setUpdates(), VisController::state, AnalysisState::treeState, and Camera::type().
Referenced by cloneActiveCam(), BasicGLPane::mouseLeftWindow(), BasicGLPane::mouseMoved(), and BasicGLPane::mouseReleased().
void Scene::clearAll | ( | ) |
clear rendering vectors
References clearObjs(), clearRefObjs(), and BoundCube::setInverseLimits().
Referenced by VisController::clearScene(), setVisControl(), and ~Scene().
void Scene::clearDevices | ( | ) |
Clear the current selection devices.
Referenced by cloneActiveCam().
void Scene::clearEffects | ( | ) |
Clear effects vector.
References UniqueIDHandler::clear().
Referenced by setEffects(), and setEffectVec().
void Scene::clearObjs | ( | ) |
Clear drawing objects vector.
Referenced by clearAll(), and setVisControl().
void Scene::clearRefObjs | ( | ) |
Clear the reference object vector.
Referenced by clearAll(), and setVisControl().
|
inline |
Clone the active camera.
References applyDevice(), clearDevices(), Camera::clone(), ensureVisible(), finaliseCam(), and glSelect().
void Scene::commitTempCam | ( | ) |
Make the temp camera permanent.
References ASSERT.
Referenced by getAspect(), BasicGLPane::mouseLeftWindow(), BasicGLPane::mouseMoved(), and BasicGLPane::mouseReleased().
void Scene::computeSceneLimits | ( | ) |
Computes the bounding box for the scene.
References ASSERT, BoundCube::expand(), BoundCube::getCentroid(), BoundCube::isValid(), BoundCube::setBounds(), and BoundCube::setInverseLimits().
Referenced by applyDevice(), ensureVisible(), getBackgroundColour(), glSelect(), and ~Scene().
void Scene::discardTempCam | ( | ) |
Discard the temporary camera.
Referenced by getAspect(), BasicGLPane::mouseMoved(), BasicGLPane::saveImageSequence(), setActiveCam(), and setActiveCamByClone().
void Scene::draw | ( | bool | noUpdateCam = false | ) |
Draw the objects in the active window. May adjust cameras and compute bounding as needed.
References ASSERT, AXIS_IN_SPACE, DrawRectPrism::draw(), DrawAxis::draw(), drawOverlays(), BoundCube::getCentroid(), BoundCube::getLargestDim(), glError, DrawRectPrism::setAxisAligned(), DrawableObj::setBackgroundColour(), DrawRectPrism::setColour(), Effect::setCurCam(), DrawableObj::setCurCamera(), DrawAxis::setPosition(), DrawAxis::setSize(), DrawAxis::setStyle(), and DrawableObj::setWindowSize().
Referenced by BasicGLPane::render(), BasicGLPane::saveImage(), and setVisControl().
void Scene::drawOverlays | ( | bool | noCamUpdate = false | ) | const |
Draw the normal overlays.
References BIND_MODE_FLOAT_SCALE, BIND_MODE_FLOAT_TRANSLATE, BIND_MODE_POINT3D_ROTATE, BIND_MODE_POINT3D_ROTATE_LOCK, BIND_MODE_POINT3D_SCALE, BIND_MODE_POINT3D_TRANSLATE, DrawTexturedQuadOverlay::draw(), DrawAnimatedOverlay::draw(), DrawProgressCircleOverlay::draw(), FLAG_CMD, FLAG_SHIFT, VisController::getSelectionDevices(), DrawAnimatedOverlay::isOK(), TreeState::isRefreshing(), progressCircle, SELECT_BUTTON_LEFT, SELECT_BUTTON_MIDDLE, SELECT_BUTTON_RIGHT, DrawableOverlay::setPosition(), DrawableOverlay::setSize(), DrawTexturedQuadOverlay::setTexture(), VisController::state, TEXTURE_COMMAND, TEXTURE_CTRL, TEXTURE_ENLARGE, TEXTURE_LEFT_CLICK, TEXTURE_MIDDLE_CLICK, TEXTURE_OVERLAY_PNG, TEXTURE_RIGHT_CLICK, TEXTURE_ROTATE, TEXTURE_SHIFT, TEXTURE_TRANSLATE, and AnalysisState::treeState.
Referenced by draw(), BasicGLPane::saveImage(), and setVisControl().
unsigned int Scene::duplicateCameras | ( | std::vector< Camera *> & | cams | ) | const |
Duplicates the internal camera vector. return value is active camera.
Referenced by getLastHover().
void Scene::ensureVisible | ( | unsigned int | direction | ) |
Modify the active camera position to ensure that scene is visible.
References computeSceneLimits(), and Camera::ensureVisible().
Referenced by cloneActiveCam(), and BasicGLPane::keyPressed().
void Scene::finaliseCam | ( | ) |
Call if user has stopped interacting with camera briefly.
References CAM_LOOKAT, and Camera::type().
Referenced by cloneActiveCam(), and BasicGLPane::mouseReleased().
Camera * Scene::getActiveCam | ( | ) |
get the active camera
Referenced by applyDevice(), getAspect(), BasicGLPane::keyReleased(), BasicGLPane::mouseWheelMoved(), BasicGLPane::saveImage(), and BasicGLPane::saveImageSequence().
Point3D Scene::getActiveCamLoc | ( | ) | const |
get the active camera's location
Referenced by getAspect().
|
inline |
retrieve aspect ratio (h/w) of output win
References addDrawable(), addRefDrawable(), commitTempCam(), discardTempCam(), getActiveCam(), getActiveCamLoc(), getTempCam(), removeDrawable(), resetProgressAnim(), setActiveCam(), setActiveCamByClone(), setProgressAnimation(), and setTempCam().
Referenced by BasicGLPane::saveImage().
|
inline |
References computeSceneLimits().
Referenced by BasicGLPane::getGlClearColour(), BasicGLPane::saveImage(), and BasicGLPane::updateClearColour().
|
inline |
Get the scene bounding box.
Referenced by BasicGLPane::saveImage().
void Scene::getEffects | ( | std::vector< const Effect *> & | effects | ) | const |
Get a copy of the effects pointers.
Referenced by getLastHover().
|
inlinestatic |
|
inline |
Return the last object over which the cursor was hovered.
References duplicateCameras(), and getEffects().
Referenced by BasicGLPane::setSceneInteractionAllowed().
|
inline |
Get the last selected object from call to glSelect()
Referenced by BasicGLPane::mouseDown(), and BasicGLPane::setSceneInteractionAllowed().
void Scene::getLightPos | ( | float * | f | ) | const |
Obtain the scene's light coordinates in camera relative space.
Referenced by BasicGLPane::saveImage(), and setVisControl().
Camera * Scene::getTempCam | ( | ) |
Return pointer to active camera. Must init a temporary camera first! (use setTempCam)
References ASSERT.
Referenced by getAspect(), BasicGLPane::keyReleased(), BasicGLPane::mouseMoved(), and BasicGLPane::mouseWheelMoved().
|
inline |
Get whether the XYZ world axes are enabled.
unsigned int Scene::glSelect | ( | bool | storeSelection = true | ) |
perform an openGL selection rendering pass. Return
References Camera::apply(), ASSERT, computeSceneLimits(), and BoundCube::isValid().
Referenced by cloneActiveCam(), and BasicGLPane::setSceneInteractionAllowed().
bool Scene::hasOverlays | ( | ) | const |
Do we have overlay items?
References Camera::apply(), Camera::getViewDirection(), progressCircle, DrawableOverlay::setPosition(), and DrawableOverlay::setSize().
Referenced by BasicGLPane::saveImage(), and setVisControl().
|
inline |
Are we using a temporary camera?
Referenced by BasicGLPane::keyReleased(), BasicGLPane::mouseLeftWindow(), BasicGLPane::mouseMoved(), BasicGLPane::mouseReleased(), BasicGLPane::mouseWheelMoved(), and BasicGLPane::saveImageSequence().
|
inline |
Referenced by BasicGLPane::mouseDown(), BasicGLPane::mouseMoved(), BasicGLPane::mouseReleased(), and BasicGLPane::setSceneInteractionAllowed().
|
inline |
Prevent user interaction.
Referenced by BasicGLPane::setSceneInteractionAllowed().
void Scene::removeDrawable | ( | unsigned | int | ) |
void Scene::removeEffect | ( | unsigned int | uniqueEffectID | ) |
Remove a given effect.
References UniqueIDHandler::getPos(), and UniqueIDHandler::killByPos().
Referenced by setEffects().
void Scene::resetProgressAnim | ( | ) |
References progressCircle, DrawProgressCircleOverlay::reset(), and DrawAnimatedOverlay::resetTime().
Referenced by getAspect().
void Scene::setActiveCam | ( | Camera * | c | ) |
Set the active camera directly.
References discardTempCam().
Referenced by getAspect(), and BasicGLPane::saveImageSequence().
void Scene::setActiveCamByClone | ( | const Camera * | c | ) |
set the active camera
References Camera::clone(), and discardTempCam().
Referenced by getAspect().
|
inline |
Set whether to use alpha blending.
void Scene::setAspect | ( | float | newAspect | ) |
Set the aspect ratio of the output window. Required.
Referenced by BasicGLPane::prepare3DViewport(), and setVisControl().
|
inline |
Set the background colour.
Referenced by BasicGLPane::setGlClearColour().
|
inline |
Set whether to use effects or not.
References addEffect(), clearEffects(), removeEffect(), and setEffectVec().
void Scene::setEffectVec | ( | std::vector< Effect *> & | e | ) |
Set the effect vector.
Pointers will become "owned" by scene and will be deleted during destruction, clear, or next setEffectVec call input vector will be cleared.
References addEffect(), and clearEffects().
Referenced by setEffects().
|
inline |
Set the hover mode to control drawing.
Referenced by BasicGLPane::setSceneInteractionAllowed().
|
inline |
Return the last object over which the cursor was hovered.
Referenced by BasicGLPane::setSceneInteractionAllowed().
|
inline |
Set whether to enable lighting.
void Scene::setLightPos | ( | const float * | f | ) |
Obtain the scene's light coordinates in camera relative space.
Referenced by BasicGLPane::saveImage(), and setVisControl().
bool Scene::setProgressAnimation | ( | const std::vector< std::string > & | animFiles | ) |
|
inline |
Set selection mode true=select on, false=select off.
Referenced by BasicGLPane::mouseDown(), BasicGLPane::mouseLeftWindow(), and BasicGLPane::mouseReleased().
void Scene::setTempCam | ( | ) |
Construct (or refresh) a temporary camera.
this temporary camera is discarded with either killTempCam or reset to the active camera with another call to setTempCam(). The temporary camera overrides the existing camera setup
References Camera::clone().
Referenced by getAspect(), and BasicGLPane::mouseMoved().
|
inline |
Set the vis control.
References clearAll(), clearObjs(), clearRefObjs(), draw(), drawOverlays(), getLightPos(), hasOverlays(), setAspect(), and setLightPos().
Referenced by VisController::VisController().
|
inline |
Set window size.
Referenced by BasicGLPane::prepare3DViewport().
|
inline |
Set whether to enable the XYZ world axes.
DrawProgressCircleOverlay Scene::progressCircle |
Referenced by drawOverlays(), hasOverlays(), resetProgressAnim(), and ~Scene().