Choreonoid  1.8
SceneBody.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BODY_SCENE_BODY_H
6 #define CNOID_BODY_SCENE_BODY_H
7 
8 #include "Body.h"
9 #include "SceneDevice.h"
10 #include <cnoid/SceneGraph>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class SceneBody;
16 class SceneLinkImpl;
17 
18 class CNOID_EXPORT SceneLink : public SgPosTransform
19 {
20 public:
21  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22 
23  SceneLink(SceneBody* sceneBody, Link* link);
24  SceneLink(const SceneLink& org) = delete;
25  ~SceneLink();
26 
27  SceneBody* sceneBody(){ return sceneBody_; }
28  const SceneBody* sceneBody() const { return sceneBody_; }
29 
30  Link* link() { return link_; }
31  const Link* link() const { return link_; }
32 
33  const SgNode* visualShape() const;
34  SgNode* visualShape();
35  const SgNode* collisionShape() const;
36  SgNode* collisionShape();
37 
38  void insertEffectGroup(SgGroup* effect, SgUpdateRef update = SgUpdateRef());
39  void removeEffectGroup(SgGroup* effect, SgUpdateRef update = SgUpdateRef());
40 
41  void setVisible(bool on);
42  float transparency() const;
43  void setTransparency(float transparency, SgUpdateRef update = SgUpdateRef());
45  void makeTransparent(float transparency);
46 
47  void addSceneDevice(SceneDevice* sdev);
48  SceneDevice* getSceneDevice(Device* device);
49 
50 private:
51  Link* link_;
52  SceneLinkImpl* impl;
53  SceneBody* sceneBody_;
54  friend class SceneBody;
55 };
56 
58 
59 class SceneBodyImpl;
60 
61 class CNOID_EXPORT SceneBody : public SgPosTransform
62 {
63 public:
64  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65 
66  SceneBody();
67  SceneBody(Body* body);
68  SceneBody(const SceneBody& org) = delete;
69  virtual ~SceneBody();
70 
71  Body* body() { return body_; }
72  const Body* body() const { return body_; }
73 
74  void cloneShapes(CloneMap& cloneMap);
75 
76  int numSceneLinks() const { return sceneLinks_.size(); }
77  SceneLink* sceneLink(int index) { return sceneLinks_[index]; }
78  const SceneLink* sceneLink(int index) const { return sceneLinks_[index]; }
79 
80  void updateLinkPositions();
81  void updateLinkPositions(SgUpdate& update);
82 
83  SceneDevice* getSceneDevice(Device* device);
84  void setSceneDeviceUpdateConnection(bool on);
85  void updateSceneDevices(double time);
86 
87  void setTransparency(float transparency);
88 
90  void makeTransparent(float transparency);
92  void makeTransparent(float transparency, CloneMap& cloneMap);
93 
94  void insertEffectGroup(SgGroup* effect, SgUpdateRef update = SgUpdateRef());
95  void removeEffectGroup(SgGroup* effect, SgUpdateRef update = SgUpdateRef());
96 
97  virtual void updateModel();
98 
99 protected:
100  void setBody(Body* body, std::function<SceneLink*(Link*)> sceneLinkFactory);
101 
102 private:
103  BodyPtr body_;
104  std::vector<SceneLinkPtr> sceneLinks_;
105  SceneBodyImpl* impl;
106 
107  friend class SceneLink;
108 };
109 
111 
112 }
113 
114 #endif
cnoid::SgPosTransform
Definition: SceneGraph.h:357
cnoid::SceneBody::sceneLink
SceneLink * sceneLink(int index)
Definition: SceneBody.h:77
cnoid::SgGroup
Definition: SceneGraph.h:220
cnoid::SceneBodyPtr
ref_ptr< SceneBody > SceneBodyPtr
Definition: SceneBody.h:110
cnoid::SgUpdate
Definition: SceneUpdate.h:10
cnoid::SgUpdateRef
Definition: SceneUpdate.h:73
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid::makeTransparent
CNOID_EXPORT int makeTransparent(SgNode *topNode, float transparency, CloneMap &cloneMap, bool doKeepOrgTransparency=true)
Definition: SceneUtil.cpp:154
SceneDevice.h
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::SceneBody::body
Body * body()
Definition: SceneBody.h:71
cnoid::SceneBody::numSceneLinks
int numSceneLinks() const
Definition: SceneBody.h:76
cnoid::SceneBody
Definition: SceneBody.h:61
Body.h
cnoid::SceneLinkPtr
ref_ptr< SceneLink > SceneLinkPtr
Definition: SceneBody.h:57
cnoid::Body
Definition: Body.h:28
cnoid::Device
Definition: Device.h:53
cnoid::SceneBody::body
const Body * body() const
Definition: SceneBody.h:72
cnoid::SceneBody::sceneLink
const SceneLink * sceneLink(int index) const
Definition: SceneBody.h:78
cnoid::SgNode
Definition: SceneGraph.h:157
cnoid::SceneDevice
Definition: SceneDevice.h:20