Loading...
Searching...
No Matches
rtfactRenderer.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_VIEW_RENDERING_RENDERERS_RTFACTRENDERER_H
#define BALL_VIEW_RENDERING_RENDERERS_RTFACTRENDERER_H
#define BALLVIEW_RTFACTRENDERER_THROW(exceptionName, message) (throw BALL::Exception::##exceptionName##(__FILE__, __LINE__, message))
#include <BALL/VIEW/RENDERING/RENDERERS/raytracingRenderer.h>
#include <BALL/VIEW/WIDGETS/scene.h>
#include <BALL/VIEW/KERNEL/stage.h>
#include <BALL/VIEW/KERNEL/representationManager.h>
#include <BALL/VIEW/PRIMITIVES/mesh.h>
#include <BALL/VIEW/KERNEL/mainControl.h>
#include <BALL/MATHS/surface.h>
#include <BALL/MATHS/vector3.h>
#include <BALL/DATATYPE/hashMap.h>
#include <RTpieCpp/RayTracerHandle.hpp>
#include <RTfact/Model/Image/BasicImage2D.hpp>
#include <RTfact/Model/Framebuffer/Image2DFramebuffer.hpp>
#include <RTfact/Utils/FPSMeter.hpp>
namespace boost
{
template <>
struct hash< RTpieCpp::MeshHandle >
{
public:
union conv
{
size_t s;
const void *p;
};
size_t operator()(const RTpieCpp::MeshHandle& x ) const throw() {
conv c;
c.p=x.get();
return c.s;
}
};
template <>
struct hash< RTpieCpp::InstanceHandle >
{
public:
union conv
{
size_t s;
const void *p;
};
size_t operator()(const RTpieCpp::InstanceHandle& x ) const throw() {
conv c;
c.p=x.get();
return c.s;
}
};
}
namespace BALL
{
namespace VIEW
{
class BALL_VIEW_EXPORT RTfactRenderer
: public RaytracingRenderer
{
public:
class RTfactData
{
public:
std::vector<RTpieCpp::GeometryHandle> object_handles;
std::vector<RTpieCpp::MeshHandle> mesh_handles;
std::vector<RTpieCpp::InstanceHandle> instance_handles;
std::vector<RTpieCpp::AppearanceHandle> material_handles;
std::vector<RTpieCpp::GeometryHandle> cutPlanes;
std::vector<RTpieCpp::MeshHandle> cutPlaneMeshes;
std::vector<RTpieCpp::InstanceHandle> cutPlaneInstances;
RTpieCpp::AppearanceHandle cutPlaneShader;
bool has_been_disabled;
};
RTfactRenderer()
: RaytracingRenderer(),
rtfact_needs_update_(false)
{
}
virtual ~RTfactRenderer()
{
}
virtual bool hasFPScounter();
virtual double getFPS();
/************************************************************************/
/* RaytracingRenderer methods */
/************************************************************************/
virtual bool init(Scene& scene);
virtual String getRenderer()
{
return "RTfact-RTRemote Ray Tracer";
}
virtual void formatUpdated()
{
}
virtual GeometricObject* pickObject(Position x, Position y);
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2,
std::list<GeometricObject*>& objects);
virtual void setSize(float width, float height);
virtual void setupStereo(float eye_separation, float focal_length);
virtual void getFrustum(float& near_f, float& far_f, float& left_f, float& right_f, float& top_f, float& bottom_f);
virtual void setFrustum(float near_f, float far_f, float left_f, float right_f, float top_f, float bottom_f);
virtual void prepareBufferedRendering(const Stage& stage);
virtual void renderToBufferImpl(FrameBufferPtr buffer);
virtual void useContinuousLoop(bool use_loop);
void bufferRepresentation(const Representation& rep);
void bufferRepresentationDynamic(const Representation& rep);
void removeRepresentation(const Representation& rep);
void setLights(bool reset_all = false);
void updateCamera(const Camera* camera = 0);
void updateBackgroundColor();
void setupEnvironmentMap(const QImage& image);
void updateMaterialForRepresentation(Representation const* rep);
void transformTube(const TwoColoredTube& tube, float *trafo);
void transformLine(const TwoColoredLine& line, float *trafo);
void updateMaterialFromStage(RTpieCpp::AppearanceHandle& material);
void convertMaterial(Stage::Material const& rt_material, RTpieCpp::AppearanceHandle& material);
virtual std::vector<float> intersectRaysWithGeometry(const std::vector<Vector3>& origins, const std::vector<Vector3>& directions);
private:
static const float vectorDifferenceTolerance_;
bool doVectorsDiffer(const Vector3& vecA, const Vector3& vecB);
template<typename taPixelType>
void renderImpl(taPixelType* buffer, const unsigned int width, const unsigned int height, const unsigned int pitch);
void renderImpl(float* buffer, const unsigned int width, const unsigned int height, const unsigned int pitch)
{
}
std::vector<RTpieCpp::LightHandle> lights_;
typedef RTfact::BasicImage2D<float> t_ColorImage;
typedef RTfact::BasicImage2D<float> t_DistanceImage;
typedef RTfact::Image2DFramebuffer<
t_ColorImage,
t_DistanceImage> t_Framebuffer;
typedef RTfact::BasicImage2D<unsigned char> t_ByteColorImage;
typedef RTfact::BasicImage2D<unsigned char> t_ByteDistanceImage;
typedef RTfact::Image2DFramebuffer<
t_ByteColorImage,
t_ByteDistanceImage> t_ByteFramebuffer;
RTpieCpp::SceneHandle sceneHandle;
RTpieCpp::RayTracerHandle rayTracer;
RTpieCpp::CameraHandle cameraHandle;
RTpieCpp::FrameBufferHandle renderBuffer;
RTpieCpp::RenderTaskHandle renderTask;
t_Framebuffer framebuffer;
t_ByteFramebuffer byteFramebuffer;
RTfact::FPSMeter fpsMeter;
RTpieCpp::PickTaskHandle pickTask;
HashMap<Representation const*, RTfactData> objects_;
HashMap<RTpieCpp::InstanceHandle, GeometricObject*> geometric_objects_inst;
HashMap<RTpieCpp::MeshHandle, GeometricObject*> geometric_objects_;
Surface sphere_template_;
Surface tube_template_;
bool rtfact_needs_update_;
Vector3 last_camera_position;
Vector3 last_camera_view_vec;
Vector3 last_camera_lookup;
float x_scale_;
float y_scale_;
};
} // namespace VIEW
} // namespace BALL
#endif // BALL_VIEW_RENDERING_RTFACTRENDERER_H
BALL_VIEW_EXPORT
#define BALL_VIEW_EXPORT
Definition COMMON/global.h:52
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions).
Definition hashMap.h:74
BALL::String
Definition string.h:57
BALL::VIEW::Camera
Definition camera.h:24
BALL::VIEW::GeometricObject
Definition geometricObject.h:37
BALL::VIEW::RTfactRenderer::RTfactData
Definition rtfactRenderer.h:78
BALL::VIEW::RTfactRenderer::RTfactData::instance_handles
std::vector< RTpieCpp::InstanceHandle > instance_handles
The instances (visible objects).
Definition rtfactRenderer.h:88
BALL::VIEW::RTfactRenderer::RTfactData::cutPlaneShader
RTpieCpp::AppearanceHandle cutPlaneShader
Cut-planes material.
Definition rtfactRenderer.h:103
BALL::VIEW::RTfactRenderer::RTfactData::cutPlanes
std::vector< RTpieCpp::GeometryHandle > cutPlanes
Cut-plane geometries.
Definition rtfactRenderer.h:94
BALL::VIEW::RTfactRenderer::RTfactData::object_handles
std::vector< RTpieCpp::GeometryHandle > object_handles
The object handles (all objects).
Definition rtfactRenderer.h:82
BALL::VIEW::RTfactRenderer::RTfactData::cutPlaneInstances
std::vector< RTpieCpp::InstanceHandle > cutPlaneInstances
Cut-plane instances.
Definition rtfactRenderer.h:100
BALL::VIEW::RTfactRenderer::RTfactData::mesh_handles
std::vector< RTpieCpp::MeshHandle > mesh_handles
The meshes.
Definition rtfactRenderer.h:85
BALL::VIEW::RTfactRenderer::RTfactData::material_handles
std::vector< RTpieCpp::AppearanceHandle > material_handles
The materials.
Definition rtfactRenderer.h:91
BALL::VIEW::RTfactRenderer::RTfactData::cutPlaneMeshes
std::vector< RTpieCpp::MeshHandle > cutPlaneMeshes
Cut-plane meshes.
Definition rtfactRenderer.h:97
BALL::VIEW::RTfactRenderer::RTfactData::has_been_disabled
bool has_been_disabled
Mark previously disabled representations.
Definition rtfactRenderer.h:106
BALL::VIEW::RTfactRenderer::removeRepresentation
void removeRepresentation(const Representation &rep)
BALL::VIEW::RTfactRenderer::formatUpdated
virtual void formatUpdated()
Definition rtfactRenderer.h:135
BALL::VIEW::RTfactRenderer::pickObject
virtual GeometricObject * pickObject(Position x, Position y)
BALL::VIEW::RTfactRenderer::transformLine
void transformLine(const TwoColoredLine &line, float *trafo)
BALL::VIEW::RTfactRenderer::setFrustum
virtual void setFrustum(float near_f, float far_f, float left_f, float right_f, float top_f, float bottom_f)
BALL::VIEW::RTfactRenderer::pickObjects
virtual void pickObjects(Position x1, Position y1, Position x2, Position y2, std::list< GeometricObject * > &objects)
BALL::VIEW::RTfactRenderer::transformTube
void transformTube(const TwoColoredTube &tube, float *trafo)
BALL::VIEW::RTfactRenderer::updateCamera
void updateCamera(const Camera *camera=0)
BALL::VIEW::RTfactRenderer::hasFPScounter
virtual bool hasFPScounter()
BALL::VIEW::RTfactRenderer::~RTfactRenderer
virtual ~RTfactRenderer()
Destructor.
Definition rtfactRenderer.h:117
BALL::VIEW::RTfactRenderer::updateMaterialForRepresentation
void updateMaterialForRepresentation(Representation const *rep)
BALL::VIEW::RTfactRenderer::setSize
virtual void setSize(float width, float height)
Set the size of the display.
BALL::VIEW::RTfactRenderer::setupStereo
virtual void setupStereo(float eye_separation, float focal_length)
BALL::VIEW::RTfactRenderer::getRenderer
virtual String getRenderer()
Definition rtfactRenderer.h:130
BALL::VIEW::RTfactRenderer::setLights
void setLights(bool reset_all=false)
Set the light sources according to the stage.
BALL::VIEW::RTfactRenderer::bufferRepresentationDynamic
void bufferRepresentationDynamic(const Representation &rep)
BALL::VIEW::RTfactRenderer::useContinuousLoop
virtual void useContinuousLoop(bool use_loop)
BALL::VIEW::RTfactRenderer::setupEnvironmentMap
void setupEnvironmentMap(const QImage &image)
Setup an environment map.
BALL::VIEW::RTfactRenderer::intersectRaysWithGeometry
virtual std::vector< float > intersectRaysWithGeometry(const std::vector< Vector3 > &origins, const std::vector< Vector3 > &directions)
BALL::VIEW::RTfactRenderer::updateBackgroundColor
void updateBackgroundColor()
Update the background color from the stage.
BALL::VIEW::RTfactRenderer::prepareBufferedRendering
virtual void prepareBufferedRendering(const Stage &stage)
BALL::VIEW::RTfactRenderer::updateMaterialFromStage
void updateMaterialFromStage(RTpieCpp::AppearanceHandle &material)
BALL::VIEW::RTfactRenderer::convertMaterial
void convertMaterial(Stage::Material const &rt_material, RTpieCpp::AppearanceHandle &material)
BALL::VIEW::RTfactRenderer::bufferRepresentation
void bufferRepresentation(const Representation &rep)
BALL::VIEW::RTfactRenderer::getFrustum
virtual void getFrustum(float &near_f, float &far_f, float &left_f, float &right_f, float &top_f, float &bottom_f)
BALL::VIEW::RTfactRenderer::renderToBufferImpl
virtual void renderToBufferImpl(FrameBufferPtr buffer)
BALL::VIEW::RTfactRenderer::RTfactRenderer
RTfactRenderer()
Default Constructor.
Definition rtfactRenderer.h:110
BALL::VIEW::RTfactRenderer::getFPS
virtual double getFPS()
BALL::VIEW::RTfactRenderer::init
virtual bool init(Scene &scene)
BALL::VIEW::RaytracingRenderer
Definition raytracingRenderer.h:34
BALL::VIEW::Representation
Definition representation.h:59
BALL::VIEW::Scene
Definition scene.h:141
BALL::VIEW::Stage::Material
Definition stage.h:246
BALL::VIEW::Stage
Definition stage.h:239
BALL::VIEW::TwoColoredLine
Definition twoColoredLine.h:49
BALL::VIEW::TwoColoredTube
Definition twoColoredTube.h:49
BALL::Surface
TSurface< float > Surface
Definition surface.h:488
hashMap.h
mainControl.h
mesh.h
BALL::VIEW
Definition constraints.h:35
BALL::VIEW::FrameBufferPtr
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition renderTarget.h:222
BALL
Definition constants.h:13
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::Vector3
TVector3< float > Vector3
Definition vector3.h:1084
boost
Definition graphAlgorithms.h:27
raytracingRenderer.h
representationManager.h
scene.h
stage.h
boost::hash< RTpieCpp::InstanceHandle >::operator()
size_t operator()(const RTpieCpp::InstanceHandle &x) const
Definition rtfactRenderer.h:54
boost::hash< RTpieCpp::MeshHandle >::operator()
size_t operator()(const RTpieCpp::MeshHandle &x) const
Definition rtfactRenderer.h:37
surface.h
boost::hash< RTpieCpp::InstanceHandle >::conv
Definition rtfactRenderer.h:49
boost::hash< RTpieCpp::InstanceHandle >::conv::p
const void * p
Definition rtfactRenderer.h:51
boost::hash< RTpieCpp::InstanceHandle >::conv::s
size_t s
Definition rtfactRenderer.h:50
boost::hash< RTpieCpp::MeshHandle >::conv
Definition rtfactRenderer.h:32
boost::hash< RTpieCpp::MeshHandle >::conv::s
size_t s
Definition rtfactRenderer.h:33
boost::hash< RTpieCpp::MeshHandle >::conv::p
const void * p
Definition rtfactRenderer.h:34
vector3.h