Loading...
Searching...
No Matches
renderer.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
#define BALL_VIEW_RENDERING_RENDERERS_RENDERER_H
#ifndef BALL_VIEW_KERNEL_REPRESENTATION_H
# include <BALL/VIEW/KERNEL/representation.h>
#endif
#ifndef BALL_CONCEPT_OBJECT_H
# include <BALL/CONCEPT/object.h>
#endif
#ifndef BALL_VIEW_KERNEL_STAGE_H
# include <BALL/VIEW/KERNEL/stage.h>
#endif
#ifndef BALL_MATHS_VECTOR2_H
# include <BALL/MATHS/vector2.h>
#endif
class QImage;
namespace BALL
{
namespace VIEW
{
class Scene;
class Line;
class MultiLine;
class Tube;
class Mesh;
class Label;
class Point;
class Sphere;
class Disc;
class Box;
class SimpleBox;
class TwoColoredLine;
class TwoColoredTube;
class ClippingPlane;
class GridVisualisation;
class QuadMesh;
class BALL_VIEW_EXPORT Renderer
{
public:
enum StereoMode
{
NO_STEREO = 0,
ACTIVE_STEREO,
DUAL_VIEW_STEREO,
DUAL_VIEW_DIFFERENT_DISPLAY_STEREO,
TOP_BOTTOM_STEREO,
INTERLACED_STEREO
};
BALL_CREATE(Renderer)
Renderer();
Renderer(const Renderer& renderer);
virtual ~Renderer() {}
virtual void clear(){}
virtual bool init(Scene& scene);
virtual bool init(const Stage& stage, float height, float width);
virtual void setLights(bool reset_all = false);
virtual void updateCamera(const Camera* camera = 0);
virtual void updateMaterialForRepresentation(Representation const*) {};
virtual void updateBackgroundColor();
virtual void setupEnvironmentMap(const QImage& image);
virtual void setupStereo(float eye_separation, float focal_length);
virtual void useContinuousLoop(bool use_loop)
{
// TODO: mutex for use_continuous_loop_ just to be on the safe side
use_continuous_loop_ = use_loop;
};
bool isContinuous() { return use_continuous_loop_; }
virtual bool hasFPScounter() { return false; }
virtual double getFPS() { return 0; }
virtual bool finish();
virtual Vector3 mapViewportTo3D(Position x, Position y);
virtual Vector2 map3DToViewport(const Vector3& vec);
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2,
std::list<GeometricObject*>& objects);
virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f,
float& top_f, float& bottom_f);
virtual bool renderOneRepresentation(const Representation& representation);
virtual void bufferRepresentation(const Representation& /*rep*/) {};
virtual void removeRepresentation(const Representation& /*rep*/) {};
virtual const Stage& getStage() const
{ return *stage_;}
virtual void setStage(const Stage& stage)
{ stage_ = &stage;}
bool hasStage() const;
virtual void setSize(float width, float height) {width_ = width; height_ = height;}
virtual float getWidth() const { return width_;}
virtual float getHeight() const { return height_;}
virtual void setPreviewMode(bool show_preview) { show_preview_ = show_preview; }
virtual void showLightSources(bool show_light_sources) { show_light_sources_ = show_light_sources; }
virtual void renderRuler();
virtual void setStereoMode(StereoMode state);
virtual StereoMode getStereoMode() const;
virtual void setStereoFrustumConversion(int width_factor, int height_factor);
bool operator == (const Renderer& /*renderer*/) const
{ return true; }
virtual void render_(const GeometricObject* object);
protected:
virtual void renderClippingPlane_(const ClippingPlane&)
{Log.error() << "renderClippingPlane_ not implemented in derived Renderer class" << std::endl;}
// Render a text label
virtual void renderLabel_(const Label& /*label*/)
{Log.error() << "renderLabel_ not implemented in derived Renderer class" << std::endl;}
virtual void renderLine_(const Line& /*line*/)
{Log.error() << "renderLine_ not implemented in derived Renderer class" << std::endl;}
virtual void renderMultiLine_(const MultiLine& /*line*/)
{Log.error() << "renderMultiLine_ not implemented in derived Renderer class" << std::endl;}
virtual void renderMesh_(const Mesh& /*mesh*/)
{Log.error() << "renderMesh_ not implemented in derived Renderer class" << std::endl;}
virtual void renderPoint_(const Point& /*point*/)
{Log.error() << "renderPoint_ not implemented in derived Renderer class" << std::endl;}
virtual void renderBox_(const Box& /*box*/)
{Log.error() << "renderBox_ not implemented in derived Renderer class" << std::endl;}
virtual void renderSimpleBox_(const SimpleBox& /*box*/)
{Log.error() << "renderSimpleBox_ not implemented in derived Renderer class" << std::endl;}
virtual void renderSphere_(const Sphere& /*sphere*/)
{Log.error() << "renderSphere_ not implemented in derived Renderer class" << std::endl;}
virtual void renderDisc_(const Disc& /*disc*/)
{Log.error() << "renderDisc_ not implemented in derived Renderer class" << std::endl;}
virtual void renderTube_(const Tube& /*tube*/)
{Log.error() << "renderTube_ not implemented in derived Renderer class" << std::endl;}
virtual void renderTwoColoredLine_(const TwoColoredLine& /*two_colored_line*/)
{Log.error() << "renderTwoColoredLine_ not implemented in derived Renderer class" << std::endl;}
virtual void renderTwoColoredTube_(const TwoColoredTube& /*two_colored_tube*/)
{Log.error() << "renderTwoColoredTube_ not implemented in derived Renderer class" << std::endl;}
virtual void renderGridVisualisation_(const GridVisualisation&)
{Log.error() << "renderGridVisualisation_ not implemented in derived Renderer class" << std::endl;}
virtual void renderQuadMesh_(const QuadMesh&)
{Log.error() << "renderQuadMesh_ not implemented in derived Renderer class" << std::endl;}
//_
Scene* scene_;
//_
const Stage* stage_;
//_The width of the render area
float width_;
//_The height of the render area
float height_;
//_
bool show_preview_;
//_
float volume_width_;
//_
bool show_light_sources_;
//_
Camera camera_;
// An offset added to camera position and look at
Vector3 camera_offset_;
bool use_continuous_loop_;
Size stereo_frustum_conversion_width_;
Size stereo_frustum_conversion_height_;
StereoMode stereo_;
};
} // namespace VIEW
} // namespace BALL
#endif // BALL_VIEW_RENDERING_RENDERER_H
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
BALL::VIEW::Box
Definition box.h:33
BALL::VIEW::Camera
Definition camera.h:24
BALL::VIEW::ClippingPlane
Definition clippingPlane.h:26
BALL::VIEW::Disc
Definition disc.h:32
BALL::VIEW::GeometricObject
Definition geometricObject.h:37
BALL::VIEW::GridVisualisation
Definition gridVisualisation.h:27
BALL::VIEW::Label
Definition label.h:48
BALL::VIEW::Line
Definition line.h:38
BALL::VIEW::Mesh
Definition mesh.h:42
BALL::VIEW::MultiLine
Definition multiLine.h:33
BALL::VIEW::Point
Definition point.h:37
BALL::VIEW::QuadMesh
Definition quadMesh.h:30
BALL::VIEW::Renderer
Definition renderer.h:55
BALL::VIEW::Renderer::stereo_frustum_conversion_height_
Size stereo_frustum_conversion_height_
Definition renderer.h:353
BALL::VIEW::Renderer::height_
float height_
Definition renderer.h:333
BALL::VIEW::Renderer::show_preview_
bool show_preview_
Definition renderer.h:336
BALL::VIEW::Renderer::use_continuous_loop_
bool use_continuous_loop_
Definition renderer.h:350
BALL::VIEW::Renderer::renderOneRepresentation
virtual bool renderOneRepresentation(const Representation &representation)
BALL::VIEW::Renderer::renderMesh_
virtual void renderMesh_(const Mesh &)
Render a surface mesh.
Definition renderer.h:280
BALL::VIEW::Renderer::mapViewportTo3D
virtual Vector3 mapViewportTo3D(Position x, Position y)
BALL::VIEW::Renderer::getStage
virtual const Stage & getStage() const
Definition renderer.h:199
BALL::VIEW::Renderer::volume_width_
float volume_width_
Definition renderer.h:339
BALL::VIEW::Renderer::width_
float width_
Definition renderer.h:330
BALL::VIEW::Renderer::finish
virtual bool finish()
BALL::VIEW::Renderer::renderTwoColoredTube_
virtual void renderTwoColoredTube_(const TwoColoredTube &)
Render a tube with two colors.
Definition renderer.h:312
BALL::VIEW::Renderer::map3DToViewport
virtual Vector2 map3DToViewport(const Vector3 &vec)
BALL::VIEW::Renderer::setStereoFrustumConversion
virtual void setStereoFrustumConversion(int width_factor, int height_factor)
BALL::VIEW::Renderer::camera_
Camera camera_
Definition renderer.h:345
BALL::VIEW::Renderer::renderSphere_
virtual void renderSphere_(const Sphere &)
Render a sphere.
Definition renderer.h:296
BALL::VIEW::Renderer::renderQuadMesh_
virtual void renderQuadMesh_(const QuadMesh &)
Render a quad mesh.
Definition renderer.h:319
BALL::VIEW::Renderer::renderLabel_
virtual void renderLabel_(const Label &)
Definition renderer.h:268
BALL::VIEW::Renderer::init
virtual bool init(const Stage &stage, float height, float width)
BALL::VIEW::Renderer::renderBox_
virtual void renderBox_(const Box &)
Render a box.
Definition renderer.h:288
BALL::VIEW::Renderer::getWidth
virtual float getWidth() const
Definition renderer.h:214
BALL::VIEW::Renderer::setSize
virtual void setSize(float width, float height)
Set the size of the display.
Definition renderer.h:211
BALL::VIEW::Renderer::hasStage
bool hasStage() const
Test if a Stage was assigned to the Renderer.
BALL::VIEW::Renderer::updateMaterialForRepresentation
virtual void updateMaterialForRepresentation(Representation const *)
Definition renderer.h:121
BALL::VIEW::Renderer::scene_
Scene * scene_
Definition renderer.h:324
BALL::VIEW::Renderer::isContinuous
bool isContinuous()
Definition renderer.h:146
BALL::VIEW::Renderer::stereo_frustum_conversion_width_
Size stereo_frustum_conversion_width_
Definition renderer.h:352
BALL::VIEW::Renderer::camera_offset_
Vector3 camera_offset_
Definition renderer.h:348
BALL::VIEW::Renderer::hasFPScounter
virtual bool hasFPScounter()
Definition renderer.h:150
BALL::VIEW::Renderer::show_light_sources_
bool show_light_sources_
Definition renderer.h:342
BALL::VIEW::Renderer::setStereoMode
virtual void setStereoMode(StereoMode state)
BALL::VIEW::Renderer::getHeight
virtual float getHeight() const
Definition renderer.h:217
BALL::VIEW::Renderer::updateBackgroundColor
virtual void updateBackgroundColor()
Update the background color from the stage.
BALL::VIEW::Renderer::getStereoMode
virtual StereoMode getStereoMode() const
BALL::VIEW::Renderer::getFPS
virtual double getFPS()
Definition renderer.h:154
BALL::VIEW::Renderer::render_
virtual void render_(const GeometricObject *object)
Wrapper for the renderering of special GeometricObjects.
BALL::VIEW::Renderer::setupEnvironmentMap
virtual void setupEnvironmentMap(const QImage &image)
Setup an environment map.
BALL::VIEW::Renderer::StereoMode
StereoMode
Definition renderer.h:60
BALL::VIEW::Renderer::DUAL_VIEW_STEREO
@ DUAL_VIEW_STEREO
Stereo mode for output on two projectors.
Definition renderer.h:67
BALL::VIEW::Renderer::INTERLACED_STEREO
@ INTERLACED_STEREO
Line interlaced stereo.
Definition renderer.h:76
BALL::VIEW::Renderer::DUAL_VIEW_DIFFERENT_DISPLAY_STEREO
@ DUAL_VIEW_DIFFERENT_DISPLAY_STEREO
Stereo mode for output on two projectors with one display per head.
Definition renderer.h:70
BALL::VIEW::Renderer::NO_STEREO
@ NO_STEREO
Definition renderer.h:61
BALL::VIEW::Renderer::TOP_BOTTOM_STEREO
@ TOP_BOTTOM_STEREO
Stereo mode for top bottom views.
Definition renderer.h:73
BALL::VIEW::Renderer::ACTIVE_STEREO
@ ACTIVE_STEREO
Stereo mode for shutter glasses.
Definition renderer.h:64
BALL::VIEW::Renderer::setupStereo
virtual void setupStereo(float eye_separation, float focal_length)
BALL::VIEW::Renderer::getFrustum
virtual void getFrustum(float &near_f, float &far_f, float &left_f, float &right_f, float &top_f, float &bottom_f)
BALL::VIEW::Renderer::stage_
const Stage * stage_
Definition renderer.h:327
BALL::VIEW::Renderer::renderDisc_
virtual void renderDisc_(const Disc &)
Render a disc.
Definition renderer.h:300
BALL::VIEW::Renderer::showLightSources
virtual void showLightSources(bool show_light_sources)
Definition renderer.h:229
BALL::VIEW::Renderer::renderMultiLine_
virtual void renderMultiLine_(const MultiLine &)
Render an illuminated line.
Definition renderer.h:276
BALL::VIEW::Renderer::renderClippingPlane_
virtual void renderClippingPlane_(const ClippingPlane &)
Definition renderer.h:264
BALL::VIEW::Renderer::removeRepresentation
virtual void removeRepresentation(const Representation &)
Definition renderer.h:195
BALL::VIEW::Renderer::pickObjects
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2, std::list< GeometricObject * > &objects)
BALL::VIEW::Renderer::clear
virtual void clear()
Definition renderer.h:99
BALL::VIEW::Renderer::updateCamera
virtual void updateCamera(const Camera *camera=0)
BALL::VIEW::Renderer::useContinuousLoop
virtual void useContinuousLoop(bool use_loop)
Definition renderer.h:138
BALL::VIEW::Renderer::setStage
virtual void setStage(const Stage &stage)
Definition renderer.h:204
BALL::VIEW::Renderer::renderTwoColoredLine_
virtual void renderTwoColoredLine_(const TwoColoredLine &)
Render a line with two colors.
Definition renderer.h:308
BALL::VIEW::Renderer::init
virtual bool init(Scene &scene)
BALL::VIEW::Renderer::setPreviewMode
virtual void setPreviewMode(bool show_preview)
Definition renderer.h:223
BALL::VIEW::Renderer::Renderer
Renderer()
BALL::VIEW::Renderer::renderRuler
virtual void renderRuler()
BALL::VIEW::Renderer::stereo_
StereoMode stereo_
Definition renderer.h:355
BALL::VIEW::Renderer::setLights
virtual void setLights(bool reset_all=false)
Set the light sources according to the stage.
BALL::VIEW::Renderer::renderGridVisualisation_
virtual void renderGridVisualisation_(const GridVisualisation &)
Render a grid.
Definition renderer.h:316
BALL::VIEW::Renderer::renderSimpleBox_
virtual void renderSimpleBox_(const SimpleBox &)
Render a simple box (parallel to the axes).
Definition renderer.h:292
BALL::VIEW::Renderer::renderPoint_
virtual void renderPoint_(const Point &)
Render a single point.
Definition renderer.h:284
BALL::VIEW::Renderer::bufferRepresentation
virtual void bufferRepresentation(const Representation &)
Definition renderer.h:191
BALL::VIEW::Renderer::renderTube_
virtual void renderTube_(const Tube &)
Render a tube.
Definition renderer.h:304
BALL::VIEW::Renderer::renderLine_
virtual void renderLine_(const Line &)
Render a line.
Definition renderer.h:272
BALL::VIEW::Representation
Definition representation.h:59
BALL::VIEW::Scene
Definition scene.h:141
BALL::VIEW::SimpleBox
Definition simpleBox.h:37
BALL::VIEW::Sphere
Definition sphere.h:33
BALL::VIEW::Stage
Definition stage.h:239
BALL::VIEW::Tube
Definition tube.h:40
BALL::VIEW::TwoColoredLine
Definition twoColoredLine.h:49
BALL::VIEW::TwoColoredTube
Definition twoColoredTube.h:49
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL::Vector2
TVector2< float > Vector2
Definition vector2.h:771
BALL::VIEW
Definition constraints.h:35
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Log
BALL_EXPORT LogStream Log
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::Vector3
TVector3< float > Vector3
Definition vector3.h:1084
object.h
representation.h
stage.h
vector2.h