Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00015 #ifndef OPENHRP_MODEL_LOADER_SHAPE_SET_INFO_INPL_H_INCLUDED
00016 #define OPENHRP_MODEL_LOADER_SHAPE_SET_INFO_INPL_H_INCLUDED
00017
00018 #include <string>
00019 #include <hrpCorba/ORBwrap.h>
00020 #include <hrpCorba/ModelLoader.hh>
00021 #include <hrpUtil/TriangleMeshShaper.h>
00022 #include <hrpUtil/VrmlNodes.h>
00023 #include <hrpUtil/Eigen3d.h>
00024 #include <hrpUtil/Eigen4d.h>
00025 #include <hrpCollision/ColdetModel.h>
00026
00027 using namespace OpenHRP;
00028 using namespace hrp;
00029
00030 class ShapeSetInfo_impl : public virtual POA_OpenHRP::ShapeSetInfo
00031 {
00032 public:
00033
00034 ShapeSetInfo_impl(PortableServer::POA_ptr poa);
00035 virtual ~ShapeSetInfo_impl();
00036
00037 virtual PortableServer::POA_ptr _default_POA();
00038
00039 virtual ShapeInfoSequence* shapes();
00040 virtual AppearanceInfoSequence* appearances();
00041 virtual MaterialInfoSequence* materials();
00042 virtual TextureInfoSequence* textures();
00043
00044 protected:
00045
00046 void applyTriangleMeshShaper(VrmlNodePtr node);
00047 static void putMessage(const std::string& message);
00048 std::string& replace(std::string& str, const std::string& sb, const std::string& sa);
00049 void traverseShapeNodes(VrmlNode* node, const Matrix44& T, TransformedShapeIndexSequence& io_shapeIndices, DblArray12Sequence& inlinedShapeM, const SFString* url = NULL);
00050 virtual const std::string& topUrl() = 0;
00051 void setColdetModel(ColdetModelPtr& coldetModel, TransformedShapeIndexSequence shapeIndices, const Matrix44& Tparent, int& vertexIndex, int& triangleIndex);
00052 void saveOriginalData();
00053 void restoreOriginalData();
00054 void createAppearanceInfo();
00055 void setBoundingBoxData(const Vector3& boxSize, int shapeIndex);
00056 bool checkFileUpdateTime();
00057 bool readImage;
00058
00059 private:
00060
00061 PortableServer::POA_var poa;
00062
00063 ShapeInfoSequence shapes_;
00064 AppearanceInfoSequence appearances_;
00065 MaterialInfoSequence materials_;
00066 TextureInfoSequence textures_;
00067
00068 ShapeInfoSequence originShapes_;
00069 AppearanceInfoSequence originAppearances_;
00070 MaterialInfoSequence originMaterials_;
00071
00072 TriangleMeshShaper triangleMeshShaper;
00073
00074 typedef std::map<VrmlShapePtr, int> ShapeNodeToShapeInfoIndexMap;
00075 ShapeNodeToShapeInfoIndexMap shapeInfoIndexMap;
00076
00077 std::map<std::string, time_t> fileTimeMap;
00078
00079 int createShapeInfo(VrmlShape* shapeNode, const SFString* url);
00080 void setTriangleMesh(ShapeInfo& shapeInfo, VrmlIndexedFaceSet* triangleMesh);
00081 void setPrimitiveProperties(ShapeInfo& shapeInfo, VrmlShape* shapeNode);
00082 int createAppearanceInfo(ShapeInfo& shapeInfo, VrmlShape* shapeNode, VrmlIndexedFaceSet* faceSet, const SFString *url);
00083 void setColors(AppearanceInfo& appInfo, VrmlIndexedFaceSet* triangleMesh);
00084 void setNormals(AppearanceInfo& appInfo, VrmlIndexedFaceSet* triangleMesh);
00085 void setTexCoords(AppearanceInfo& appInfo, VrmlIndexedFaceSet* triangleMesh);
00086 int createMaterialInfo(VrmlMaterialPtr& materialNode);
00087 int createTextureInfo(VrmlTexturePtr& textureNode, const SFString *url);
00088 void createTextureTransformMatrix(AppearanceInfo& appInfo, VrmlTextureTransformPtr& textureTransform );
00089 std::string getModelFileDirPath(const std::string& url);
00090 void setColdetModelTriangles(ColdetModelPtr& coldetModel, const TransformedShapeIndex& tsi, const Matrix44& Tparent, int& vertexIndex, int& triangleIndex);
00091
00092 friend class BodyInfo_impl;
00093 friend class SceneInfo_impl;
00094 #ifdef OPENHRP_COLLADA_FOUND
00095 friend class ColladaReader;
00096 friend class BodyInfoCollada_impl;
00097 friend class SceneInfoCollada_impl;
00098 #endif
00099 };
00100 #endif