Browse Source

Better usage of *Basic* in class names, part 5: SceneGraph drawables.

Use AbstractCamera<dimensions, T>, Drawable<dimensions, T> and
DrawableGroup<dimensions, T> like before and add two kinds of aliases
instead of only one: AbstractBasicCamera2D<T>/AbstractBasicCamera3D<T>,
BasicDrawable2D<T>/BasicDrawable3D<T> and
BasicDrawableGroup2D<T>/BasicDrawableGroup3D<T> for abstract type and
AbstractCamera2D/AbstractCamera3D, Drawable2D/Drawable3D and
DrawableGroup2D/DrawableGroup3D for Float.

Also fixed some find&replace errors in documentation and include guards.

Partially reverts commit a0d60bbaa7.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
9450ec6e1e
  1. 4
      src/DebugTools/ForceRenderer.cpp
  2. 6
      src/DebugTools/ForceRenderer.h
  3. 4
      src/DebugTools/ObjectRenderer.cpp
  4. 6
      src/DebugTools/ObjectRenderer.h
  5. 4
      src/DebugTools/ShapeRenderer.cpp
  6. 6
      src/DebugTools/ShapeRenderer.h
  7. 64
      src/SceneGraph/AbstractCamera.h
  8. 10
      src/SceneGraph/AbstractCamera.hpp
  9. 19
      src/SceneGraph/Camera2D.h
  10. 8
      src/SceneGraph/Camera2D.hpp
  11. 15
      src/SceneGraph/Camera3D.h
  12. 16
      src/SceneGraph/Camera3D.hpp
  13. 118
      src/SceneGraph/Drawable.h
  14. 35
      src/SceneGraph/SceneGraph.h
  15. 4
      src/SceneGraph/instantiation.cpp

4
src/DebugTools/ForceRenderer.cpp

@ -64,7 +64,7 @@ const std::array<UnsignedByte, 6> indices{{
}
template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get<ForceRendererOptions>(options)) {
template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options, SceneGraph::DrawableGroup<dimensions, Float>* drawables): SceneGraph::Drawable<dimensions, Float>(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get<ForceRendererOptions>(options)) {
/* Shader */
shader = ResourceManager::instance()->get<AbstractShaderProgram, Shaders::Flat<dimensions>>(shaderKey<dimensions>());
if(!shader) ResourceManager::instance()->set<AbstractShaderProgram>(shader.key(), new Shaders::Flat<dimensions>);
@ -94,7 +94,7 @@ template<UnsignedInt dimensions> ForceRenderer<dimensions>::ForceRenderer(SceneG
ResourceManager::instance()->set<Mesh>(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual);
}
template<UnsignedInt dimensions> void ForceRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) {
template<UnsignedInt dimensions> void ForceRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>* camera) {
shader->setTransformationProjectionMatrix(camera->projectionMatrix()*Implementation::forceRendererTransformation<dimensions>(transformationMatrix.transformPoint(forcePosition), *force)*DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->scale())))
->setColor(options->color())
->use();

6
src/DebugTools/ForceRenderer.h

@ -101,7 +101,7 @@ new DebugTools::ForceRenderer2D(object, {0.3f, 1.5f, -0.7f}, &force, "my", debug
@see ForceRenderer2D, ForceRenderer3D
*/
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::BasicDrawable<dimensions, Float> {
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::Drawable<dimensions, Float> {
public:
/**
* @brief Constructor
@ -117,10 +117,10 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p
* saved as reference to original vector and thus it must be available
* for the whole lifetime of the renderer.
*/
explicit ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr);
explicit ForceRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, const typename DimensionTraits<dimensions, Float>::VectorType& forcePosition, const typename DimensionTraits<dimensions, Float>::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* drawables = nullptr);
protected:
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override;
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>* camera) override;
private:
const typename DimensionTraits<dimensions, Float>::VectorType forcePosition;

4
src/DebugTools/ObjectRenderer.cpp

