18 #include <sys/types.h>
25 #ifdef OPENHRP_COLLADA_FOUND
26 #include <boost/foreach.hpp>
31 static bool IsColladaFile(
const std::string&
filename)
49 std::string path = url;
50 if ( path.find(
"$(PROJECT_DIR)") != std::string::npos ) {
51 std::string shdir = OPENHRP_SHARE_DIR;
52 std::string pjdir = shdir +
"/sample/project";
53 path.replace(path.find(
"$(PROJECT_DIR)"),14, pjdir);
60 orb(CORBA::ORB::_duplicate(orb)),
61 poa(PortableServer::POA::_duplicate(poa))
75 return PortableServer::POA::_duplicate(
poa);
82 if( !!pBodyInfo_impl ) {
86 #ifdef OPENHRP_COLLADA_FOUND
88 if( !!pBodyInfoCollada_impl ) {
93 throw ModelLoader::ModelLoaderException(
"setLastUpdateTime invalid pointer");
98 if( !!pBodyInfo_impl ) {
101 #ifdef OPENHRP_COLLADA_FOUND
103 if( !!pBodyInfoCollada_impl ) {
107 throw ModelLoader::ModelLoaderException(
"getLastUpdateTime invalid pointer");
113 if( !!pBodyInfo_impl ) {
116 #ifdef OPENHRP_COLLADA_FOUND
118 if( !!pBodyInfoCollada_impl ) {
122 throw ModelLoader::ModelLoaderException(
"checkInlineFileUpdateTime invalid pointer");
125 static void setParam(POA_OpenHRP::BodyInfo* bodyInfo, std::string param,
int value)
128 if( !!pBodyInfo_impl ) {
132 #ifdef OPENHRP_COLLADA_FOUND
134 if( !!pBodyInfoCollada_impl ) {
139 throw ModelLoader::ModelLoaderException(
"setParam(param,value) invalid pointer");
145 if( !!pBodyInfo_impl ) {
149 #ifdef OPENHRP_COLLADA_FOUND
151 if( !!pBodyInfoCollada_impl ) {
156 throw ModelLoader::ModelLoaderException(
"changetoBoundingBox(depth) invalid pointer");
160 throw (CORBA::SystemException, OpenHRP::ModelLoader::ModelLoaderException)
162 OpenHRP::ModelLoader::ModelLoadOption
option;
164 option.AABBdata.length(0);
165 option.AABBtype = OpenHRP::ModelLoader::AABB_NUM;
167 return bodyInfo->_this();
171 throw (CORBA::SystemException, OpenHRP::ModelLoader::ModelLoaderException)
174 if(
option.AABBdata.length()){
177 unsigned int* _AABBdata =
new unsigned int[
length];
183 return bodyInfo->_this();
187 throw (CORBA::SystemException, OpenHRP::ModelLoader::ModelLoaderException)
191 BodyInfo_ptr bodyInfo = 0;
193 struct stat statbuff;
197 if( stat(
filename.c_str(), &statbuff ) == 0 ){
198 mtime = statbuff.st_mtime;
201 UrlToBodyInfoMap::iterator p = urlToBodyInfoMap.find(url);
203 bodyInfo = p->second->_this();
204 cout << string(
"cache found for ") + url << endl;
205 if(
option.AABBdata.length()){
208 unsigned int* _AABBdata =
new unsigned int[
length];
216 return loadBodyInfoEx(url0,
option);
220 throw (CORBA::SystemException, OpenHRP::ModelLoader::ModelLoaderException)
222 OpenHRP::ModelLoader::ModelLoadOption
option;
224 option.AABBdata.length(0);
225 option.AABBtype = OpenHRP::ModelLoader::AABB_NUM;
226 return getBodyInfoEx(url,
option);
231 cout <<
"loading " << url << endl;
232 POA_OpenHRP::BodyInfo* bodyInfo;
234 #ifdef OPENHRP_COLLADA_FOUND
235 if( IsColladaFile(url) ) {
250 catch(OpenHRP::ModelLoader::ModelLoaderException& ex){
251 cout <<
"loading failed.\n";
252 cout << ex.description << endl;
257 cout <<
"The model was successfully loaded ! " << endl;
259 #ifdef OPENHRP_COLLADA_FOUND
270 struct stat statbuff;
274 if( stat(
filename.c_str(), &statbuff ) == 0 ){
275 mtime = statbuff.st_mtime;
285 throw (CORBA::SystemException, OpenHRP::ModelLoader::ModelLoaderException)
287 cout <<
"loading " << url << endl;
291 #ifdef OPENHRP_COLLADA_FOUND
292 if( IsColladaFile(url) ) {
305 catch(OpenHRP::ModelLoader::ModelLoaderException& ex){
306 cout <<
"loading failed.\n";
307 cout << ex.description << endl;
311 cout << url <<
" was successfully loaded ! " << endl;
315 return sceneInfo->_this();
335 orb->shutdown(
false);