SceneInfoCollada_impl.h
Go to the documentation of this file.
00001 // -*- coding: utf-8 -*-
00002 // Copyright (C) 2011 University of Tokyo, General Robotix Inc.
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 //     http://www.apache.org/licenses/LICENSE-2.0
00008 // 
00009 // Unless required by applicable law or agreed to in writing, software
00010 // distributed under the License is distributed on an "AS IS" BASIS,
00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 // See the License for the specific language governing permissions and
00013 // limitations under the License.
00021 /*
00022  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00023  * All rights reserved. This program is made available under the terms of the
00024  * Eclipse Public License v1.0 which accompanies this distribution, and is
00025  * available at http://www.eclipse.org/legal/epl-v10.html
00026  * Contributors:
00027  * National Institute of Advanced Industrial Science and Technology (AIST)
00028  */
00029 
00035 #ifndef OPENHRP_MODEL_LOADER_SCENE_INFO_COLLADA_IMPL_H_INCLUDED
00036 #define OPENHRP_MODEL_LOADER_SCENE_INFO_COLLADA_IMPL_H_INCLUDED
00037 
00038 #include <string>
00039 #include <hrpCorba/ModelLoader.hh>
00040 #include <hrpUtil/EasyScanner.h>
00041 
00042 #include "SceneInfo_impl.h"
00043 
00044 using namespace OpenHRP;
00045 
00046 class SceneInfoCollada_impl : public SceneInfo_impl
00047 {
00048 public:
00049     BodyInfoCollada_impl* probot;
00050 
00051     SceneInfoCollada_impl(PortableServer::POA_ptr poa) : ShapeSetInfo_impl(poa), SceneInfo_impl(poa)
00052     {
00053         probot = new BodyInfoCollada_impl(poa);
00054     }
00055     virtual ~SceneInfoCollada_impl()
00056     {
00057     }
00058 
00059     void load(const std::string& filename)
00060     {
00061         try {
00062             probot->loadModelFile(filename);
00063             url_ = CORBA::string_dup(filename.c_str());
00064 
00065             shapes_ = probot->shapes_;
00066             appearances_ = probot->appearances_;
00067             materials_ = probot->materials_;
00068             textures_ = probot->textures_;
00069 
00070             Matrix44 E(Matrix44::Identity());
00071             AllLinkShapeIndexSequence* asis = probot->linkShapeIndices();
00072             size_t linkLength = asis->length();
00073             for(size_t linkIndex = 0; linkIndex < linkLength; ++linkIndex) {
00074                 TransformedShapeIndexSequence tsis = (*asis)[linkIndex];
00075                 for(size_t segmentIndex = 0; segmentIndex < tsis.length(); ++segmentIndex) {
00076                     long length = shapeIndices_.length();
00077                     shapeIndices_.length(length+1);
00078                     TransformedShapeIndex tsi = tsis[segmentIndex];
00079                     shapeIndices_[length] = tsi;
00080 
00081                     const DblArray12& M = tsi.transformMatrix;
00082                     inlinedShapeTransformMatrices_.length(length+1);
00083                     for(int i=0; i<12;i++) {
00084                         inlinedShapeTransformMatrices_[length][i] = M[i];
00085                     }
00086                 }
00087             }
00088         } catch(EasyScanner::Exception& ex){
00089             cout << ex.getFullMessage() << endl;
00090             throw ModelLoader::ModelLoaderException(ex.getFullMessage().c_str());
00091         }
00092     }
00093 };
00094 
00095 
00096 #endif


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19