libalmath  2.5.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
scenebuilder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Aldebaran. All rights reserved.
3  *
4  */
5 
6 #ifndef LIB_ALMATH_SCENEGRAPH_SCENEBUILDER_H
7 #define LIB_ALMATH_SCENEGRAPH_SCENEBUILDER_H
8 
9 #include <Eigen/Geometry>
10 
11 namespace AL {
12 class Mesh;
13 
14 namespace Math {
15 struct Transform;
16 class Sphere;
17 class RoundedRectangle;
18 class Pill;
19 class Shape3D;
20 }
21 // Interface for a simple Scene builder.
22 //
23 // The scene is indeed simple:
24 //
25 // * all meshes have the same material
26 // * each node binds a single mesh, and a mesh is bound by a single node
27 // * there is no node hierarchy
28 // * there is no texture support (yet?)
29 //
30 //
31 // Possible future developments:
32 //
33 // * add texture support
34 // * add support for external meshes
35 // * add support for debugging markers (arrows, frames, lines, points)
36 // * add ids (and maybe scoped ids) to nodes so that one can target them later
37 // (maybe add an id for individual shapes color)
38 // * add animation support: let one
39 // * move
40 // * change color
41 // * toggle visibility
42 // of stuff at specific time
43 //
44 // One can imagine several implementations of this interface:
45 //
46 // * build the scene in a collada file
47 // * animate a collada scene by dumping collada animations
48 // (though we lack a nice portable collada animation viewer, maybe blender
49 // would fit the bill for specifically created collada files?)
50 // * build the scene in a node of the Ogre scene graph (we do not need to
51 // build the whole Ogre scene)
52 // * animate an ogre scene
53 // * idem with renderwidget?
54 // * write the animation in a ros bag
55 class SceneBuilder {
56  public:
57  class Color {
58  public:
59  Color() : r(0.5f), g(0.5f), b(0.5f), a(0.5f) {}
60  float r, g, b, a;
61  };
62 
63  // a class for configuration which can be used by the SceneBuilder
64  // implementations
65  class Config {
66  public:
69  // the number of intermediate vertices on the are of a rounded box
71  };
72 
73  SceneBuilder(const Config &_config);
74  SceneBuilder(const SceneBuilder &other);
75 
76  virtual ~SceneBuilder();
77 
78  const Config &getConfig() const;
79 
80  void add(const Mesh &mesh, const Eigen::Affine3f &tf);
81  void add(const Mesh &mesh, const Math::Transform &tf);
82  void add(const Math::Sphere &shape, const Math::Transform &tf);
83  void add(const Math::RoundedRectangle &shape, const Math::Transform &tf);
84  void add(const Math::Pill &shape, const Math::Transform &tf);
85 
86  void add(const Math::Shape3D &shape, const Math::Transform &tf);
87 
88  protected:
89  virtual void xAddMesh(const Mesh &mesh, const Eigen::Affine3f &tf) = 0;
90 
91  private:
92  Config _config;
93 };
94 }
95 
96 #endif
const Config & getConfig() const
SceneBuilder(const Config &_config)
Definition: mesh.h:88
A homogenous transformation matrix.
Definition: altransform.h:22
void add(const Mesh &mesh, const Eigen::Affine3f &tf)
virtual ~SceneBuilder()
virtual void xAddMesh(const Mesh &mesh, const Eigen::Affine3f &tf)=0