@ -142,7 +142,7 @@ const std::array<UnsignedByte, 18> Renderer<3>::indices{{
}
template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(object, drawables), options(ResourceManager::instance()->get<ObjectRendererOptions>(options)) {
template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, ResourceKey options, SceneGraph::DrawableGroup<dimensions, Float>* drawables): SceneGraph::Drawable<dimensions, Float>(object, drawables), options(ResourceManager::instance()->get<ObjectRendererOptions>(options)) {
/* Shader */
shader = ResourceManager::instance()->get<AbstractShaderProgram, Shaders::VertexColor<dimensions>>(Renderer<dimensions>::shader());
if(!shader) ResourceManager::instance()->set<AbstractShaderProgram>(shader.key(), new Shaders::VertexColor<dimensions>);
@ -173,7 +173,7 @@ template<UnsignedInt dimensions> ObjectRenderer<dimensions>::ObjectRenderer(Scen
ResourceManager::instance()->set<Mesh>(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual);
}
template<UnsignedInt dimensions> void ObjectRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) {
template<UnsignedInt dimensions> void ObjectRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>* camera) {
shader->setTransformationProjectionMatrix(camera->projectionMatrix()*transformationMatrix*DimensionTraits<dimensions, Float>::MatrixType::scaling(typename DimensionTraits<dimensions, Float>::VectorType(options->size())))
->use();

6
src/DebugTools/ObjectRenderer.h

@ -84,7 +84,7 @@ new DebugTools::ObjectRenderer2D(object, "my", debugDrawables);
@see ObjectRenderer2D, ObjectRenderer3D
*/
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::BasicDrawable<dimensions, Float> {
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::Drawable<dimensions, Float> {
public:
/**
* @brief Constructor
@ -96,10 +96,10 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer:
*
* The renderer is automatically added to object's features.
*/
explicit ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr);
explicit ObjectRenderer(SceneGraph::AbstractObject<dimensions, Float>* object, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* drawables = nullptr);
protected:
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override;
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>* camera) override;
private:
Resource<ObjectRendererOptions> options;

4
src/DebugTools/ShapeRenderer.cpp

@ -97,7 +97,7 @@ template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Shapes::Implem
}
template<UnsignedInt dimensions> ShapeRenderer<dimensions>::ShapeRenderer(Shapes::AbstractShape<dimensions>* shape, ResourceKey options, SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables): SceneGraph::BasicDrawable<dimensions, Float>(shape->object(), drawables), options(ResourceManager::instance()->get<ShapeRendererOptions>(options)) {
template<UnsignedInt dimensions> ShapeRenderer<dimensions>::ShapeRenderer(Shapes::AbstractShape<dimensions>* shape, ResourceKey options, SceneGraph::DrawableGroup<dimensions, Float>* drawables): SceneGraph::Drawable<dimensions, Float>(shape->object(), drawables), options(ResourceManager::instance()->get<ShapeRendererOptions>(options)) {
Implementation::createDebugMesh(this, Shapes::Implementation::getAbstractShape(shape));
}
@ -105,7 +105,7 @@ template<UnsignedInt dimensions> ShapeRenderer<dimensions>::~ShapeRenderer() {
for(auto i: renderers) delete i;
}
template<UnsignedInt dimensions> void ShapeRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType&, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) {
template<UnsignedInt dimensions> void ShapeRenderer<dimensions>::draw(const typename DimensionTraits<dimensions, Float>::MatrixType&, SceneGraph::AbstractCamera<dimensions, Float>* camera) {
typename DimensionTraits<dimensions, Float>::MatrixType projectionMatrix = camera->projectionMatrix()*camera->cameraMatrix();
for(auto i: renderers) i->draw(options, projectionMatrix);
}

6
src/DebugTools/ShapeRenderer.h

@ -138,7 +138,7 @@ new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables);
@see ShapeRenderer2D, ShapeRenderer3D
*/
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::BasicDrawable<dimensions, Float> {
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable<dimensions, Float> {
friend void Implementation::createDebugMesh<>(ShapeRenderer<dimensions>*, const Shapes::Implementation::AbstractShape<dimensions>*);
public:
@ -154,13 +154,13 @@ template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: p
* @p shape must be available for the whole lifetime of the renderer
* and if it is group, it must not change its internal structure.
*/
explicit ShapeRenderer(Shapes::AbstractShape<dimensions>* shape, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup<dimensions, Float>* drawables = nullptr);
explicit ShapeRenderer(Shapes::AbstractShape<dimensions>* shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup<dimensions, Float>* drawables = nullptr);
~ShapeRenderer();
protected:
/** @todoc Remove Float when Doxygen properly treats this as override */
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera<dimensions, Float>* camera) override;
void draw(const typename DimensionTraits<dimensions, Float>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, Float>* camera) override;
private:
Resource<ShapeRendererOptions> options;

64
src/SceneGraph/AbstractCamera.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractBasicCamera, enum Magnum::SceneGraph::AspectRatioPolicy, typedef Magnum::SceneGraph::AbstractCamera2D, Magnum::SceneGraph::AbstractCamera3D
* @brief Class Magnum::SceneGraph::AbstractCamera, enum Magnum::SceneGraph::AspectRatioPolicy, alias Magnum::SceneGraph::AbstractBasicCamera2D, Magnum::SceneGraph::AbstractBasicCamera3D, typedef Magnum::SceneGraph::AbstractCamera2D, Magnum::SceneGraph::AbstractCamera3D
*/
#include "Math/Matrix3.h"
@ -39,7 +39,7 @@ namespace Magnum { namespace SceneGraph {
/**
@brief Camera aspect ratio policy
@see AbstractBasicCamera::setAspectRatioPolicy()
@see AbstractCamera::setAspectRatioPolicy()
*/
enum class AspectRatioPolicy: UnsignedByte {
NotPreserved, /**< Don't preserve aspect ratio (default) */
@ -55,7 +55,8 @@ namespace Implementation {
@brief Base for cameras
See Drawable documentation for more information. This class is not directly
instantiatable, use Camera2D or Camera3D subclasses instead.
instantiatable, use @ref BasicCamera2D or @ref BasicCamera3D subclasses
instead.
@section AbstractCamera-explicit-specializations Explicit template specializations
@ -67,20 +68,21 @@ relevant sections in
@ref Camera3D-explicit-specializations "Camera3D" class documentation or
@ref compilation-speedup-hpp for more information.
- @ref AbstractBasicCamera "AbstractBasicCamera<2, Float>"
- @ref AbstractBasicCamera "AbstractBasicCamera<3, Float>"
- @ref AbstractCamera "AbstractCamera<2, Float>"
- @ref AbstractCamera "AbstractCamera<3, Float>"
@see AbstractCamera2D, AbstractCamera3D, @ref scenegraph, Drawable, DrawableGroup
@see @ref scenegraph, @ref AbstractBasicCamera2D, @ref AbstractBasicCamera3D,
@ref Drawable, @ref DrawableGroup
*/
template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicCamera: public AbstractFeature<dimensions, T> {
template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature<dimensions, T> {
public:
/**
* @brief Constructor
* @param object Object holding the camera
*/
explicit AbstractBasicCamera(AbstractObject<dimensions, T>* object);
explicit AbstractCamera(AbstractObject<dimensions, T>* object);
virtual ~AbstractBasicCamera() = 0;
virtual ~AbstractCamera() = 0;
/** @brief Aspect ratio policy */
AspectRatioPolicy aspectRatioPolicy() const { return _aspectRatioPolicy; }
@ -89,7 +91,7 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
* @brief Set aspect ratio policy
* @return Pointer to self (for method chaining)
*/
AbstractBasicCamera<dimensions, T>* setAspectRatioPolicy(AspectRatioPolicy policy);
AbstractCamera<dimensions, T>* setAspectRatioPolicy(AspectRatioPolicy policy);
/**
* @brief Camera matrix
@ -138,7 +140,7 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
*
* Draws given group of drawables.
*/
virtual void draw(BasicDrawableGroup<dimensions, T>& group);
virtual void draw(DrawableGroup<dimensions, T>& group);
protected:
/** Recalculates camera matrix */
@ -162,19 +164,51 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
Vector2i _viewport;
};
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Base camera for two-dimensional scenes
Convenience alternative to <tt>%AbstractCamera<2, T></tt>. See AbstractCamera
for more information.
@note Not available on GCC < 4.7. Use <tt>%AbstractCamera<2, T></tt> instead.
@see @ref AbstractCamera2D, @ref AbstractBasicCamera3D
*/
template<class T> using AbstractBasicCamera2D = AbstractCamera<2, T>;
#endif
/**
@brief Base camera for two-dimensional float scenes
@see AbstractCamera3D
@see @ref AbstractCamera3D
*/
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef AbstractBasicCamera2D<Float> AbstractCamera2D;
#else
typedef AbstractCamera<2, Float> AbstractCamera2D;
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Base camera for three-dimensional scenes
Convenience alternative to <tt>%AbstractCamera<3, T></tt>. See AbstractCamera
for more information.
@note Not available on GCC < 4.7. Use <tt>%AbstractCamera<3, T></tt> instead.
@see @ref AbstractCamera3D, @ref AbstractBasicCamera2D
*/
typedef AbstractBasicCamera<2, Float> AbstractCamera2D;
template<class T> using AbstractBasicCamera3D = AbstractCamera<3, T>;
#endif
/**
@brief Base camera for three-dimensional float scenes
@see AbstractBasicCamera2D
@see @ref AbstractCamera2D
*/
typedef AbstractBasicCamera<3, Float> AbstractCamera3D;
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef AbstractBasicCamera3D<Float> AbstractCamera3D;
#else
typedef AbstractCamera<3, Float> AbstractCamera3D;
#endif
}}

10
src/SceneGraph/AbstractCamera.hpp

@ -70,24 +70,24 @@ template<UnsignedInt dimensions, class T> typename DimensionTraits<dimensions, T
}
template<UnsignedInt dimensions, class T> AbstractBasicCamera<dimensions, T>::AbstractBasicCamera(AbstractObject<dimensions, T>* object): AbstractFeature<dimensions, T>(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {
template<UnsignedInt dimensions, class T> AbstractCamera<dimensions, T>::AbstractCamera(AbstractObject<dimensions, T>* object): AbstractFeature<dimensions, T>(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) {
AbstractFeature<dimensions, T>::setCachedTransformations(CachedTransformation::InvertedAbsolute);
}
template<UnsignedInt dimensions, class T> AbstractBasicCamera<dimensions, T>::~AbstractBasicCamera() {}
template<UnsignedInt dimensions, class T> AbstractCamera<dimensions, T>::~AbstractCamera() {}
template<UnsignedInt dimensions, class T> AbstractBasicCamera<dimensions, T>* AbstractBasicCamera<dimensions, T>::setAspectRatioPolicy(AspectRatioPolicy policy) {
template<UnsignedInt dimensions, class T> AbstractCamera<dimensions, T>* AbstractCamera<dimensions, T>::setAspectRatioPolicy(AspectRatioPolicy policy) {
_aspectRatioPolicy = policy;
fixAspectRatio();
return this;
}
template<UnsignedInt dimensions, class T> void AbstractBasicCamera<dimensions, T>::setViewport(const Vector2i& size) {
template<UnsignedInt dimensions, class T> void AbstractCamera<dimensions, T>::setViewport(const Vector2i& size) {
_viewport = size;
fixAspectRatio();
}
template<UnsignedInt dimensions, class T> void AbstractBasicCamera<dimensions, T>::draw(BasicDrawableGroup<dimensions, T>& group) {
template<UnsignedInt dimensions, class T> void AbstractCamera<dimensions, T>::draw(DrawableGroup<dimensions, T>& group) {
AbstractObject<dimensions, T>* scene = AbstractFeature<dimensions, T>::object()->scene();
CORRADE_ASSERT(scene, "Camera::draw(): cannot draw when camera is not part of any scene", );

19
src/SceneGraph/Camera2D.h

@ -1,5 +1,5 @@
#ifndef Magnum_SceneGraph_BasicCamera2D_h
#define Magnum_SceneGraph_BasicCamera2D_h
#ifndef Magnum_SceneGraph_Camera2D_h
#define Magnum_SceneGraph_Camera2D_h
/*
This file is part of Magnum.
@ -39,7 +39,7 @@ See Drawable documentation for introduction. The camera by default displays
OpenGL unit cube `[(-1, -1, -1); (1, 1, 1)]` and doesn't do any aspect ratio
correction. Common setup example:
@code
SceneGraph::BasicCamera2D* camera = new SceneGraph::BasicCamera2D(&cameraObject);
SceneGraph::Camera2D* camera = new SceneGraph::Camera2D(&cameraObject);
camera->setProjection({4.0f/3.0f, 1.0f})
->setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend);
@endcode
@ -47,15 +47,16 @@ camera->setProjection({4.0f/3.0f, 1.0f})
@section Camera2D-explicit-specializations Explicit template specializations
The following specialization are explicitly compiled into SceneGraph library.
For other specializations (e.g. using Double type) you have to use
BasicCamera2D.hpp implementation file to avoid linker errors. See
@ref compilation-speedup-hpp for more information.
For other specializations (e.g. using Double type) you have to use Camera2D.hpp
implementation file to avoid linker errors. See @ref compilation-speedup-hpp
for more information.
- @ref BasicCamera2D "BasicCamera2D<Float>"
@see @ref Camera2D, @ref scenegraph, @ref BasicCamera3D, @ref BasicDrawable, @ref BasicDrawableGroup
@see @ref scenegraph, @ref Camera2D, @ref BasicCamera3D, @ref Drawable,
@ref DrawableGroup
*/
template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D: public AbstractBasicCamera<2, T> {
template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D: public AbstractCamera<2, T> {
public:
/**
* @brief Constructor
@ -78,7 +79,7 @@ template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D: public AbstractB
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
BasicCamera2D<T>* setAspectRatioPolicy(AspectRatioPolicy policy) {
AbstractBasicCamera<2, T>::setAspectRatioPolicy(policy);
AbstractCamera<2, T>::setAspectRatioPolicy(policy);
return this;
}
#endif

8
src/SceneGraph/Camera2D.hpp

@ -33,14 +33,16 @@
using namespace std;
/** @todo Use AbstractBasicCamera2D<T> when support for GCC 4.6 is dropped (also in header) */
namespace Magnum { namespace SceneGraph {
template<class T> BasicCamera2D<T>::BasicCamera2D(AbstractObject<2, T>* object): AbstractBasicCamera<2, T>(object) {}
template<class T> BasicCamera2D<T>::BasicCamera2D(AbstractObject<2, T>* object): AbstractCamera<2, T>(object) {}
template<class T> BasicCamera2D<T>* BasicCamera2D<T>::setProjection(const Math::Vector2<T>& size) {
AbstractBasicCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size);
AbstractCamera<2, T>::rawProjectionMatrix = Math::Matrix3<T>::projection(size);
AbstractBasicCamera<2, T>::fixAspectRatio();
AbstractCamera<2, T>::fixAspectRatio();
return this;
}

15
src/SceneGraph/Camera3D.h

@ -44,7 +44,7 @@ See Drawable documentation for introduction. The camera by default displays
OpenGL unit cube `[(-1, -1, -1); (1, 1, 1)]` with orthographic projection and
doesn't do any aspect ratio correction. Common setup example:
@code
SceneGraph::BasicCamera3D* camera = new SceneGraph::BasicCamera3D(&cameraObject);
SceneGraph::Camera3D* camera = new SceneGraph::Camera3D(&cameraObject);
camera->setPerspective({}, 0.001f, 100.0f)
->setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend);
@endcode
@ -52,15 +52,16 @@ camera->setPerspective({}, 0.001f, 100.0f)
@section Camera3D-explicit-specializations Explicit template specializations
The following specialization are explicitly compiled into SceneGraph library.
For other specializations (e.g. using Double type) you have to use
BasicCamera3D.hpp implementation file to avoid linker errors. See
@ref compilation-speedup-hpp for more information.
For other specializations (e.g. using Double type) you have to use Camera3D.hpp
implementation file to avoid linker errors. See @ref compilation-speedup-hpp
for more information.
- @ref BasicCamera3D "BasicCamera3D<Float>"
@see @ref Camera3D, @ref scenegraph, @ref BasicCamera2D, @ref BasicDrawable, @ref BasicDrawableGroup
@see @ref scenegraph, @ref Camera3D, @ref BasicCamera2D, @ref Drawable,
@ref DrawableGroup
*/
template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D: public AbstractBasicCamera<3, T> {
template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D: public AbstractCamera<3, T> {
public:
/**
* @brief Constructor
@ -111,7 +112,7 @@ template<class T> class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D: public AbstractB
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
BasicCamera3D<T>* setAspectRatioPolicy(AspectRatioPolicy policy) {
AbstractBasicCamera<3, T>::setAspectRatioPolicy(policy);
AbstractCamera<3, T>::setAspectRatioPolicy(policy);
return this;
}
#endif

16
src/SceneGraph/Camera3D.hpp

@ -31,17 +31,19 @@
#include "AbstractCamera.hpp"
#include "Camera3D.h"
/** @todo Use AbstractBasicCamera3D<T> when support for GCC 4.6 is dropped (also in header) */
namespace Magnum { namespace SceneGraph {
template<class T> BasicCamera3D<T>::BasicCamera3D(AbstractObject<3, T>* object): AbstractBasicCamera<3, T>(object), _near(T(0)), _far(T(0)) {}
template<class T> BasicCamera3D<T>::BasicCamera3D(AbstractObject<3, T>* object): AbstractCamera<3, T>(object), _near(T(0)), _far(T(0)) {}
template<class T> BasicCamera3D<T>* BasicCamera3D<T>::setOrthographic(const Math::Vector2<T>& size, T near, T far) {
/** @todo Get near/far from the matrix */
_near = near;
_far = far;
AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::orthographicProjection(size, near, far);
AbstractBasicCamera<3, T>::fixAspectRatio();
AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::orthographicProjection(size, near, far);
AbstractCamera<3, T>::fixAspectRatio();
return this;
}
@ -50,8 +52,8 @@ template<class T> BasicCamera3D<T>* BasicCamera3D<T>::setPerspective(const Math:
_near = near;
_far = far;
AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(size, near, far);
AbstractBasicCamera<3, T>::fixAspectRatio();
AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(size, near, far);
AbstractCamera<3, T>::fixAspectRatio();
return this;
}
@ -60,8 +62,8 @@ template<class T> BasicCamera3D<T>* BasicCamera3D<T>::setPerspective(Math::Rad<T
_near = near;
_far = far;
AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(fov, aspectRatio, near, far);
AbstractBasicCamera<3, T>::fixAspectRatio();
AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4<T>::perspectiveProjection(fov, aspectRatio, near, far);
AbstractCamera<3, T>::fixAspectRatio();
return this;
}

118
src/SceneGraph/Drawable.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::BasicDrawable, Magnum::SceneGraph::BasicDrawableGroup, typedef Magnum::SceneGraph::Drawable2D, Magnum::SceneGraph::Drawable3D, Magnum::SceneGraph::DrawableGroup2D, Magnum::SceneGraph::DrawableGroup3D
* @brief Class Magnum::SceneGraph::Drawable, Magnum::SceneGraph::DrawableGroup, alias Magnum::SceneGraph::BasicDrawable2D, Magnum::SceneGraph::BasicDrawable3D, Magnum::SceneGraph::BasicDrawableGroup2D, Magnum::SceneGraph::BasicDrawableGroup3D, typedef Magnum::SceneGraph::Drawable2D, Magnum::SceneGraph::Drawable3D, Magnum::SceneGraph::DrawableGroup2D, Magnum::SceneGraph::DrawableGroup3D
*/
#include "AbstractGroupedFeature.h"
@ -35,7 +35,7 @@ namespace Magnum { namespace SceneGraph {
/**
@brief %Drawable
Adds drawing function to the object. Each Drawable is part of some DrawableGroup
Adds drawing function to the object. Each %Drawable is part of some DrawableGroup
and the whole group is drawn with particular camera using AbstractCamera::draw().
@section Drawable-usage Usage
@ -60,8 +60,8 @@ class DrawableObject: public Object3D, SceneGraph::Drawable3D {
@endcode
Then you add these objects to your scene and some drawable group and transform
them as you like. You can also use BasicDrawableGroup::add() and
BasicDrawableGroup::remove().
them as you like. You can also use DrawableGroup::add() and
DrawableGroup::remove().
@code
Scene3D scene;
SceneGraph::DrawableGroup3D drawables;
@ -78,7 +78,7 @@ The last thing you need is Camera attached to some object (thus using its
transformation) and with it you can perform drawing in your draw event
implementation. See Camera2D and Camera3D documentation for more information.
@code
Camera3D<> camera(&cameraObject);
Camera3D camera(&cameraObject);
void MyApplication::drawEvent() {
camera.draw(drawables);
@ -114,9 +114,10 @@ void MyApplication::drawEvent() {
}
@endcode
@see Drawable2D, Drawable3D, @ref scenegraph, DrawableGroup2D, DrawableGroup3D
@see @ref scenegraph, @ref BasicDrawable2D, @ref BasicDrawable3D,
@ref Drawable2D, @ref Drawable3D, @ref DrawableGroup
*/
template<UnsignedInt dimensions, class T> class BasicDrawable: public AbstractGroupedFeature<dimensions, BasicDrawable<dimensions, T>, T> {
template<UnsignedInt dimensions, class T> class Drawable: public AbstractGroupedFeature<dimensions, Drawable<dimensions, T>, T> {
public:
/**
* @brief Constructor
@ -124,9 +125,9 @@ template<UnsignedInt dimensions, class T> class BasicDrawable: public AbstractGr
* @param drawables Group this drawable belongs to
*
* Adds the feature to the object and also to the group, if specified.
* Otherwise you can use BasicDrawableGroup::add().
* Otherwise you can use DrawableGroup::add().
*/
explicit BasicDrawable(AbstractObject<dimensions, T>* object, BasicDrawableGroup<dimensions, T>* drawables = nullptr): AbstractGroupedFeature<dimensions, BasicDrawable<dimensions, T>, T>(object, drawables) {}
explicit Drawable(AbstractObject<dimensions, T>* object, DrawableGroup<dimensions, T>* drawables = nullptr): AbstractGroupedFeature<dimensions, Drawable<dimensions, T>, T>(object, drawables) {}
/**
* @brief Draw the object using given camera
@ -136,48 +137,113 @@ template<UnsignedInt dimensions, class T> class BasicDrawable: public AbstractGr
*
* Projection matrix can be retrieved from AbstractCamera::projectionMatrix().
*/
virtual void draw(const typename DimensionTraits<dimensions, T>::MatrixType& transformationMatrix, AbstractBasicCamera<dimensions, T>* camera) = 0;
virtual void draw(const typename DimensionTraits<dimensions, T>::MatrixType& transformationMatrix, AbstractCamera<dimensions, T>* camera) = 0;
};
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief %Drawable for two-dimensional scenes
Convenience alternative to <tt>%Drawable<2, T></tt>. See Drawable for more
information.
@note Not available on GCC < 4.7. Use <tt>%Drawable<2, T></tt> instead.
@see @ref Drawable2D, @ref BasicDrawable3D
*/
template<class T> using BasicDrawable2D = Drawable<2, T>;
#endif
/**
@brief %Drawable for two-dimensional float scenes
@see @ref Drawable3D
*/
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef BasicDrawable2D<Float> Drawable2D;
#else
typedef Drawable<2, Float> Drawable2D;
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Two-dimensional drawable for float scenes
@brief %Drawable for three-dimensional scenes
@see Drawable3D
Convenience alternative to <tt>%Drawable<3, T></tt>. See Drawable for more
information.
@note Not available on GCC < 4.7. Use <tt>%Drawable<3, T></tt> instead.
@see @ref Drawable3D, @ref BasicDrawable3D
*/
typedef BasicDrawable<2, Float> Drawable2D;
template<class T> using BasicDrawable3D = Drawable<3, T>;
#endif
/**
@brief Three-dimensional drawable for float scenes
@brief %Drawable for three-dimensional float scenes
@see Drawable2D
@see @ref Drawable2D
*/
typedef BasicDrawable<3, Float> Drawable3D;
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef BasicDrawable3D<Float> Drawable3D;
#else
typedef Drawable<3, Float> Drawable3D;
#endif
/**
@brief Group of drawables
See Drawable for more information.
@see @ref scenegraph, DrawableGroup2D, DrawableGroup3D
See @ref Drawable for more information.
@see @ref scenegraph, @ref BasicDrawableGroup2D, @ref BasicDrawableGroup3D,
@ref DrawableGroup2D, @ref DrawableGroup3D
*/
#ifndef CORRADE_GCC46_COMPATIBILITY
template<UnsignedInt dimensions, class T> using BasicDrawableGroup = FeatureGroup<dimensions, BasicDrawable<dimensions, T>, T>;
template<UnsignedInt dimensions, class T> using DrawableGroup = FeatureGroup<dimensions, Drawable<dimensions, T>, T>;
#else
template<UnsignedInt dimensions, class T> class BasicDrawableGroup: public FeatureGroup<dimensions, BasicDrawable<dimensions, T>, T> {};
template<UnsignedInt dimensions, class T> class DrawableGroup: public FeatureGroup<dimensions, Drawable<dimensions, T>, T> {};
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Group of drawables for two-dimensional scenes
Convenience alternative to <tt>%DrawableGroup<2, T></tt>. See Drawable for
more information.
@note Not available on GCC < 4.7. Use <tt>%Drawable<2, T></tt> instead.
@see @ref DrawableGroup2D, @ref BasicDrawableGroup3D
*/
template<class T> using BasicDrawableGroup2D = DrawableGroup<2, T>;
#endif
/**
@brief Group of drawables for two-dimensional float scenes
@see @ref DrawableGroup3D
*/
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef BasicDrawableGroup2D<Float> DrawableGroup2D;
#else
typedef DrawableGroup<2, Float> DrawableGroup2D;
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Group of two-dimensional drawables for float scenes
@brief Group of drawables for three-dimensional scenes
@see DrawableGroup3D
Convenience alternative to <tt>%DrawableGroup<3, T></tt>. See Drawable for
more information.
@note Not available on GCC < 4.7. Use <tt>%Drawable<3, T></tt> instead.
@see @ref DrawableGroup3D, @ref BasicDrawableGroup2D
*/
typedef BasicDrawableGroup<2, Float> DrawableGroup2D;
template<class T> using BasicDrawableGroup3D = DrawableGroup<3, T>;
#endif
/**
@brief Group of three-dimensional drawables for float scenes
@brief Group of drawables for three-dimensional float scenes
@see DrawableGroup2D
@see @ref DrawableGroup2D
*/
typedef BasicDrawableGroup<3, Float> DrawableGroup3D;
#ifndef CORRADE_GCC46_COMPATIBILITY
typedef BasicDrawableGroup3D<Float> DrawableGroup3D;
#else
typedef DrawableGroup<3, Float> DrawableGroup3D;
#endif
}}

35
src/SceneGraph/SceneGraph.h

@ -38,9 +38,16 @@ namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT
enum class AspectRatioPolicy: UnsignedByte;
template<UnsignedInt, class> class AbstractBasicCamera;
typedef AbstractBasicCamera<2, Float> AbstractCamera2D;
typedef AbstractBasicCamera<3, Float> AbstractCamera3D;
template<UnsignedInt, class> class AbstractCamera;
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class T> using AbstractBasicCamera2D = AbstractCamera<2, T>;
template<class T> using AbstractBasicCamera3D = AbstractCamera<3, T>;
typedef AbstractBasicCamera2D<Float> AbstractCamera2D;
typedef AbstractBasicCamera3D<Float> AbstractCamera3D;
#else
typedef AbstractCamera<2, Float> AbstractCamera2D;
typedef AbstractCamera<3, Float> AbstractCamera3D;
#endif
/* Enum CachedTransformation and CachedTransformations used only directly */
@ -128,9 +135,13 @@ template<class> class BasicCamera3D;
typedef BasicCamera2D<Float> Camera2D;
typedef BasicCamera3D<Float> Camera3D;
template<UnsignedInt, class> class BasicDrawable;
typedef BasicDrawable<2, Float> Drawable2D;
typedef BasicDrawable<3, Float> Drawable3D;
template<UnsignedInt, class> class Drawable;
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class T> using BasicDrawable2D = Drawable<2, T>;
template<class T> using BasicDrawable3D = Drawable<3, T>;
typedef BasicDrawable2D<Float> Drawable2D;
typedef BasicDrawable3D<Float> Drawable3D;
#endif
template<class> class BasicDualComplexTransformation;
template<class> class BasicDualQuaternionTransformation;
@ -146,12 +157,16 @@ template<class Feature> using FeatureGroup3D = BasicFeatureGroup3D<Feature, Floa
#endif
#ifndef CORRADE_GCC46_COMPATIBILITY
template<UnsignedInt dimensions, class T> using BasicDrawableGroup = FeatureGroup<dimensions, BasicDrawable<dimensions, T>, T>;
template<UnsignedInt dimensions, class T> using DrawableGroup = FeatureGroup<dimensions, Drawable<dimensions, T>, T>;
template<class T> using BasicDrawableGroup2D = DrawableGroup<2, T>;
template<class T> using BasicDrawableGroup3D = DrawableGroup<3, T>;
typedef BasicDrawableGroup2D<Float> DrawableGroup2D;
typedef BasicDrawableGroup3D<Float> DrawableGroup3D;
#else
template<UnsignedInt, class> class BasicDrawableGroup;
template<UnsignedInt, class> class DrawableGroup;
typedef DrawableGroup<2, Float> DrawableGroup2D;
typedef DrawableGroup<3, Float> DrawableGroup3D;
#endif
typedef BasicDrawableGroup<2, Float> DrawableGroup2D;
typedef BasicDrawableGroup<3, Float> DrawableGroup3D;
template<class> class BasicMatrixTransformation2D;
template<class> class BasicMatrixTransformation3D;

4
src/SceneGraph/instantiation.cpp

@ -47,8 +47,8 @@ template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature<3, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeatureGroup<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeatureGroup<3, Float>;
template class AbstractBasicCamera<2, Float>;
template class AbstractBasicCamera<3, Float>;
template class AbstractCamera<2, Float>;
template class AbstractCamera<3, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D<Float>;
template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D<Float>;

Loading…
Cancel
Save