Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// leaf-node-mesh.h |
3 |
|
|
// gepetto-viewer |
4 |
|
|
// |
5 |
|
|
// Created by Olivier Stasse, Justin Carpentier, Anthony Couret, Mathieu |
6 |
|
|
// Geisert in November 2014. 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 |
|
|
|
14 |
|
|
#include <osg/Geometry> |
15 |
|
|
#include <osg/PrimitiveSet> |
16 |
|
|
|
17 |
|
|
namespace gepetto { |
18 |
|
|
namespace viewer { |
19 |
|
|
DEF_CLASS_SMART_PTR(LeafNodeMesh) |
20 |
|
|
|
21 |
|
|
/** Implementation of the Mesh GraphicalObject in OSG render */ |
22 |
|
|
class LeafNodeMesh : public Node { |
23 |
|
|
private: |
24 |
|
|
/** Associated weak pointer */ |
25 |
|
|
LeafNodeMeshWeakPtr weak_ptr_; |
26 |
|
|
|
27 |
|
|
/** Associated mesh geometry */ |
28 |
|
|
osg::GeometryRefPtr mesh_geometry_ptr_; |
29 |
|
|
|
30 |
|
|
void init(); |
31 |
|
|
|
32 |
|
|
/* Default constructor */ |
33 |
|
|
LeafNodeMesh(const std::string& name); |
34 |
|
|
/* Copy constructor */ |
35 |
|
|
LeafNodeMesh(const LeafNodeMesh& other); |
36 |
|
|
LeafNodeMesh(const std::string& name, const osgVector4& color); |
37 |
|
|
|
38 |
|
|
/** Initialize weak_ptr */ |
39 |
|
|
void initWeakPtr(LeafNodeMeshWeakPtr other_weak_ptr); |
40 |
|
|
|
41 |
|
|
protected: |
42 |
|
|
public: |
43 |
|
|
/** Static method which create a new LeafNodeCollada |
44 |
|
|
*/ |
45 |
|
|
static LeafNodeMeshPtr_t create(const std::string& name); |
46 |
|
|
static LeafNodeMeshPtr_t create(const std::string& name, |
47 |
|
|
const osgVector4& color); |
48 |
|
|
|
49 |
|
|
/** Static method for creating a clone of LeafNodeMesh other |
50 |
|
|
*/ |
51 |
|
|
static LeafNodeMeshPtr_t createCopy(LeafNodeMeshPtr_t other); |
52 |
|
|
|
53 |
|
|
/** Proceed to a clonage of the current object defined by the copy constructor |
54 |
|
|
*/ |
55 |
|
|
virtual LeafNodeMeshPtr_t clone(void) const; |
56 |
|
|
|
57 |
|
|
/** Copy |
58 |
|
|
\brief Proceed to a copy of the currend object as clone |
59 |
|
|
*/ |
60 |
|
✗ |
virtual LeafNodeMeshPtr_t copy() const { return clone(); } |
61 |
|
|
|
62 |
|
|
/** Return a shared pointer of the current object |
63 |
|
|
*/ |
64 |
|
|
LeafNodeMeshPtr_t self(void) const; |
65 |
|
|
|
66 |
|
|
void setColor(const osgVector4& color_diffuse); |
67 |
|
|
|
68 |
|
|
void setColor(const osgVector4& color_diffuse, |
69 |
|
|
const osgVector4& color_specular, |
70 |
|
|
const osgVector4& color_emissive); |
71 |
|
|
|
72 |
|
|
void setTexture(const std::string& image_path); |
73 |
|
|
|
74 |
|
|
virtual void setAlpha(const float& alpha); |
75 |
|
|
virtual osg::ref_ptr<osg::Node> getOsgNode() const; |
76 |
|
|
|
77 |
|
✗ |
SCENE_VIEWER_ACCEPT_VISITOR; |
78 |
|
|
|
79 |
|
|
/** Add geometric data */ |
80 |
|
|
/** Set the vertices of the mesh */ |
81 |
|
|
void setVertexArray(osg::Vec3ArrayRefPtr arrayOfVertices); |
82 |
|
|
|
83 |
|
|
/** Add a primitive set to the mesh */ |
84 |
|
|
void addPrimitiveSet(osg::DrawElementsUInt* aSetOfColors); |
85 |
|
|
|
86 |
|
|
void setColorBinding(osg::Geometry::AttributeBinding aColorBinding); |
87 |
|
|
/** Add colors */ |
88 |
|
|
void setColorArray(osg::Vec4ArrayRefPtr colors); |
89 |
|
|
|
90 |
|
|
/** Add normals */ |
91 |
|
|
void setNormalArray(osg::Vec3ArrayRefPtr normals); |
92 |
|
|
void setNormalBinding(osg::Geometry::AttributeBinding aNormalBinding); |
93 |
|
|
/** Destructor */ |
94 |
|
|
virtual ~LeafNodeMesh(); |
95 |
|
|
}; |
96 |
|
|
} /* namespace viewer */ |
97 |
|
|
} /* namespace gepetto */ |
98 |
|
|
|
99 |
|
|
#endif /* GEPETTO_VIEWER_LEAFNODECOLLADA_HH */ |
100 |
|
|
|