Choreonoid  1.8
SceneEffects.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_UTIL_SCENE_EFFECTS_H
7 #define CNOID_UTIL_SCENE_EFFECTS_H
8 
9 #include "SceneGraph.h"
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class CNOID_EXPORT SgPolygonDrawStyle : public SgGroup
15 {
16 public:
18  SgPolygonDrawStyle(const SgPolygonDrawStyle& org, CloneMap* cloneMap = nullptr);
19 
21  Face = 1,
22  Edge = 2,
23  Vertex = 4
24  };
25  void setPolygonElements(int elementFlags) { polygonElements_ = elementFlags; };
26  int polygonElements() const { return polygonElements_; }
27  const Vector4f& edgeColor() const { return edgeColor_; }
28  void setEdgeColor(const Vector4f& c) { edgeColor_ = c; }
29  float edgeWidth() const { return edgeWidth_; }
30  void setEdgeWidth(float w) { edgeWidth_ = w; }
31  const Vector4f& vertexColor() const { return vertexColor_; }
32  void setVertexColor(const Vector4f& c) { vertexColor_ = c; }
33  float vertexSize() const { return vertexSize_; }
34  void setVertexSize(float s) { vertexSize_ = s; }
35 
36 protected:
37  virtual Referenced* doClone(CloneMap* cloneMap) const override;
38 
39 private:
40  int polygonElements_;
41  Vector4f edgeColor_;
42  float edgeWidth_;
43  Vector4f vertexColor_;
44  float vertexSize_;
45 };
46 
48 
49 
50 class CNOID_EXPORT SgTransparentGroup : public SgGroup
51 {
52 public:
54  SgTransparentGroup(const SgTransparentGroup& org, CloneMap* cloneMap = nullptr);
55 
56  float transparency() const { return transparency_; }
57  void setTransparency(float t) { transparency_ = t; }
58 
59 protected:
60  virtual Referenced* doClone(CloneMap* cloneMap) const override;
61 
62 private:
63  float transparency_;
64 };
65 
67 
68 
69 class CNOID_EXPORT SgFog : public SgPreprocessed
70 {
71 protected:
72  SgFog(int polymorhicId);
73 
74 public:
75  SgFog();
76  SgFog(const SgFog& org);
77 
78  const Vector3f& color() const { return color_; }
79  template<typename Derived> void setColor(const Eigen::MatrixBase<Derived>& c) {
80  color_ = c.template cast<Vector3f::Scalar>(); }
81  void setVisibilityRange(float r) { visibilityRange_ = r; }
82  float visibilityRange() const { return visibilityRange_; }
83 
84 protected:
85  virtual Referenced* doClone(CloneMap* cloneMap) const override;
86 
87 private:
88  Vector3f color_;
89  float visibilityRange_;
90  //int fogType;
91 };
92 
94 
95 
96 class CNOID_EXPORT SgHighlight : public SgGroup
97 {
98 protected:
99  SgHighlight(int polymorhicId);
100  SgHighlight(const SgHighlight& org);
101 
102 public:
103  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
104 
105  SgHighlight() = delete;
106 
107  virtual const Vector3f& color() const = 0;
108  virtual void setColor(const Vector3f& color) = 0;
109  virtual float lineWidth() const = 0;
110  virtual void setLineWidth(float width) = 0;
111 };
112 
114 
115 
116 class CNOID_EXPORT SgBoundingBox : public SgHighlight
117 {
118 public:
119  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
120 
121  SgBoundingBox();
122  SgBoundingBox(const SgBoundingBox& org);
123  ~SgBoundingBox();
124 
125  virtual const Vector3f& color() const override;
126  virtual void setColor(const Vector3f& color) override;
127  virtual float lineWidth() const override;
128  virtual void setLineWidth(float width) override;
129 
130  const SgLineSet* lineSet() const { return lineSet_; }
131  void updateLineSet(SgUpdateRef update = nullptr);
132 
133  virtual int numChildObjects() const override;
134  virtual SgObject* childObject(int index) override;
135 
136 protected:
137  virtual Referenced* doClone(CloneMap* cloneMap) const override;
138 
139 private:
140  ref_ptr<SgLineSet> lineSet_;
141  BoundingBox lastBoundingBox;
142 
143  void initializeLineSet();
144 };
145 
147 
148 
149 class CNOID_EXPORT SgOutline : public SgHighlight
150 {
151 public:
152  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
153 
154  SgOutline();
155  SgOutline(const SgOutline& org);
156 
157  virtual const Vector3f& color() const override;
158  virtual void setColor(const Vector3f& color) override;
159  virtual float lineWidth() const override;
160  virtual void setLineWidth(float width) override;
161 
162 protected:
163  virtual Referenced* doClone(CloneMap* cloneMap) const override;
164 
165 private:
166  Vector3f color_;
167  float lineWidth_;
168 };
169 
171 
172 
173 class CNOID_EXPORT SgLightweightRenderingGroup : public SgGroup
174 {
175 public:
177 
178 protected:
179  virtual Referenced* doClone(CloneMap* cloneMap) const override;
180 };
181 
183 
184 }
185 
186 #endif
cnoid::SgPolygonDrawStyle::edgeColor
const Vector4f & edgeColor() const
Definition: SceneEffects.h:27
cnoid::SgBoundingBox
Definition: SceneEffects.h:116
cnoid::SgGroup
Definition: SceneGraph.h:220
cnoid::SgLineSet
Definition: SceneDrawables.h:660
cnoid::SgPreprocessed
Definition: SceneGraph.h:595
cnoid::SgFogPtr
ref_ptr< SgFog > SgFogPtr
Definition: SceneEffects.h:93
cnoid::SgTransparentGroupPtr
ref_ptr< SgTransparentGroup > SgTransparentGroupPtr
Definition: SceneEffects.h:66
cnoid::SgUpdateRef
Definition: SceneUpdate.h:73
cnoid::SgPolygonDrawStyle::setVertexColor
void setVertexColor(const Vector4f &c)
Definition: SceneEffects.h:32
cnoid::SgFog::visibilityRange
float visibilityRange() const
Definition: SceneEffects.h:82
cnoid::SgFog::setVisibilityRange
void setVisibilityRange(float r)
Definition: SceneEffects.h:81
cnoid::ref_ptr< SgPolygonDrawStyle >
cnoid::SgPolygonDrawStyle
Definition: SceneEffects.h:14
cnoid::SgPolygonDrawStyle::setPolygonElements
void setPolygonElements(int elementFlags)
Definition: SceneEffects.h:25
cnoid::SgPolygonDrawStyle::vertexSize
float vertexSize() const
Definition: SceneEffects.h:33
cnoid::SgPolygonDrawStyle::edgeWidth
float edgeWidth() const
Definition: SceneEffects.h:29
cnoid::SgFog::setColor
void setColor(const Eigen::MatrixBase< Derived > &c)
Definition: SceneEffects.h:79
cnoid::SgPolygonDrawStyle::PolygonElement
PolygonElement
Definition: SceneEffects.h:20
cnoid::SgTransparentGroup
Definition: SceneEffects.h:50
cnoid::SgOutline
Definition: SceneEffects.h:149
cnoid::SgFog
Definition: SceneEffects.h:69
cnoid::SgPolygonDrawStyle::setVertexSize
void setVertexSize(float s)
Definition: SceneEffects.h:34
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::SgPolygonDrawStyle::setEdgeColor
void setEdgeColor(const Vector4f &c)
Definition: SceneEffects.h:28
cnoid::SgPolygonDrawStyle::polygonElements
int polygonElements() const
Definition: SceneEffects.h:26
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::SgLightweightRenderingGroupPtr
ref_ptr< SgLightweightRenderingGroup > SgLightweightRenderingGroupPtr
Definition: SceneEffects.h:182
cnoid::SgLightweightRenderingGroup
Definition: SceneEffects.h:173
cnoid::SgFog::color
const Vector3f & color() const
Definition: SceneEffects.h:78
cnoid::SgTransparentGroup::transparency
float transparency() const
Definition: SceneEffects.h:56
cnoid::SgBoundingBox::lineSet
const SgLineSet * lineSet() const
Definition: SceneEffects.h:130
cnoid::SgOutlinePtr
ref_ptr< SgOutline > SgOutlinePtr
Definition: SceneEffects.h:170
cnoid::Referenced
Definition: Referenced.h:54
cnoid::SgPolygonDrawStyle::vertexColor
const Vector4f & vertexColor() const
Definition: SceneEffects.h:31
SceneGraph.h
cnoid::SgHighlightPtr
ref_ptr< SgHighlight > SgHighlightPtr
Definition: SceneEffects.h:113
cnoid::SgHighlight
Definition: SceneEffects.h:96
cnoid::SgPolygonDrawStyle::setEdgeWidth
void setEdgeWidth(float w)
Definition: SceneEffects.h:30
cnoid::SgObject
Definition: SceneGraph.h:28
cnoid::SgTransparentGroup::setTransparency
void setTransparency(float t)
Definition: SceneEffects.h:57
cnoid::SgPolygonDrawStylePtr
ref_ptr< SgPolygonDrawStyle > SgPolygonDrawStylePtr
Definition: SceneEffects.h:47
cnoid::BoundingBox
Definition: BoundingBox.h:17
cnoid::SgBoundingBoxPtr
ref_ptr< SgBoundingBox > SgBoundingBoxPtr
Definition: SceneEffects.h:146