leaf-node-mesh.h
Go to the documentation of this file.
1 //
2 // leaf-node-mesh.h
3 // gepetto-viewer
4 //
5 // Created by Olivier Stasse, Justin Carpentier, Anthony Couret, Mathieu Geisert in November 2014.
6 // Copyright (c) 2016 LAAS-CNRS. All rights reserved.
7 //
8 
9 #ifndef GEPETTO_VIEWER_LEAFNODEMESH_HH
10 #define GEPETTO_VIEWER_LEAFNODEMESH_HH
11 
12 #include <gepetto/viewer/node.h>
13 #include <osg/PrimitiveSet>
14 #include <osg/Geometry>
15 
16 namespace gepetto {
17 namespace viewer {
18  DEF_CLASS_SMART_PTR(LeafNodeMesh)
19 
20 
21  class LeafNodeMesh : public Node
22  {
23  private:
24 
26  LeafNodeMeshWeakPtr weak_ptr_;
27 
29  osg::GeometryRefPtr mesh_geometry_ptr_;
30 
31  void init();
32 
33  /* Default constructor */
34  LeafNodeMesh(const std::string &name);
35  /* Copy constructor */
36  LeafNodeMesh(const LeafNodeMesh& other);
37  LeafNodeMesh(const std::string &name,const osgVector4 & color);
38 
40  void initWeakPtr (LeafNodeMeshWeakPtr other_weak_ptr);
41 
42 
43  protected:
44  public:
47  static LeafNodeMeshPtr_t create(const std:: string &name);
48  static LeafNodeMeshPtr_t create(const std::string &name, const osgVector4& color);
49 
52  static LeafNodeMeshPtr_t createCopy(LeafNodeMeshPtr_t other);
53 
56  virtual LeafNodeMeshPtr_t clone(void) const;
57 
58 
62  virtual LeafNodeMeshPtr_t copy() const { return clone(); }
63 
66  LeafNodeMeshPtr_t self(void) const;
67 
68  void setColor(const osgVector4& color_diffuse);
69 
70  void setColor(const osgVector4& color_diffuse,
71  const osgVector4& color_specular,
72  const osgVector4& color_emissive);
73 
74  void setTexture(const std::string& image_path);
75 
76  virtual void setAlpha(const float& alpha);
77  virtual osg::ref_ptr<osg::Node> getOsgNode() const;
78 
80 
83  void setVertexArray(osg::Vec3ArrayRefPtr arrayOfVertices);
84 
86  void addPrimitiveSet(osg::DrawElementsUInt * aSetOfColors);
87 
88  void setColorBinding(osg::Geometry::AttributeBinding aColorBinding);
90  void setColorArray(osg::Vec4ArrayRefPtr colors);
91 
93  void setNormalArray(osg::Vec3ArrayRefPtr normals);
94  void setNormalBinding(osg::Geometry::AttributeBinding aNormalBinding);
96  virtual ~LeafNodeMesh();
97 
98  };
99 } /* namespace viewer */
100 } /* namespace gepetto */
101 
102 #endif /* GEPETTO_VIEWER_LEAFNODECOLLADA_HH */
SCENE_VIEWER_ACCEPT_VISITOR
Definition: leaf-node-mesh.h:79
virtual LeafNodeMeshPtr_t copy() const
Proceed to a copy of the currend object as clone.
Definition: leaf-node-mesh.h:62
::osg::Vec4f osgVector4
Definition: config-osg.h:110
Definition: action-search-bar.hh:27
Definition: leaf-node-mesh.h:21
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:50
Abstract base class of 3D objects in a scene.
Definition: node.h:27