SceneInfoCollada_impl.h
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2011 University of Tokyo, General Robotix Inc.
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 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
21 /*
22  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
23  * All rights reserved. This program is made available under the terms of the
24  * Eclipse Public License v1.0 which accompanies this distribution, and is
25  * available at http://www.eclipse.org/legal/epl-v10.html
26  * Contributors:
27  * National Institute of Advanced Industrial Science and Technology (AIST)
28  */
29 
35 #ifndef OPENHRP_MODEL_LOADER_SCENE_INFO_COLLADA_IMPL_H_INCLUDED
36 #define OPENHRP_MODEL_LOADER_SCENE_INFO_COLLADA_IMPL_H_INCLUDED
37 
38 #include <string>
39 #include <hrpCorba/ModelLoader.hh>
40 #include <hrpUtil/EasyScanner.h>
41 
42 #include "SceneInfo_impl.h"
43 
44 using namespace OpenHRP;
45 
47 {
48 public:
50 
51  SceneInfoCollada_impl(PortableServer::POA_ptr poa) : ShapeSetInfo_impl(poa), SceneInfo_impl(poa)
52  {
53  probot = new BodyInfoCollada_impl(poa);
54  }
56  {
57  }
58 
59  void load(const std::string& filename)
60  {
61  try {
62  probot->loadModelFile(filename);
63  url_ = CORBA::string_dup(filename.c_str());
64 
65  shapes_ = probot->shapes_;
66  appearances_ = probot->appearances_;
67  materials_ = probot->materials_;
68  textures_ = probot->textures_;
69 
70  Matrix44 E(Matrix44::Identity());
71  AllLinkShapeIndexSequence* asis = probot->linkShapeIndices();
72  size_t linkLength = asis->length();
73  for(size_t linkIndex = 0; linkIndex < linkLength; ++linkIndex) {
74  TransformedShapeIndexSequence tsis = (*asis)[linkIndex];
75  for(size_t segmentIndex = 0; segmentIndex < tsis.length(); ++segmentIndex) {
76  long length = shapeIndices_.length();
77  shapeIndices_.length(length+1);
78  TransformedShapeIndex tsi = tsis[segmentIndex];
79  shapeIndices_[length] = tsi;
80 
81  const DblArray12& M = tsi.transformMatrix;
82  inlinedShapeTransformMatrices_.length(length+1);
83  for(int i=0; i<12;i++) {
84  inlinedShapeTransformMatrices_[length][i] = M[i];
85  }
86  }
87  }
88  } catch(EasyScanner::Exception& ex){
89  cout << ex.getFullMessage() << endl;
90  throw ModelLoader::ModelLoaderException(ex.getFullMessage().c_str());
91  }
92  }
93 };
94 
95 
96 #endif
virtual AllLinkShapeIndexSequence * linkShapeIndices()
SceneInfoCollada_impl(PortableServer::POA_ptr poa)
char * filename
Definition: cdjpeg.h:133
png_bytep png_bytep png_size_t length
Definition: png.h:1541
png_uint_32 i
Definition: png.h:2735
Eigen::Matrix4d Matrix44
Definition: Eigen4d.h:18
reads in collada files and initializes a BodyInfo struct
void loadModelFile(const std::string &filename)
BodyInfoCollada_impl * probot
void load(const std::string &filename)
The header file of a text scanner class.


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05