##

ColladaLoader.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_COLLADALOADER_HH_
#define _GAZEBO_COLLADALOADER_HH_
#include <string>
#include <vector>
#include <map>
#include <ignition/math/Matrix4.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/common/MeshLoader.hh"
#include "gazebo/util/system.hh"
class TiXmlElement;
namespace gazebo
{
namespace common
{
class Material;
class ColladaLoaderPrivate;
class GZ_COMMON_VISIBLE ColladaLoader : public MeshLoader
{
public: ColladaLoader();
public: virtual ~ColladaLoader();
public: virtual Mesh *Load(const std::string &_filename);
private: void LoadController(TiXmlElement *_contrXml,
const std::vector<TiXmlElement*> &rootNodeXmls,
const ignition::math::Matrix4d &_transform, Mesh *_mesh);
private: void LoadAnimations(TiXmlElement *_xml, Skeleton *_skel);
private: void LoadAnimationSet(TiXmlElement *_xml, Skeleton *_skel);
private: SkeletonNode* LoadSingleSkeletonNode(TiXmlElement *_xml,
SkeletonNode *_parent);
private: SkeletonNode* LoadSkeletonNodes(TiXmlElement *_xml,
SkeletonNode *_parent);
private: void SetSkeletonNodeTransform(TiXmlElement *_elem,
SkeletonNode *_node);
private: void LoadGeometry(TiXmlElement *_xml,
const ignition::math::Matrix4d &_transform, Mesh *_mesh);
private: TiXmlElement *GetElementId(TiXmlElement *_parent,
const std::string &_name,
const std::string &_id);
private: TiXmlElement *GetElementId(const std::string &_name,
const std::string &_id);
private: void LoadNode(TiXmlElement *_elem, Mesh *_mesh,
const ignition::math::Matrix4d &_transform);
private: ignition::math::Matrix4d LoadNodeTransform(TiXmlElement *_elem);
private: void LoadVertices(const std::string &_id,
const ignition::math::Matrix4d &_transform,
std::vector<ignition::math::Vector3d> &_verts,
std::vector<ignition::math::Vector3d> &_norms);
private: void LoadVertices(const std::string &_id,
const ignition::math::Matrix4d &_transform,
std::vector<ignition::math::Vector3d> &_verts,
std::vector<ignition::math::Vector3d> &_norms,
std::map<unsigned int, unsigned int> &_vertDup,
std::map<unsigned int, unsigned int> &_normDup);
private: void LoadPositions(const std::string &_id,
const ignition::math::Matrix4d &_transform,
std::vector<ignition::math::Vector3d> &_values,
std::map<unsigned int, unsigned int> &_duplicates);
private: void LoadNormals(const std::string &_id,
const ignition::math::Matrix4d &_transform,
std::vector<ignition::math::Vector3d> &_values,
std::map<unsigned int, unsigned int> &_duplicates);
private: void LoadTexCoords(const std::string &_id,
std::vector<ignition::math::Vector2d> &_values,
std::map<unsigned int, unsigned int> &_duplicates);
private: Material *LoadMaterial(const std::string &_name);
private: void LoadColorOrTexture(TiXmlElement *_elem,
const std::string &_type,
Material *_mat);
private: void LoadTriangles(TiXmlElement *_trianglesXml,
const ignition::math::Matrix4d &_transform,
Mesh *_mesh);
private: void LoadPolylist(TiXmlElement *_polylistXml,
const ignition::math::Matrix4d &_transform,
Mesh *_mesh);
private: void LoadLines(TiXmlElement *_xml,
const ignition::math::Matrix4d &_transform,
Mesh *_mesh);
private: void LoadScene(Mesh *_mesh);
private: float LoadFloat(TiXmlElement *_elem);
private: void LoadTransparent(TiXmlElement *_elem, Material *_mat);
private: void MergeSkeleton(Skeleton *_skeleton,
SkeletonNode *_mergeNode);
private: void ApplyInvBindTransform(Skeleton *_skeleton);
private: ColladaLoaderPrivate *dataPtr;
};
}
}
#endif
gazebo::common::ColladaLoader::ColladaLoader
ColladaLoader()
Constructor.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::ColladaLoader::~ColladaLoader
virtual ~ColladaLoader()
Destructor.
system.hh
gazebo::common::ColladaLoader::Load
virtual Mesh * Load(const std::string &_filename)
Load a mesh.
gazebo::common::Skeleton
A skeleton.
Definition: Skeleton.hh:52
gazebo::common::Material
Encapsulates description of a material.
Definition: common/Material.hh:35
gazebo::common::ColladaLoader
Class used to load Collada mesh files.
Definition: ColladaLoader.hh:46
gazebo::common::MeshLoader
Base class for loading meshes.
Definition: MeshLoader.hh:36
gazebo::common::Mesh
A 3D mesh.
Definition: Mesh.hh:42
gazebo::common::SkeletonNode
A skeleton node.
Definition: Skeleton.hh:179
MeshLoader.hh