diff --git a/src/DebugTools/ForceRenderer.cpp b/src/DebugTools/ForceRenderer.cpp index e0998962c..96c441c9b 100644 --- a/src/DebugTools/ForceRenderer.cpp +++ b/src/DebugTools/ForceRenderer.cpp @@ -64,7 +64,7 @@ const std::array indices{{ } -template ForceRenderer::ForceRenderer(SceneGraph::AbstractObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get(options)) { +template ForceRenderer::ForceRenderer(SceneGraph::AbstractObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options, SceneGraph::BasicDrawableGroup* drawables): SceneGraph::BasicDrawable(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get(options)) { /* Shader */ shader = ResourceManager::instance()->get>(shaderKey()); if(!shader) ResourceManager::instance()->set(shader.key(), new Shaders::Flat); @@ -94,7 +94,7 @@ template ForceRenderer::ForceRenderer(SceneG ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } -template void ForceRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) { +template void ForceRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) { shader->setTransformationProjectionMatrix(camera->projectionMatrix()*Implementation::forceRendererTransformation(transformationMatrix.transformPoint(forcePosition), *force)*DimensionTraits::MatrixType::scaling(typename DimensionTraits::VectorType(options->scale()))) ->setColor(options->color()) ->use(); diff --git a/src/DebugTools/ForceRenderer.h b/src/DebugTools/ForceRenderer.h index fdc32978b..b77851cd5 100644 --- a/src/DebugTools/ForceRenderer.h +++ b/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 class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::Drawable { +template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::BasicDrawable { public: /** * @brief Constructor @@ -117,11 +117,10 @@ template 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* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ForceRenderer(SceneGraph::AbstractObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup* drawables = nullptr); protected: - /** @todoc Remove Float when Doxygen properly treats this as override */ - void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) override; private: const typename DimensionTraits::VectorType forcePosition; diff --git a/src/DebugTools/ObjectRenderer.cpp b/src/DebugTools/ObjectRenderer.cpp index e81064260..62e24612c 100644 --- a/src/DebugTools/ObjectRenderer.cpp +++ b/src/DebugTools/ObjectRenderer.cpp @@ -142,7 +142,7 @@ const std::array Renderer<3>::indices{{ } -template ObjectRenderer::ObjectRenderer(SceneGraph::AbstractObject* object, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(object, drawables), options(ResourceManager::instance()->get(options)) { +template ObjectRenderer::ObjectRenderer(SceneGraph::AbstractObject* object, ResourceKey options, SceneGraph::BasicDrawableGroup* drawables): SceneGraph::BasicDrawable(object, drawables), options(ResourceManager::instance()->get(options)) { /* Shader */ shader = ResourceManager::instance()->get>(Renderer::shader()); if(!shader) ResourceManager::instance()->set(shader.key(), new Shaders::VertexColor); @@ -173,7 +173,7 @@ template ObjectRenderer::ObjectRenderer(Scen ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } -template void ObjectRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) { +template void ObjectRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) { shader->setTransformationProjectionMatrix(camera->projectionMatrix()*transformationMatrix*DimensionTraits::MatrixType::scaling(typename DimensionTraits::VectorType(options->size()))) ->use(); diff --git a/src/DebugTools/ObjectRenderer.h b/src/DebugTools/ObjectRenderer.h index 1c3c77f26..cd21ea50b 100644 --- a/src/DebugTools/ObjectRenderer.h +++ b/src/DebugTools/ObjectRenderer.h @@ -84,7 +84,7 @@ new DebugTools::ObjectRenderer2D(object, "my", debugDrawables); @see ObjectRenderer2D, ObjectRenderer3D */ -template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::Drawable { +template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::BasicDrawable { public: /** * @brief Constructor @@ -96,11 +96,10 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: * * The renderer is automatically added to object's features. */ - explicit ObjectRenderer(SceneGraph::AbstractObject* object, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ObjectRenderer(SceneGraph::AbstractObject* object, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup* drawables = nullptr); protected: - /** @todoc Remove Float when Doxygen properly treats this as override */ - void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) override; private: Resource options; diff --git a/src/DebugTools/ShapeRenderer.cpp b/src/DebugTools/ShapeRenderer.cpp index eaaefe838..a15ae1d3c 100644 --- a/src/DebugTools/ShapeRenderer.cpp +++ b/src/DebugTools/ShapeRenderer.cpp @@ -94,7 +94,7 @@ template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Shapes::Implem } -template ShapeRenderer::ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { +template ShapeRenderer::ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options, SceneGraph::BasicDrawableGroup* drawables): SceneGraph::BasicDrawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { Implementation::createDebugMesh(this, Shapes::Implementation::getAbstractShape(shape)); } @@ -102,7 +102,7 @@ template ShapeRenderer::~ShapeRenderer() { for(auto i: renderers) delete i; } -template void ShapeRenderer::draw(const typename DimensionTraits::MatrixType&, SceneGraph::AbstractCamera* camera) { +template void ShapeRenderer::draw(const typename DimensionTraits::MatrixType&, SceneGraph::AbstractBasicCamera* camera) { typename DimensionTraits::MatrixType projectionMatrix = camera->projectionMatrix()*camera->cameraMatrix(); for(auto i: renderers) i->draw(options, projectionMatrix); } diff --git a/src/DebugTools/ShapeRenderer.h b/src/DebugTools/ShapeRenderer.h index 3ec2dc1f4..9c8e0eaf1 100644 --- a/src/DebugTools/ShapeRenderer.h +++ b/src/DebugTools/ShapeRenderer.h @@ -138,7 +138,7 @@ new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables); @see ShapeRenderer2D, ShapeRenderer3D */ -template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable { +template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::BasicDrawable { friend void Implementation::createDebugMesh<>(ShapeRenderer*, const Shapes::Implementation::AbstractShape*); public: @@ -154,13 +154,13 @@ template 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* shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup* drawables = nullptr); ~ShapeRenderer(); protected: /** @todoc Remove Float when Doxygen properly treats this as override */ - void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) override; private: Resource options; diff --git a/src/SceneGraph/AbstractCamera.h b/src/SceneGraph/AbstractCamera.h index 43287ba10..e7e71fb25 100644 --- a/src/SceneGraph/AbstractCamera.h +++ b/src/SceneGraph/AbstractCamera.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractCamera, enum Magnum::SceneGraph::AspectRatioPolicy, alias Magnum::SceneGraph::AbstractCamera2D, Magnum::SceneGraph::AbstractCamera3D + * @brief Class Magnum::SceneGraph::AbstractBasicCamera, enum Magnum::SceneGraph::AspectRatioPolicy, 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 AbstractCamera::setAspectRatioPolicy() +@see AbstractBasicCamera::setAspectRatioPolicy() */ enum class AspectRatioPolicy: UnsignedByte { NotPreserved, /**< Don't preserve aspect ratio (default) */ @@ -67,25 +67,20 @@ relevant sections in @ref Camera3D-explicit-specializations "Camera3D" class documentation or @ref compilation-speedup-hpp for more information. - - @ref AbstractCamera "AbstractCamera<2, Float>" - - @ref AbstractCamera "AbstractCamera<3, Float>" + - @ref AbstractBasicCamera "AbstractBasicCamera<2, Float>" + - @ref AbstractBasicCamera "AbstractBasicCamera<3, Float>" -@see @ref scenegraph, Drawable, DrawableGroup, AbstractCamera2D, AbstractCamera3D +@see AbstractCamera2D, AbstractCamera3D, @ref scenegraph, Drawable, DrawableGroup */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature { +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicCamera: public AbstractFeature { public: /** * @brief Constructor * @param object Object holding the camera */ - explicit AbstractCamera(AbstractObject* object); + explicit AbstractBasicCamera(AbstractObject* object); - virtual ~AbstractCamera() = 0; + virtual ~AbstractBasicCamera() = 0; /** @brief Aspect ratio policy */ AspectRatioPolicy aspectRatioPolicy() const { return _aspectRatioPolicy; } @@ -94,7 +89,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature* setAspectRatioPolicy(AspectRatioPolicy policy); + AbstractBasicCamera* setAspectRatioPolicy(AspectRatioPolicy policy); /** * @brief Camera matrix @@ -143,7 +138,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature& group); + virtual void draw(BasicDrawableGroup& group); protected: /** Recalculates camera matrix */ @@ -167,37 +162,19 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature%AbstractCamera<2, T>. See AbstractCamera -for more information. -@note Not available on GCC < 4.7. Use %AbstractCamera<2, T> instead. @see AbstractCamera3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractCamera2D = AbstractCamera<2, T>; +typedef AbstractBasicCamera<2, Float> AbstractCamera2D; /** -@brief Base for three-dimensional cameras +@brief Base camera for three-dimensional float scenes -Convenience alternative to %AbstractCamera<3, T>. See AbstractCamera -for more information. -@note Not available on GCC < 4.7. Use %AbstractCamera<3, T> instead. -@see AbstractCamera2D +@see AbstractBasicCamera2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractCamera3D = AbstractCamera<3, T>; -#endif +typedef AbstractBasicCamera<3, Float> AbstractCamera3D; }} diff --git a/src/SceneGraph/AbstractCamera.hpp b/src/SceneGraph/AbstractCamera.hpp index 413cc4b86..91d7ed59a 100644 --- a/src/SceneGraph/AbstractCamera.hpp +++ b/src/SceneGraph/AbstractCamera.hpp @@ -70,24 +70,24 @@ template typename DimensionTraits AbstractCamera::AbstractCamera(AbstractObject* object): AbstractFeature(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) { +template AbstractBasicCamera::AbstractBasicCamera(AbstractObject* object): AbstractFeature(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) { AbstractFeature::setCachedTransformations(CachedTransformation::InvertedAbsolute); } -template AbstractCamera::~AbstractCamera() {} +template AbstractBasicCamera::~AbstractBasicCamera() {} -template AbstractCamera* AbstractCamera::setAspectRatioPolicy(AspectRatioPolicy policy) { +template AbstractBasicCamera* AbstractBasicCamera::setAspectRatioPolicy(AspectRatioPolicy policy) { _aspectRatioPolicy = policy; fixAspectRatio(); return this; } -template void AbstractCamera::setViewport(const Vector2i& size) { +template void AbstractBasicCamera::setViewport(const Vector2i& size) { _viewport = size; fixAspectRatio(); } -template void AbstractCamera::draw(DrawableGroup& group) { +template void AbstractBasicCamera::draw(BasicDrawableGroup& group) { AbstractObject* scene = AbstractFeature::object()->scene(); CORRADE_ASSERT(scene, "Camera::draw(): cannot draw when camera is not part of any scene", ); diff --git a/src/SceneGraph/Camera2D.h b/src/SceneGraph/Camera2D.h index ad52e41b6..6e12b1672 100644 --- a/src/SceneGraph/Camera2D.h +++ b/src/SceneGraph/Camera2D.h @@ -1,5 +1,5 @@ -#ifndef Magnum_SceneGraph_Camera2D_h -#define Magnum_SceneGraph_Camera2D_h +#ifndef Magnum_SceneGraph_BasicCamera2D_h +#define Magnum_SceneGraph_BasicCamera2D_h /* This file is part of Magnum. @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Camera2D + * @brief Class Magnum::SceneGraph::BasicCamera2D, typedef Magnum::SceneGraph::Camera2D */ #include "AbstractCamera.h" @@ -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::Camera2D<>* camera = new SceneGraph::Camera2D<>(&cameraObject); +SceneGraph::BasicCamera2D<>* camera = new SceneGraph::BasicCamera2D<>(&cameraObject); camera->setProjection({4.0f/3.0f, 1.0f}) ->setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend); @endcode @@ -48,19 +48,14 @@ camera->setProjection({4.0f/3.0f, 1.0f}) The following specialization are explicitly compiled into SceneGraph library. For other specializations (e.g. using Double type) you have to use -Camera2D.hpp implementation file to avoid linker errors. See +BasicCamera2D.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information. - - @ref Camera2D "Camera2D" + - @ref BasicCamera2D "BasicCamera2D" -@see @ref scenegraph, Camera3D, Drawable, DrawableGroup +@see @ref Camera2D, @ref scenegraph, @ref BasicCamera3D, @ref BasicDrawable, @ref BasicDrawableGroup */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { +template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D: public AbstractBasicCamera<2, T> { public: /** * @brief Constructor @@ -69,7 +64,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { * Sets orthographic projection to the default OpenGL cube (range @f$ [-1; 1] @f$ in all directions). * @see setProjection() */ - explicit Camera2D(AbstractObject<2, T>* object); + explicit BasicCamera2D(AbstractObject<2, T>* object); /** * @brief Set projection @@ -78,17 +73,24 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { * * @see Matrix3::projection() */ - Camera2D* setProjection(const Math::Vector2& size); + BasicCamera2D* setProjection(const Math::Vector2& size); /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - Camera2D* setAspectRatioPolicy(AspectRatioPolicy policy) { - AbstractCamera<2, T>::setAspectRatioPolicy(policy); + BasicCamera2D* setAspectRatioPolicy(AspectRatioPolicy policy) { + AbstractBasicCamera<2, T>::setAspectRatioPolicy(policy); return this; } #endif }; +/** +@brief Camera for two-dimensional float scenes + +@see @ref Camera3D +*/ +typedef BasicCamera2D Camera2D; + }} #endif diff --git a/src/SceneGraph/Camera2D.hpp b/src/SceneGraph/Camera2D.hpp index 900d976b1..16926a89d 100644 --- a/src/SceneGraph/Camera2D.hpp +++ b/src/SceneGraph/Camera2D.hpp @@ -35,12 +35,12 @@ using namespace std; namespace Magnum { namespace SceneGraph { -template Camera2D::Camera2D(AbstractObject<2, T>* object): AbstractCamera<2, T>(object) {} +template BasicCamera2D::BasicCamera2D(AbstractObject<2, T>* object): AbstractBasicCamera<2, T>(object) {} -template Camera2D* Camera2D::setProjection(const Math::Vector2& size) { - AbstractCamera<2, T>::rawProjectionMatrix = Math::Matrix3::projection(size); +template BasicCamera2D* BasicCamera2D::setProjection(const Math::Vector2& size) { + AbstractBasicCamera<2, T>::rawProjectionMatrix = Math::Matrix3::projection(size); - AbstractCamera<2, T>::fixAspectRatio(); + AbstractBasicCamera<2, T>::fixAspectRatio(); return this; } diff --git a/src/SceneGraph/Camera3D.h b/src/SceneGraph/Camera3D.h index 6885037df..c2331d38a 100644 --- a/src/SceneGraph/Camera3D.h +++ b/src/SceneGraph/Camera3D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Camera3D + * @brief Class Magnum::SceneGraph::BasicCamera3D, typedef Magnum::SceneGraph::Camera3D */ #include "AbstractCamera.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::Camera3D<>* camera = new SceneGraph::Camera3D<>(&cameraObject); +SceneGraph::BasicCamera3D<>* camera = new SceneGraph::BasicCamera3D<>(&cameraObject); camera->setPerspective({}, 0.001f, 100.0f) ->setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend); @endcode @@ -53,25 +53,20 @@ camera->setPerspective({}, 0.001f, 100.0f) The following specialization are explicitly compiled into SceneGraph library. For other specializations (e.g. using Double type) you have to use -Camera3D.hpp implementation file to avoid linker errors. See +BasicCamera3D.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information. - - @ref Camera3D "Camera3D" + - @ref BasicCamera3D "BasicCamera3D" -@see @ref scenegraph, Camera2D, Drawable, DrawableGroup +@see @ref Camera3D, @ref scenegraph, @ref BasicCamera2D, @ref BasicDrawable, @ref BasicDrawableGroup */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { +template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D: public AbstractBasicCamera<3, T> { public: /** * @brief Constructor * @param object %Object holding this feature */ - explicit Camera3D(AbstractObject<3, T>* object); + explicit BasicCamera3D(AbstractObject<3, T>* object); /** * @brief Set orthographic projection @@ -82,7 +77,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { * * @see setPerspective(), Matrix4::orthographicProjection() */ - Camera3D* setOrthographic(const Math::Vector2& size, T near, T far); + BasicCamera3D* setOrthographic(const Math::Vector2& size, T near, T far); /** * @brief Set perspective projection @@ -93,7 +88,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { * * @see setOrthographic(), Matrix4::perspectiveProjection() */ - Camera3D* setPerspective(const Math::Vector2& size, T near, T far); + BasicCamera3D* setPerspective(const Math::Vector2& size, T near, T far); /** * @brief Set perspective projection @@ -105,7 +100,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { * * @see setOrthographic(), Matrix4::perspectiveProjection() */ - Camera3D* setPerspective(Math::Rad fov, T aspectRatio, T near, T far); + BasicCamera3D* setPerspective(Math::Rad fov, T aspectRatio, T near, T far); /** @brief Near clipping plane */ T near() const { return _near; } @@ -115,8 +110,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - Camera3D* setAspectRatioPolicy(AspectRatioPolicy policy) { - AbstractCamera<3, T>::setAspectRatioPolicy(policy); + BasicCamera3D* setAspectRatioPolicy(AspectRatioPolicy policy) { + AbstractBasicCamera<3, T>::setAspectRatioPolicy(policy); return this; } #endif @@ -125,6 +120,13 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { T _near, _far; }; +/** +@brief Camera for three-dimensional float scenes + +@see @ref Camera2D +*/ +typedef BasicCamera3D Camera3D; + }} #endif diff --git a/src/SceneGraph/Camera3D.hpp b/src/SceneGraph/Camera3D.hpp index 732cba3f7..81f15bfa0 100644 --- a/src/SceneGraph/Camera3D.hpp +++ b/src/SceneGraph/Camera3D.hpp @@ -33,35 +33,35 @@ namespace Magnum { namespace SceneGraph { -template Camera3D::Camera3D(AbstractObject<3, T>* object): AbstractCamera<3, T>(object), _near(T(0)), _far(T(0)) {} +template BasicCamera3D::BasicCamera3D(AbstractObject<3, T>* object): AbstractBasicCamera<3, T>(object), _near(T(0)), _far(T(0)) {} -template Camera3D* Camera3D::setOrthographic(const Math::Vector2& size, T near, T far) { +template BasicCamera3D* BasicCamera3D::setOrthographic(const Math::Vector2& size, T near, T far) { /** @todo Get near/far from the matrix */ _near = near; _far = far; - AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4::orthographicProjection(size, near, far); - AbstractCamera<3, T>::fixAspectRatio(); + AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4::orthographicProjection(size, near, far); + AbstractBasicCamera<3, T>::fixAspectRatio(); return this; } -template Camera3D* Camera3D::setPerspective(const Math::Vector2& size, T near, T far) { +template BasicCamera3D* BasicCamera3D::setPerspective(const Math::Vector2& size, T near, T far) { /** @todo Get near/far from the matrix */ _near = near; _far = far; - AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(size, near, far); - AbstractCamera<3, T>::fixAspectRatio(); + AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(size, near, far); + AbstractBasicCamera<3, T>::fixAspectRatio(); return this; } -template Camera3D* Camera3D::setPerspective(Math::Rad fov, T aspectRatio, T near, T far) { +template BasicCamera3D* BasicCamera3D::setPerspective(Math::Rad fov, T aspectRatio, T near, T far) { /** @todo Get near/far from the matrix */ _near = near; _far = far; - AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(fov, aspectRatio, near, far); - AbstractCamera<3, T>::fixAspectRatio(); + AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(fov, aspectRatio, near, far); + AbstractBasicCamera<3, T>::fixAspectRatio(); return this; } diff --git a/src/SceneGraph/Drawable.h b/src/SceneGraph/Drawable.h index 5afb8b80d..c6dfe2ea0 100644 --- a/src/SceneGraph/Drawable.h +++ b/src/SceneGraph/Drawable.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Drawable, Magnum::SceneGraph::DrawableGroup, alias Magnum::SceneGraph::Drawable2D, Magnum::SceneGraph::Drawable3D, Magnum::SceneGraph::DrawableGroup2D, Magnum::SceneGraph::DrawableGroup3D + * @brief Class Magnum::SceneGraph::BasicDrawable, Magnum::SceneGraph::BasicDrawableGroup, 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 @@ -47,24 +47,24 @@ for introduction). Example: typedef SceneGraph::Object> Object3D; typedef SceneGraph::Scene> Scene3D; -class DrawableObject: public Object3D, SceneGraph::Drawable3D<> { +class DrawableObject: public Object3D, SceneGraph::Drawable3D { public: - DrawableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D<>* group = nullptr): Object3D(parent), SceneGraph::Drawable3D<>(this, group) { + DrawableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D* group = nullptr): Object3D(parent), SceneGraph::Drawable3D(this, group) { // ... } - void draw(const Matrix4& transformationMatrix, AbstractCamera3D<>* camera) override { + void draw(const Matrix4& transformationMatrix, AbstractCamera3D* camera) override { // ... } } @endcode Then you add these objects to your scene and some drawable group and transform -them as you like. You can also use DrawableGroup::add() and -DrawableGroup::remove(). +them as you like. You can also use BasicDrawableGroup::add() and +BasicDrawableGroup::remove(). @code Scene3D scene; -SceneGraph::DrawableGroup3D<> drawables; +SceneGraph::DrawableGroup3D drawables; (new DrawableObject(&scene, &drawables)) ->translate(Vector3::yAxis(-0.3f)) @@ -97,7 +97,7 @@ parameters once for whole group instead of setting them again in each draw() implementation. Example: @code Shaders::PhongShader* shader; -SceneGraph::DrawableGroup3D<> phongObjects, transparentObjects; +SceneGraph::DrawableGroup3D phongObjects, transparentObjects; void MyApplication::drawEvent() { shader->setProjectionMatrix(camera->projectionMatrix()) @@ -114,14 +114,9 @@ void MyApplication::drawEvent() { } @endcode -@see @ref scenegraph, Drawable2D, Drawable3D, DrawableGroup2D, DrawableGroup3D +@see Drawable2D, Drawable3D, @ref scenegraph, DrawableGroup2D, DrawableGroup3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class Drawable: public AbstractGroupedFeature, T> { +template class BasicDrawable: public AbstractGroupedFeature, T> { public: /** * @brief Constructor @@ -129,9 +124,9 @@ class Drawable: public AbstractGroupedFeature* object, DrawableGroup* drawables = nullptr): AbstractGroupedFeature, T>(object, drawables) {} + explicit BasicDrawable(AbstractObject* object, BasicDrawableGroup* drawables = nullptr): AbstractGroupedFeature, T>(object, drawables) {} /** * @brief Draw the object using given camera @@ -141,40 +136,22 @@ class Drawable: public AbstractGroupedFeature::MatrixType& transformationMatrix, AbstractCamera* camera) = 0; + virtual void draw(const typename DimensionTraits::MatrixType& transformationMatrix, AbstractBasicCamera* camera) = 0; }; -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Two-dimensional drawable +@brief Two-dimensional drawable for float scenes -Convenience alternative to %Drawable<2, T>. See Drawable for more -information. -@note Not available on GCC < 4.7. Use %Drawable<2, T> instead. @see Drawable3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Drawable2D = Drawable<2, T>; +typedef BasicDrawable<2, Float> Drawable2D; /** -@brief Three-dimensional drawable +@brief Three-dimensional drawable for float scenes -Convenience alternative to %Drawable<3, T>. See Drawable for more -information. -@note Not available on GCC < 4.7. Use %Drawable<3, T> instead. @see Drawable2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Drawable3D = Drawable<3, T>; -#endif +typedef BasicDrawable<3, Float> Drawable3D; /** @brief Group of drawables @@ -183,52 +160,24 @@ See Drawable for more information. @see @ref scenegraph, DrawableGroup2D, DrawableGroup3D */ #ifndef CORRADE_GCC46_COMPATIBILITY -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using DrawableGroup = FeatureGroup, T>; -#else -#ifdef DOXYGEN_GENERATING_OUTPUT -template +template using BasicDrawableGroup = FeatureGroup, T>; #else -template -#endif -class DrawableGroup: public FeatureGroup, T> {}; +template class BasicDrawableGroup: public FeatureGroup, T> {}; #endif -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Group of two-dimensional drawables +@brief Group of two-dimensional drawables for float scenes -Convenience alternative to %DrawableGroup<2, T>. See Drawable for -more information. -@note Not available on GCC < 4.7. Use %Drawable<2, T> instead. @see DrawableGroup3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using DrawableGroup2D = DrawableGroup<2, T>; +typedef BasicDrawableGroup<2, Float> DrawableGroup2D; /** -@brief Group of three-dimensional drawables +@brief Group of three-dimensional drawables for float scenes -Convenience alternative to %DrawableGroup<3, T>. See Drawable for -more information. -@note Not available on GCC < 4.7. Use %Drawable<3, T> instead. @see DrawableGroup2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using DrawableGroup3D = DrawableGroup<3, T>; -#endif +typedef BasicDrawableGroup<3, Float> DrawableGroup3D; }} diff --git a/src/SceneGraph/SceneGraph.h b/src/SceneGraph/SceneGraph.h index 05904638a..7cda3ffc4 100644 --- a/src/SceneGraph/SceneGraph.h +++ b/src/SceneGraph/SceneGraph.h @@ -38,11 +38,9 @@ namespace Magnum { namespace SceneGraph { #ifndef DOXYGEN_GENERATING_OUTPUT enum class AspectRatioPolicy: UnsignedByte; -template class AbstractCamera; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractCamera2D = AbstractCamera<2, T>; -template using AbstractCamera3D = AbstractCamera<3, T>; -#endif +template class AbstractBasicCamera; +typedef AbstractBasicCamera<2, Float> AbstractCamera2D; +typedef AbstractBasicCamera<3, Float> AbstractCamera3D; /* Enum CachedTransformation and CachedTransformations used only directly */ @@ -97,14 +95,14 @@ template using AnimableGroup2D = AnimableGroup<2, T>; template using AnimableGroup3D = AnimableGroup<3, T>; #endif -template class Camera2D; -template class Camera3D; +template class BasicCamera2D; +template class BasicCamera3D; +typedef BasicCamera2D Camera2D; +typedef BasicCamera3D Camera3D; -template class Drawable; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using Drawable2D = Drawable<2, T>; -template using Drawable3D = Drawable<3, T>; -#endif +template class BasicDrawable; +typedef BasicDrawable<2, Float> Drawable2D; +typedef BasicDrawable<3, Float> Drawable3D; template class DualComplexTransformation; template class DualQuaternionTransformation; @@ -116,12 +114,12 @@ template using FeatureGroup3D = FeatureGroup<3, #endif #ifndef CORRADE_GCC46_COMPATIBILITY -template using DrawableGroup = FeatureGroup, T>; -template using DrawableGroup2D = DrawableGroup<2, T>; -template using DrawableGroup3D = DrawableGroup<3, T>; +template using BasicDrawableGroup = FeatureGroup, T>; #else -template class DrawableGroup; +template class BasicDrawableGroup; #endif +typedef BasicDrawableGroup<2, Float> DrawableGroup2D; +typedef BasicDrawableGroup<3, Float> DrawableGroup3D; template class MatrixTransformation2D; template class MatrixTransformation3D; diff --git a/src/SceneGraph/Test/CameraTest.cpp b/src/SceneGraph/Test/CameraTest.cpp index c31da6842..697dccd1e 100644 --- a/src/SceneGraph/Test/CameraTest.cpp +++ b/src/SceneGraph/Test/CameraTest.cpp @@ -51,8 +51,6 @@ class CameraTest: public TestSuite::Tester { typedef SceneGraph::Object> Object2D; typedef SceneGraph::Object> Object3D; typedef SceneGraph::Scene> Scene3D; -typedef SceneGraph::Camera2D<> Camera2D; -typedef SceneGraph::Camera3D<> Camera3D; CameraTest::CameraTest() { addTests({&CameraTest::fixAspectRatio, @@ -158,12 +156,12 @@ void CameraTest::projectionSizeViewport() { } void CameraTest::draw() { - class Drawable: public SceneGraph::Drawable<3> { + class Drawable: public SceneGraph::Drawable3D { public: - Drawable(AbstractObject<3>* object, DrawableGroup<3>* group, Matrix4& result): SceneGraph::Drawable<3>(object, group), result(result) {} + Drawable(AbstractObject<3>* object, DrawableGroup3D* group, Matrix4& result): SceneGraph::Drawable3D(object, group), result(result) {} protected: - void draw(const Matrix4& transformationMatrix, AbstractCamera<3>*) { + void draw(const Matrix4& transformationMatrix, AbstractCamera3D*) { result = transformationMatrix; } @@ -171,7 +169,7 @@ void CameraTest::draw() { Matrix4& result; }; - DrawableGroup<3> group; + DrawableGroup3D group; Scene3D scene; Object3D first(&scene); diff --git a/src/SceneGraph/instantiation.cpp b/src/SceneGraph/instantiation.cpp index b3db08d88..c20388f03 100644 --- a/src/SceneGraph/instantiation.cpp +++ b/src/SceneGraph/instantiation.cpp @@ -47,10 +47,10 @@ template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature<3, Float>; template class AbstractFeatureGroup<2, Float>; template class AbstractFeatureGroup<3, Float>; -template class AbstractCamera<2, Float>; -template class AbstractCamera<3, Float>; -template class Camera2D; -template class Camera3D; +template class AbstractBasicCamera<2, Float>; +template class AbstractBasicCamera<3, Float>; +template class BasicCamera2D; +template class BasicCamera3D; template class MAGNUM_SCENEGRAPH_EXPORT Object>; template class MAGNUM_SCENEGRAPH_EXPORT Object>;