Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef REALTIME_PERCEPTION_RENDERABLE_H_
00032 #define REALTIME_PERCEPTION_RENDERABLE_H_
00033
00034 #include <GL3/gl3.h>
00035 #include <tf/tf.h>
00036
00037
00038 #include <urdf_interface/color.h>
00039
00040 #include <assimp/aiScene.h>
00041
00042
00043 struct aiScene;
00044 struct aiMesh;
00045
00046 namespace realtime_urdf_filter
00047 {
00048
00049 struct Renderable
00050 {
00051 void setLinkName (std::string n);
00052 virtual void render () = 0;
00053 std::string name;
00054
00055
00056
00057
00058
00059
00060 tf::Transform link_offset;
00061 tf::Transform link_to_fixed;
00062 tf::Transform fixed_to_target;
00063
00064 urdf::Color color;
00065 void applyTransform ();
00066 void unapplyTransform ();
00067 };
00068
00069 struct RenderableBox : public Renderable
00070 {
00071 RenderableBox (float dimx, float dimy, float dimz);
00072
00073 virtual void render ();
00074
00075 float dimx, dimy, dimz;
00076 protected:
00077 void createBoxVBO ();
00078 GLuint vbo;
00079 };
00080
00081 struct RenderableSphere : public Renderable
00082 {
00083 RenderableSphere (float radius);
00084
00085 virtual void render ();
00086
00087 float radius;
00088 };
00089
00090 struct RenderableCylinder : public Renderable
00091 {
00092 RenderableCylinder (float radius, float length);
00093
00094 virtual void render ();
00095
00096 float radius;
00097 float length;
00098 };
00099
00100
00101 struct RenderableMesh : public Renderable
00102 {
00103 RenderableMesh (std::string meshname);
00104
00105 virtual void render ();
00106 void setScale (float x, float y, float z);
00107
00108 private:
00109 struct Vertex
00110 {
00111 float x,y,z;
00112 float nx,ny,nz;
00113 Vertex (float x, float y, float z, float nx, float ny, float nz)
00114 : x(x), y(y), z(z), nx(nx), ny(ny), nz(nz)
00115 {}
00116 };
00117
00118 struct SubMesh
00119 {
00120 enum {INVALID_VALUE = 0xFFFFFFFF};
00121 SubMesh ();
00122 ~SubMesh ();
00123 void init (const std::vector<Vertex>& vertices,
00124 const std::vector<unsigned int>& indices);
00125 GLuint vbo, ibo;
00126 unsigned int num_indices;
00127 };
00128
00129 void fromAssimpScene (const aiScene* scene);
00130 void initMesh (unsigned int i, const aiMesh* mesh, const aiNode* node);
00131
00132 std::vector<SubMesh> meshes;
00133 double scale_x;
00134 double scale_y;
00135 double scale_z;
00136
00137 std::string meshname_;
00138 };
00139
00140
00141
00142 }
00143
00144 #endif
00145