@ -25,7 +25,7 @@
*/
*/
/** @file
/** @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 : : Basic Drawable, Magnum : : SceneGraph : : Basic DrawableGroup, typedef Magnum : : SceneGraph : : Drawable2D , Magnum : : SceneGraph : : Drawable3D , Magnum : : SceneGraph : : DrawableGroup2D , Magnum : : SceneGraph : : DrawableGroup3D
*/
*/
# include "AbstractGroupedFeature.h"
# include "AbstractGroupedFeature.h"
@ -35,7 +35,7 @@ namespace Magnum { namespace SceneGraph {
/**
/**
@ brief % Drawable
@ 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 ( ) .
and the whole group is drawn with particular camera using AbstractCamera : : draw ( ) .
@ section Drawable - usage Usage
@ section Drawable - usage Usage
@ -47,24 +47,24 @@ for introduction). Example:
typedef SceneGraph : : Object < SceneGraph : : MatrixTransformation3D < > > Object3D ;
typedef SceneGraph : : Object < SceneGraph : : MatrixTransformation3D < > > Object3D ;
typedef SceneGraph : : Scene < SceneGraph : : MatrixTransformation3D < > > Scene3D ;
typedef SceneGraph : : Scene < SceneGraph : : MatrixTransformation3D < > > Scene3D ;
class DrawableObject : public Object3D , SceneGraph : : Drawable3D < > {
class DrawableObject : public Object3D , SceneGraph : : Drawable3D {
public :
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
@ endcode
Then you add these objects to your scene and some drawable group and transform
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
them as you like . You can also use Basic DrawableGroup: : add ( ) and
DrawableGroup : : remove ( ) .
Basic DrawableGroup: : remove ( ) .
@ code
@ code
Scene3D scene ;
Scene3D scene ;
SceneGraph : : DrawableGroup3D < > drawables ;
SceneGraph : : DrawableGroup3D drawables ;
( new DrawableObject ( & scene , & drawables ) )
( new DrawableObject ( & scene , & drawables ) )
- > translate ( Vector3 : : yAxis ( - 0.3f ) )
- > translate ( Vector3 : : yAxis ( - 0.3f ) )
@ -97,7 +97,7 @@ parameters once for whole group instead of setting them again in each draw()
implementation . Example :
implementation . Example :
@ code
@ code
Shaders : : PhongShader * shader ;
Shaders : : PhongShader * shader ;
SceneGraph : : DrawableGroup3D < > phongObjects , transparentObjects ;
SceneGraph : : DrawableGroup3D phongObjects , transparentObjects ;
void MyApplication : : drawEvent ( ) {
void MyApplication : : drawEvent ( ) {
shader - > setProjectionMatrix ( camera - > projectionMatrix ( ) )
shader - > setProjectionMatrix ( camera - > projectionMatrix ( ) )
@ -114,14 +114,9 @@ void MyApplication::drawEvent() {
}
}
@ endcode
@ endcode
@ see @ ref scenegraph , Drawable2D , Drawable3D , DrawableGroup2D , DrawableGroup3D
@ see Drawable2D , Drawable3D , @ ref scenegraph , DrawableGroup2D , DrawableGroup3D
*/
*/
# ifndef DOXYGEN_GENERATING_OUTPUT
template < UnsignedInt dimensions , class T > class BasicDrawable : public AbstractGroupedFeature < dimensions , BasicDrawable < dimensions , T > , T > {
template < UnsignedInt dimensions , class T >
# else
template < UnsignedInt dimensions , class T = Float >
# endif
class Drawable : public AbstractGroupedFeature < dimensions , Drawable < dimensions , T > , T > {
public :
public :
/**
/**
* @ brief Constructor
* @ brief Constructor
@ -129,9 +124,9 @@ class Drawable: public AbstractGroupedFeature<dimensions, Drawable<dimensions, T
* @ param drawables Group this drawable belongs to
* @ param drawables Group this drawable belongs to
*
*
* Adds the feature to the object and also to the group , if specified .
* Adds the feature to the object and also to the group , if specified .
* Otherwise you can use DrawableGroup : : add ( ) .
* Otherwise you can use Basic DrawableGroup: : add ( ) .
*/
*/
explicit Drawable ( AbstractObject < dimensions , T > * object , DrawableGroup < dimensions , T > * drawables = nullptr ) : AbstractGroupedFeature < dimensions , Drawable < dimensions , T > , T > ( object , drawables ) { }
explicit Basic Drawable( AbstractObject < dimensions , T > * object , Basic DrawableGroup< dimensions , T > * drawables = nullptr ) : AbstractGroupedFeature < dimensions , Basic Drawable< dimensions , T > , T > ( object , drawables ) { }
/**
/**
* @ brief Draw the object using given camera
* @ brief Draw the object using given camera
@ -141,40 +136,22 @@ class Drawable: public AbstractGroupedFeature<dimensions, Drawable<dimensions, T
*
*
* Projection matrix can be retrieved from AbstractCamera : : projectionMatrix ( ) .
* Projection matrix can be retrieved from AbstractCamera : : projectionMatrix ( ) .
*/
*/
virtual void draw ( const typename DimensionTraits < dimensions , T > : : MatrixType & transformationMatrix , AbstractCamera < dimensions , T > * camera ) = 0 ;
virtual void draw ( const typename DimensionTraits < dimensions , T > : : MatrixType & transformationMatrix , AbstractBasic Camera < dimensions , T > * camera ) = 0 ;
} ;
} ;
# ifndef CORRADE_GCC46_COMPATIBILITY
/**
/**
@ brief Two - dimensional drawable
@ brief Two - dimensional drawable for float 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 Drawable3D
@ see Drawable3D
*/
*/
# ifdef DOXYGEN_GENERATING_OUTPUT
typedef BasicDrawable < 2 , Float > Drawable2D ;
template < class T = Float >
# else
template < class T >
# endif
using Drawable2D = Drawable < 2 , T > ;
/**
/**
@ brief Three - dimensional drawable
@ brief Three - dimensional drawable for float scenes
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 Drawable2D
@ see Drawable2D
*/
*/
# ifdef DOXYGEN_GENERATING_OUTPUT
typedef BasicDrawable < 3 , Float > Drawable3D ;
template < class T = Float >
# else
template < class T >
# endif
using Drawable3D = Drawable < 3 , T > ;
# endif
/**
/**
@ brief Group of drawables
@ brief Group of drawables
@ -183,52 +160,24 @@ See Drawable for more information.
@ see @ ref scenegraph , DrawableGroup2D , DrawableGroup3D
@ see @ ref scenegraph , DrawableGroup2D , DrawableGroup3D
*/
*/
# ifndef CORRADE_GCC46_COMPATIBILITY
# ifndef CORRADE_GCC46_COMPATIBILITY
# ifdef DOXYGEN_GENERATING_OUTPUT
template < UnsignedInt dimensions , class T > using BasicDrawableGroup = FeatureGroup < dimensions , BasicDrawable < dimensions , T > , T > ;
template < UnsignedInt dimensions , class T = Float >
# else
template < UnsignedInt dimensions , class T >
# endif
using DrawableGroup = FeatureGroup < dimensions , Drawable < dimensions , T > , T > ;
# else
# ifdef DOXYGEN_GENERATING_OUTPUT
template < UnsignedInt dimensions , class T = Float >
# else
# else
template < UnsignedInt dimensions , class T >
template < UnsignedInt dimensions , class T > class BasicDrawableGroup : public FeatureGroup < dimensions , BasicDrawable < dimensions , T > , T > { } ;
# endif
class DrawableGroup : public FeatureGroup < dimensions , Drawable < dimensions , T > , T > { } ;
# endif
# endif
# ifndef CORRADE_GCC46_COMPATIBILITY
/**
/**
@ brief Group of two - dimensional drawables
@ brief Group of two - dimensional drawables for float 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 DrawableGroup3D
@ see DrawableGroup3D
*/
*/
# ifdef DOXYGEN_GENERATING_OUTPUT
typedef BasicDrawableGroup < 2 , Float > DrawableGroup2D ;
template < class T = Float >
# else
template < class T >
# endif
using DrawableGroup2D = DrawableGroup < 2 , T > ;
/**
/**
@ brief Group of three - dimensional drawables
@ brief Group of three - dimensional drawables for float scenes
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 DrawableGroup2D
@ see DrawableGroup2D
*/
*/
# ifdef DOXYGEN_GENERATING_OUTPUT
typedef BasicDrawableGroup < 3 , Float > DrawableGroup3D ;
template < class T = Float >
# else
template < class T >
# endif
using DrawableGroup3D = DrawableGroup < 3 , T > ;
# endif
} }
} }