ColladaLoader.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 00018 #ifndef COLLADALOADER_HH 00019 #define COLLADALOADER_HH 00020 00021 #include "common/MeshLoader.hh" 00022 #include "math/MathTypes.hh" 00023 00024 class TiXmlElement; 00025 00026 namespace gazebo 00027 { 00028 namespace common 00029 { 00030 class Material; 00031 00034 00036 class ColladaLoader : public MeshLoader 00037 { 00039 public: ColladaLoader(); 00040 00042 public: virtual ~ColladaLoader(); 00043 00045 public: virtual Mesh *Load( const std::string &filename ); 00046 00047 private: void LoadGeometry(TiXmlElement *_xml, 00048 const math::Matrix4 &_transform, Mesh *_mesh); 00049 private: TiXmlElement *GetElementId(TiXmlElement *_parent, 00050 const std::string &_name, 00051 const std::string &_id); 00052 private: TiXmlElement *GetElementId( const std::string &_name, 00053 const std::string &_id); 00054 00055 private: void LoadNode(TiXmlElement *_elem, Mesh *_mesh, 00056 const math::Matrix4 &_transform); 00057 00058 private: math::Matrix4 LoadNodeTransform(TiXmlElement *_elem); 00059 00060 private: void LoadVertices(const std::string &_id, 00061 const math::Matrix4 &_transform, 00062 std::vector<math::Vector3> &_verts, 00063 std::vector<math::Vector3> &_norms); 00064 private: void LoadPositions(const std::string &_id, 00065 const math::Matrix4 &_transform, 00066 std::vector<math::Vector3> &_values); 00067 00068 private: void LoadNormals(const std::string &_id, 00069 const math::Matrix4 &_transform, 00070 std::vector<math::Vector3> &_values); 00071 private: void LoadTexCoords(const std::string &_id, 00072 std::vector<math::Vector2d> &_values); 00073 00074 private: Material *LoadMaterial(const std::string &_name); 00075 00076 private: void LoadColorOrTexture(TiXmlElement *_elem, 00077 const std::string &_type, 00078 Material *_mat); 00079 00080 private: void LoadTriangles( TiXmlElement *_trianglesXml, 00081 const math::Matrix4 &_transform, 00082 Mesh *_mesh); 00083 00084 private: void LoadLines( TiXmlElement *_xml, 00085 const math::Matrix4 &_transform, 00086 Mesh *_mesh); 00087 00088 private: void LoadScene( Mesh *_mesh ); 00089 00090 private: float LoadFloat(TiXmlElement *_elem); 00091 private: void LoadTransparent( TiXmlElement *_elem, Material *_mat ); 00092 00093 private: double meter; 00094 private: std::map<std::string, std::string> materialMap; 00095 00096 private: TiXmlElement *colladaXml; 00097 private: std::string path; 00098 }; 00099 } 00100 } 00101 00102 #endif

1.7.5.1