SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
CGraphicsChai.hpp
1 /* This file is part of scl, a control and simulation library
2 for robots and biomechanical models.
3 
4 scl is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8 
9 Alternatively, you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 scl is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public
20 License and a copy of the GNU General Public License along with
21 scl. If not, see <http://www.gnu.org/licenses/>.
22 */
23 /* \file CGraphicsChai.hpp
24  *
25  * Created on: Aug 26, 2010
26  *
27  * Copyright (C) 2010
28  *
29  * Author: Samir Menon <smenon@stanford.edu>
30  */
31 #ifndef CGRAPHICSCHAI_HPP_
32 #define CGRAPHICSCHAI_HPP_
33 
34 #include <scl/DataTypes.hpp>
35 #include <scl/data_structs/SRobotParsed.hpp>
36 
37 #include <scl/data_structs/SGraphicsParsed.hpp>
38 #include <scl/graphics/chai/data_structs/SGraphicsChai.hpp>
39 #include <scl/graphics/CGraphicsBase.hpp>
40 
41 #include <string>
42 
43 namespace scl {
44 
49 {
50 public:
51  /********************************************************
52  * Initialization Functions: Sets up a scenegraph, camera
53  * etc..
54  *********************************************************/
63  const SGraphicsParsed* arg_gr_ds)
64  {
65  SGraphicsChai *tmp = new SGraphicsChai();
66  bool flag = initGraphics(arg_gr_ds,tmp);
67  if(flag){ data_is_mine_ = true; }
68  else{ delete tmp; }
69  return flag;
70  }
71 
78  virtual sBool initGraphics(
80  const SGraphicsParsed* arg_gr_ds,
83  SGraphicsChai* arg_chai_ds);
84 
108  virtual sBool addRobotToRender(
110  const SRobotParsed *arg_rob_parsed,
112  const SRobotIO* arg_rob_io);
113 
119  virtual sBool removeRobotFromRender(const std::string& arg_robot);
120 
127  sBool addRobotLink(SGraphicsChaiRigidBody* arg_robot_link);
128 
133  virtual sBool addMeshToRender(const std::string& arg_mesh_name,
134  const std::string& arg_mesh_file, const Eigen::Vector3d& arg_pos,
135  const Eigen::Matrix3d& arg_rot);
136 
143  virtual sBool addMeshToParentInRender(const std::string& arg_mesh_name,
144  const std::string& arg_parent_name,
145  const std::string& arg_mesh_file, const Eigen::Vector3d& arg_pos,
146  const Eigen::Matrix3d& arg_rot);
147 
152  virtual sBool removeMeshFromRender(const std::string& arg_mesh_name);
153 
156  sBool scaleMesh(const std::string& arg_mesh_name,
157  sFloat arg_x, sFloat arg_y, sFloat arg_z);
158 
164  virtual sBool addMusclesToRender(
166  const std::string& arg_robot,
168  const SActuatorSetMuscleParsed& arg_mset,
169  const sBool add_musc_via_points);
170 
179  const std::string& arg_robot,
180  const std::string& arg_mset)
181  { return false; }
182 
185  const std::string& arg_robot,
186  const std::string& arg_link,
187  const Eigen::Vector3d& arg_pos,
188  const sFloat arg_size=0.01,
190  chai3d::cGenericObject** arg_ret_ptr=S_NULL);
191 
194  const Eigen::Vector3d& arg_pos,
196  chai3d::cGenericObject*& arg_ret_ptr,
197  const sFloat arg_size=0.01);
198 
202  const Eigen::Vector3d& arg_pos,
204  chai3d::cGenericObject*& arg_ret_ptr,
205  const sFloat arg_size=0.01);
206 
208  virtual sBool destroyGraphics();
209 
210  /********************************************************
211  * Convenience Functions: Will call other functions to
212  * do the real work
213  *********************************************************/
217  virtual sBool updateGraphics();
218 
222  virtual sBool updateGraphicsForRobots();
223 
230  virtual sBool updateGraphicsForMeshes(){return true;}
231 
236 
238  CGraphicsChai() : CGraphicsBase(),data_(NULL),
239  data_is_mine_(false), data_parsed_(S_NULL){}
240 
242  virtual ~CGraphicsChai(){}
243 
244  SGraphicsChai* getChaiData()
245  { return data_; }
246 
247  const SGraphicsParsed* getParsedData()
248  { return data_parsed_; }
249 
250 protected:
251  SGraphicsChai* data_;
252  bool data_is_mine_;
253  const SGraphicsParsed* data_parsed_;
254 };
255 
256 }
257 
258 #endif /* CGRAPHICS_HPP_ */
virtual sBool addMusclesToRender(const std::string &arg_robot, const SActuatorSetMuscleParsed &arg_mset, const sBool add_musc_via_points)
Definition: CGraphicsChai.cpp:781
Definition: CGraphicsChai.hpp:48
Definition: SRobotIO.hpp:107
sBool scaleMesh(const std::string &arg_mesh_name, sFloat arg_x, sFloat arg_y, sFloat arg_z)
Definition: CGraphicsChai.cpp:751
virtual ~CGraphicsChai()
Definition: CGraphicsChai.hpp:242
Definition: SRobotParsed.hpp:51
CGraphicsChai()
Definition: CGraphicsChai.hpp:238
virtual sBool destroyGraphics()
Definition: CGraphicsChai.cpp:145
virtual sBool updateGraphicsForMuscles()
Definition: CGraphicsChai.cpp:1204
Definition: SGraphicsChai.hpp:74
Definition: SActuatorSetMuscleParsed.hpp:124
sBool addRobotLink(SGraphicsChaiRigidBody *arg_robot_link)
Definition: CGraphicsChai.cpp:326
sBool addBeltedEllipsoidToRender(const Eigen::Vector3d &arg_pos, chai3d::cGenericObject *&arg_ret_ptr, const sFloat arg_size=0.01)
Definition: CGraphicsChai.cpp:1004
virtual sBool addMeshToRender(const std::string &arg_mesh_name, const std::string &arg_mesh_file, const Eigen::Vector3d &arg_pos, const Eigen::Matrix3d &arg_rot)
Definition: CGraphicsChai.cpp:604
bool sBool
Definition: DataTypes.hpp:54
virtual sBool updateGraphicsForMeshes()
Definition: CGraphicsChai.hpp:230
virtual sBool initGraphics(const SGraphicsParsed *arg_gr_ds)
Definition: CGraphicsChai.hpp:61
Definition: CGraphicsBase.hpp:48
virtual sBool addMeshToParentInRender(const std::string &arg_mesh_name, const std::string &arg_parent_name, const std::string &arg_mesh_file, const Eigen::Vector3d &arg_pos, const Eigen::Matrix3d &arg_rot)
Definition: CGraphicsChai.cpp:657
virtual sBool removeRobotFromRender(const std::string &arg_robot)
Definition: CGraphicsChai.cpp:286
virtual sBool removeMusclesFromRender(const std::string &arg_robot, const std::string &arg_mset)
Definition: CGraphicsChai.hpp:178
Definition: SGraphicsParsed.hpp:48
virtual sBool addRobotToRender(const SRobotParsed *arg_rob_parsed, const SRobotIO *arg_rob_io)
Definition: CGraphicsChai.cpp:160
virtual sBool updateGraphics()
Definition: CGraphicsChai.cpp:1037
virtual sBool updateGraphicsForRobots()
Definition: CGraphicsChai.cpp:1071
double sFloat
Definition: DataTypes.hpp:72
Definition: SGraphicsChaiRigidBody.hpp:53
virtual sBool removeMeshFromRender(const std::string &arg_mesh_name)
Definition: CGraphicsChai.cpp:721
sBool addSphereToRender(const std::string &arg_robot, const std::string &arg_link, const Eigen::Vector3d &arg_pos, const sFloat arg_size=0.01, chai3d::cGenericObject **arg_ret_ptr=S_NULL)