ColladaLoader.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _COLLADALOADER_HH_
19 #define _COLLADALOADER_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <map>
24 
26 #include "gazebo/math/MathTypes.hh"
27 #include "gazebo/util/system.hh"
28 
29 class TiXmlElement;
30 
31 namespace gazebo
32 {
33  namespace common
34  {
35  class Material;
36  class ColladaLoaderPrivate;
37 
40 
44  {
46  public: ColladaLoader();
47 
49  public: virtual ~ColladaLoader();
50 
54  public: virtual Mesh *Load(const std::string &_filename);
55 
61  private: void LoadController(TiXmlElement *_contrXml,
62  TiXmlElement *_skelXml, const math::Matrix4 &_transform, Mesh *_mesh);
63 
67  private: void LoadAnimations(TiXmlElement *_xml, Skeleton *_skel);
68 
72  private: void LoadAnimationSet(TiXmlElement *_xml, Skeleton *_skel);
73 
77  private: SkeletonNode* LoadSkeletonNodes(TiXmlElement *_xml,
78  SkeletonNode *_parent);
79 
83  private: void SetSkeletonNodeTransform(TiXmlElement *_elem,
84  SkeletonNode *_node);
85 
90  private: void LoadGeometry(TiXmlElement *_xml,
91  const math::Matrix4 &_transform, Mesh *_mesh);
92 
97  private: TiXmlElement *GetElementId(TiXmlElement *_parent,
98  const std::string &_name,
99  const std::string &_id);
100 
104  private: TiXmlElement *GetElementId(const std::string &_name,
105  const std::string &_id);
106 
111  private: void LoadNode(TiXmlElement *_elem, Mesh *_mesh,
112  const math::Matrix4 &_transform);
113 
117  private: math::Matrix4 LoadNodeTransform(TiXmlElement *_elem);
118 
119 
125  private: void LoadVertices(const std::string &_id,
126  const math::Matrix4 &_transform,
127  std::vector<math::Vector3> &_verts,
128  std::vector<math::Vector3> &_norms);
129 
137  private: void LoadVertices(const std::string &_id,
138  const math::Matrix4 &_transform,
139  std::vector<math::Vector3> &_verts,
140  std::vector<math::Vector3> &_norms,
141  std::map<unsigned int, unsigned int> &_vertDup,
142  std::map<unsigned int, unsigned int> &_normDup);
143 
149  private: void LoadPositions(const std::string &_id,
150  const math::Matrix4 &_transform,
151  std::vector<math::Vector3> &_values,
152  std::map<unsigned int, unsigned int> &_duplicates);
153 
159  private: void LoadNormals(const std::string &_id,
160  const math::Matrix4 &_transform,
161  std::vector<math::Vector3> &_values,
162  std::map<unsigned int, unsigned int> &_duplicates);
163 
168  private: void LoadTexCoords(const std::string &_id,
169  std::vector<math::Vector2d> &_values,
170  std::map<unsigned int, unsigned int> &_duplicates);
171 
175  private: Material *LoadMaterial(const std::string &_name);
176 
181  private: void LoadColorOrTexture(TiXmlElement *_elem,
182  const std::string &_type,
183  Material *_mat);
184 
189  private: void LoadTriangles(TiXmlElement *_trianglesXml,
190  const math::Matrix4 &_transform,
191  Mesh *_mesh);
192 
197  private: void LoadPolylist(TiXmlElement *_polylistXml,
198  const math::Matrix4 &_transform,
199  Mesh *_mesh);
200 
205  private: void LoadLines(TiXmlElement *_xml,
206  const math::Matrix4 &_transform,
207  Mesh *_mesh);
208 
211  private: void LoadScene(Mesh *_mesh);
212 
216  private: float LoadFloat(TiXmlElement *_elem);
217 
221  private: void LoadTransparent(TiXmlElement *_elem, Material *_mat);
222 
225  private: ColladaLoaderPrivate *dataPtr;
226  };
228  }
229 }
230 #endif
A 3D mesh.
Definition: Mesh.hh:40
Base class for loading meshes.
Definition: MeshLoader.hh:36
A skeleton.
Definition: Skeleton.hh:50
Encapsulates description of a material.
Definition: common/Material.hh:34
Private data for the ColladaLoader class.
Definition: ColladaLoaderPrivate.hh:34
A 3x3 matrix class.
Definition: Matrix4.hh:39
Class used to load Collada mesh files.
Definition: ColladaLoader.hh:43
A skeleton node.
Definition: Skeleton.hh:170
Forward declarations for the math classes.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48