| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#ifndef BALL_VIEW_RENDERING_RENDERERS_RENDERER_H |
| 6 |
#define BALL_VIEW_RENDERING_RENDERERS_RENDERER_H |
| 7 |
|
| 8 |
#ifndef BALL_VIEW_KERNEL_REPRESENTATION_H |
| 9 |
# include <BALL/VIEW/KERNEL/representation.h> |
| 10 |
#endif |
| 11 |
|
| 12 |
#ifndef BALL_CONCEPT_OBJECT_H |
| 13 |
# include <BALL/CONCEPT/object.h> |
| 14 |
#endif |
| 15 |
|
| 16 |
#ifndef BALL_VIEW_KERNEL_STAGE_H |
| 17 |
# include <BALL/VIEW/KERNEL/stage.h> |
| 18 |
#endif |
| 19 |
|
| 20 |
#ifndef BALL_MATHS_VECTOR2_H |
| 21 |
# include <BALL/MATHS/vector2.h> |
| 22 |
#endif |
| 23 |
|
| 24 |
class QImage; |
| 25 |
|
| 26 |
namespace BALL |
| 27 |
{ |
| 28 |
namespace VIEW |
| 29 |
{ |
| 30 |
class Scene; |
| 31 |
class Line; |
| 32 |
class MultiLine; |
| 33 |
class Tube; |
| 34 |
class Mesh; |
| 35 |
class Label; |
| 36 |
class Point; |
| 37 |
class Sphere; |
| 38 |
class Disc; |
| 39 |
class Box; |
| 40 |
class SimpleBox; |
| 41 |
class TwoColoredLine; |
| 42 |
class TwoColoredTube; |
| 43 |
class ClippingPlane; |
| 44 |
class GridVisualisation; |
| 45 |
class QuadMesh; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
class BALL_VIEW_EXPORT Renderer |
| 55 |
{ |
| 56 |
public: |
| 57 |
|
| 58 |
|
| 59 |
enum StereoMode |
| 60 |
{ |
| 61 |
NO_STEREO = 0, |
| 62 |
|
| 63 |
|
| 64 |
ACTIVE_STEREO, |
| 65 |
|
| 66 |
|
| 67 |
DUAL_VIEW_STEREO, |
| 68 |
|
| 69 |
|
| 70 |
DUAL_VIEW_DIFFERENT_DISPLAY_STEREO, |
| 71 |
|
| 72 |
|
| 73 |
TOP_BOTTOM_STEREO, |
| 74 |
|
| 75 |
|
| 76 |
INTERLACED_STEREO |
| 77 |
}; |
| 78 |
|
| 79 |
BALL_CREATE(Renderer) |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
Renderer(); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
Renderer(const Renderer& renderer); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
virtual ~Renderer() {} |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
virtual void clear(){} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
virtual bool init(Scene& scene); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
virtual bool init(const Stage& stage, float height, float width); |
| 110 |
|
| 111 |
|
| 112 |
virtual void setLights(bool reset_all = false); |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
virtual void updateCamera(const Camera* camera = 0); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
virtual void updateMaterialForRepresentation(Representation const*) {}; |
| 122 |
|
| 123 |
|
| 124 |
virtual void updateBackgroundColor(); |
| 125 |
|
| 126 |
|
| 127 |
virtual void setupEnvironmentMap(const QImage& image); |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
virtual void setupStereo(float eye_separation, float focal_length); |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
virtual void useContinuousLoop(bool use_loop) |
| 139 |
{ |
| 140 |
|
| 141 |
use_continuous_loop_ = use_loop; |
| 142 |
}; |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
bool isContinuous() { return use_continuous_loop_; } |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
virtual bool hasFPScounter() { return false; } |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
virtual double getFPS() { return 0; } |
| 155 |
|
| 156 |
|
| 157 |
virtual bool finish(); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
virtual Vector3 mapViewportTo3D(Position x, Position y); |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
virtual Vector2 map3DToViewport(const Vector3& vec); |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2, |
| 172 |
std::list<GeometricObject*>& objects); |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f, |
| 177 |
float& top_f, float& bottom_f); |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
virtual bool renderOneRepresentation(const Representation& representation); |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
virtual void bufferRepresentation(const Representation& ) {}; |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
virtual void removeRepresentation(const Representation& ) {}; |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
virtual const Stage& getStage() const |
| 200 |
{ return *stage_;} |
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
virtual void setStage(const Stage& stage) |
| 205 |
{ stage_ = &stage;} |
| 206 |
|
| 207 |
|
| 208 |
bool hasStage() const; |
| 209 |
|
| 210 |
|
| 211 |
virtual void setSize(float width, float height) {width_ = width; height_ = height;} |
| 212 |
|
| 213 |
|
| 214 |
virtual float getWidth() const { return width_;} |
| 215 |
|
| 216 |
|
| 217 |
virtual float getHeight() const { return height_;} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
virtual void setPreviewMode(bool show_preview) { show_preview_ = show_preview; } |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
virtual void showLightSources(bool show_light_sources) { show_light_sources_ = show_light_sources; } |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
virtual void renderRuler(); |
| 239 |
|
| 240 |
|
| 241 |
virtual void setStereoMode(StereoMode state); |
| 242 |
|
| 243 |
|
| 244 |
virtual StereoMode getStereoMode() const; |
| 245 |
|
| 246 |
|
| 247 |
virtual void setStereoFrustumConversion(int width_factor, int height_factor); |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
bool operator == (const Renderer& ) const |
| 256 |
{ return true; } |
| 257 |
|
| 258 |
|
| 259 |
virtual void render_(const GeometricObject* object); |
| 260 |
|
| 261 |
protected: |
| 262 |
|
| 263 |
|
| 264 |
virtual void renderClippingPlane_(const ClippingPlane&) |
| 265 |
{Log.error() << "renderClippingPlane_ not implemented in derived Renderer class" << std::endl;} |
| 266 |
|
| 267 |
|
| 268 |
virtual void renderLabel_(const Label& ) |
| 269 |
{Log.error() << "renderLabel_ not implemented in derived Renderer class" << std::endl;} |
| 270 |
|
| 271 |
|
| 272 |
virtual void renderLine_(const Line& ) |
| 273 |
{Log.error() << "renderLine_ not implemented in derived Renderer class" << std::endl;} |
| 274 |
|
| 275 |
|
| 276 |
virtual void renderMultiLine_(const MultiLine& ) |
| 277 |
{Log.error() << "renderMultiLine_ not implemented in derived Renderer class" << std::endl;} |
| 278 |
|
| 279 |
|
| 280 |
virtual void renderMesh_(const Mesh& ) |
| 281 |
{Log.error() << "renderMesh_ not implemented in derived Renderer class" << std::endl;} |
| 282 |
|
| 283 |
|
| 284 |
virtual void renderPoint_(const Point& ) |
| 285 |
{Log.error() << "renderPoint_ not implemented in derived Renderer class" << std::endl;} |
| 286 |
|
| 287 |
|
| 288 |
virtual void renderBox_(const Box& ) |
| 289 |
{Log.error() << "renderBox_ not implemented in derived Renderer class" << std::endl;} |
| 290 |
|
| 291 |
|
| 292 |
virtual void renderSimpleBox_(const SimpleBox& ) |
| 293 |
{Log.error() << "renderSimpleBox_ not implemented in derived Renderer class" << std::endl;} |
| 294 |
|
| 295 |
|
| 296 |
virtual void renderSphere_(const Sphere& ) |
| 297 |
{Log.error() << "renderSphere_ not implemented in derived Renderer class" << std::endl;} |
| 298 |
|
| 299 |
|
| 300 |
virtual void renderDisc_(const Disc& ) |
| 301 |
{Log.error() << "renderDisc_ not implemented in derived Renderer class" << std::endl;} |
| 302 |
|
| 303 |
|
| 304 |
virtual void renderTube_(const Tube& ) |
| 305 |
{Log.error() << "renderTube_ not implemented in derived Renderer class" << std::endl;} |
| 306 |
|
| 307 |
|
| 308 |
virtual void renderTwoColoredLine_(const TwoColoredLine& ) |
| 309 |
{Log.error() << "renderTwoColoredLine_ not implemented in derived Renderer class" << std::endl;} |
| 310 |
|
| 311 |
|
| 312 |
virtual void renderTwoColoredTube_(const TwoColoredTube& ) |
| 313 |
{Log.error() << "renderTwoColoredTube_ not implemented in derived Renderer class" << std::endl;} |
| 314 |
|
| 315 |
|
| 316 |
virtual void renderGridVisualisation_(const GridVisualisation&) |
| 317 |
{Log.error() << "renderGridVisualisation_ not implemented in derived Renderer class" << std::endl;} |
| 318 |
|
| 319 |
virtual void renderQuadMesh_(const QuadMesh&) |
| 320 |
{Log.error() << "renderQuadMesh_ not implemented in derived Renderer class" << std::endl;} |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
Scene* scene_; |
| 325 |
|
| 326 |
|
| 327 |
const Stage* stage_; |
| 328 |
|
| 329 |
|
| 330 |
float width_; |
| 331 |
|
| 332 |
|
| 333 |
float height_; |
| 334 |
|
| 335 |
|
| 336 |
bool show_preview_; |
| 337 |
|
| 338 |
|
| 339 |
float volume_width_; |
| 340 |
|
| 341 |
|
| 342 |
bool show_light_sources_; |
| 343 |
|
| 344 |
|
| 345 |
Camera camera_; |
| 346 |
|
| 347 |
|
| 348 |
Vector3 camera_offset_; |
| 349 |
|
| 350 |
bool use_continuous_loop_; |
| 351 |
|
| 352 |
Size stereo_frustum_conversion_width_; |
| 353 |
Size stereo_frustum_conversion_height_; |
| 354 |
|
| 355 |
StereoMode stereo_; |
| 356 |
}; |
| 357 |
|
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
#endif |