ShapeSetInfo_impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  */
9 
15 #include "ShapeSetInfo_impl.h"
16 
17 #include <map>
18 #include <vector>
19 #include <iostream>
20 #include <boost/bind.hpp>
21 #include <sys/stat.h>
22 
23 #include <hrpCorba/ViewSimulator.hh>
24 #include <hrpUtil/VrmlNodes.h>
25 #include <hrpUtil/ImageConverter.h>
26 
27 #include "VrmlUtil.h"
28 
29 
30 
31 using namespace std;
32 using namespace boost;
33 
34 
35 
36 ShapeSetInfo_impl::ShapeSetInfo_impl(PortableServer::POA_ptr poa) :
37  poa(PortableServer::POA::_duplicate(poa))
38 {
40  triangleMeshShaper.sigMessage.connect(boost::bind(&putMessage, _1));
41 }
42 
43 
45 {
46 
47 }
48 
49 
50 PortableServer::POA_ptr ShapeSetInfo_impl::_default_POA()
51 {
52  return PortableServer::POA::_duplicate(poa);
53 }
54 
55 
57 {
59 }
60 
61 
62 void ShapeSetInfo_impl::putMessage(const std::string& message)
63 {
64  cout << message;
65 }
66 
67 
74 string& ShapeSetInfo_impl::replace(string& str, const string& sb, const string& sa)
75 {
76  string::size_type n, nb = 0;
77 
78  while ((n = str.find(sb,nb)) != string::npos){
79  str.replace(n,sb.size(),sa);
80  nb = n + sa.size();
81  }
82 
83  return str;
84 }
85 
86 
87 ShapeInfoSequence* ShapeSetInfo_impl::shapes()
88 {
89  return new ShapeInfoSequence(shapes_);
90 }
91 
92 
93 AppearanceInfoSequence* ShapeSetInfo_impl::appearances()
94 {
95  return new AppearanceInfoSequence(appearances_);
96 }
97 
98 
99 MaterialInfoSequence* ShapeSetInfo_impl::materials()
100 {
101  return new MaterialInfoSequence(materials_);
102 }
103 
104 
105 TextureInfoSequence* ShapeSetInfo_impl::textures()
106 {
107  return new TextureInfoSequence(textures_);
108 }
109 
110 
124 (VrmlNode* node, const Matrix44& T, TransformedShapeIndexSequence& io_shapeIndices, DblArray12Sequence& inlinedShapeM, const SFString* url)
125 {
126  static int inline_count=0;
127  SFString url_ = *url;
129  VrmlProtoInstance* protoInstance = static_cast<VrmlProtoInstance*>(node);
130  if(protoInstance->actualNode){
131  traverseShapeNodes(protoInstance->actualNode.get(), T, io_shapeIndices, inlinedShapeM, url);
132  }
133 
134  } else if(node->isCategoryOf(GROUPING_NODE)) {
135  VrmlGroup* groupNode = static_cast<VrmlGroup*>(node);
136  VrmlTransform* transformNode = dynamic_cast<VrmlTransform*>(groupNode);
137  VrmlInline* inlineNode = NULL;
138 
139  inlineNode = dynamic_cast<VrmlInline*>(groupNode);
140  const Matrix44* pT;
141  if(inlineNode){
142  if(!inline_count){
143  int inlinedShapeMIndex = inlinedShapeM.length();
144  inlinedShapeM.length(inlinedShapeMIndex+1);
145  int p = 0;
146  for(int row=0; row < 3; ++row){
147  for(int col=0; col < 4; ++col){
148  inlinedShapeM[inlinedShapeMIndex][p++] = T(row, col);
149  }
150  }
151  url_ = inlineNode->urls[0];
152  }
153  inline_count++;
154  for( MFString::iterator ite = inlineNode->urls.begin(); ite != inlineNode->urls.end(); ++ite ){
155  string filename(deleteURLScheme(*ite));
156  struct stat statbuff;
157  time_t mtime = 0;
158  if( stat( filename.c_str(), &statbuff ) == 0 ){
159  mtime = statbuff.st_mtime;
160  }
161  fileTimeMap.insert(make_pair(filename, mtime));
162  }
163  }
164  Matrix44 T2;
165  if( transformNode ){
166  Matrix44 Tlocal;
167  calcTransformMatrix(transformNode, Tlocal);
168  T2 = T * Tlocal;
169  pT = &T2;
170  } else {
171  pT = &T;
172  }
173 
174  VrmlSwitch* switchNode = dynamic_cast<VrmlSwitch*>(node);
175  if(switchNode){
176  int whichChoice = switchNode->whichChoice;
177  if( whichChoice >= 0 && whichChoice < switchNode->countChildren() )
178  traverseShapeNodes(switchNode->getChild(whichChoice), *pT, io_shapeIndices, inlinedShapeM, &url_);
179  }else{
180  for(int i=0; i < groupNode->countChildren(); ++i){
181  traverseShapeNodes(groupNode->getChild(i), *pT, io_shapeIndices, inlinedShapeM, &url_);
182  }
183  }
184  if(inlineNode)
185  inline_count--;
186 
187 
188  } else if(node->isCategoryOf(SHAPE_NODE)) {
189 
190  VrmlShape* shapeNode = static_cast<VrmlShape*>(node);
191  short shapeInfoIndex;
192 
193  ShapeNodeToShapeInfoIndexMap::iterator p = shapeInfoIndexMap.find(shapeNode);
194  if(p != shapeInfoIndexMap.end()){
195  shapeInfoIndex = p->second;
196  } else {
197  shapeInfoIndex = createShapeInfo(shapeNode, url);
198  }
199 
200  if(shapeInfoIndex >= 0){
201  long length = io_shapeIndices.length();
202  io_shapeIndices.length(length + 1);
203  TransformedShapeIndex& tsi = io_shapeIndices[length];
204  tsi.shapeIndex = shapeInfoIndex;
205  int p = 0;
206  for(int row=0; row < 3; ++row){
207  for(int col=0; col < 4; ++col){
208  tsi.transformMatrix[p++] = T(row, col);
209  }
210  }
211  if(inline_count)
212  tsi.inlinedShapeTransformMatrixIndex=inlinedShapeM.length()-1;
213  else
214  tsi.inlinedShapeTransformMatrixIndex=-1;
215  }
216  }
217 }
218 
223 {
224  int shapeInfoIndex = -1;
225 
226  VrmlIndexedFaceSet* triangleMesh = dynamic_node_cast<VrmlIndexedFaceSet>(shapeNode->geometry).get();
227 
228  if(triangleMesh){
229 
230  shapeInfoIndex = shapes_.length();
231  shapes_.length(shapeInfoIndex + 1);
232  ShapeInfo& shapeInfo = shapes_[shapeInfoIndex];
233 
234  if ( url ) shapeInfo.url = CORBA::string_dup( url->c_str() );
235  setTriangleMesh(shapeInfo, triangleMesh);
236  setPrimitiveProperties(shapeInfo, shapeNode);
237  shapeInfo.appearanceIndex = createAppearanceInfo(shapeInfo, shapeNode, triangleMesh, url);
238  shapeInfoIndexMap.insert(make_pair(shapeNode, shapeInfoIndex));
239  }
240 
241  return shapeInfoIndex;
242 }
243 
244 
245 void ShapeSetInfo_impl::setTriangleMesh(ShapeInfo& shapeInfo, VrmlIndexedFaceSet* triangleMesh)
246 {
247  const MFVec3f& vertices = triangleMesh->coord->point;
248  size_t numVertices = vertices.size();
249  shapeInfo.vertices.length(numVertices * 3);
250 
251  size_t pos = 0;
252  for(size_t i=0; i < numVertices; ++i){
253  const SFVec3f& v = vertices[i];
254  shapeInfo.vertices[pos++] = v[0];
255  shapeInfo.vertices[pos++] = v[1];
256  shapeInfo.vertices[pos++] = v[2];
257  }
258 
259  const MFInt32& indices = triangleMesh->coordIndex;
260  const size_t numTriangles = indices.size() / 4;
261  shapeInfo.triangles.length(numTriangles * 3);
262 
263  int dpos = 0;
264  int spos = 0;
265  for(size_t i=0; i < numTriangles; ++i){
266  shapeInfo.triangles[dpos++] = indices[spos++];
267  shapeInfo.triangles[dpos++] = indices[spos++];
268  shapeInfo.triangles[dpos++] = indices[spos++];
269  spos++; // skip a terminater '-1'
270  }
271 }
272 
273 
274 void ShapeSetInfo_impl::setPrimitiveProperties(ShapeInfo& shapeInfo, VrmlShape* shapeNode)
275 {
276  shapeInfo.primitiveType = SP_MESH;
277  FloatSequence& param = shapeInfo.primitiveParameters;
278 
279  VrmlNode *node = triangleMeshShaper.getOriginalGeometry(shapeNode).get();
280  VrmlGeometry* originalGeometry = dynamic_cast<VrmlGeometry *>(node);
281 
282  if(originalGeometry){
283 
284  VrmlIndexedFaceSet* faceSet = dynamic_cast<VrmlIndexedFaceSet*>(originalGeometry);
285 
286  if(!faceSet){
287 
288  if(VrmlBox* box = dynamic_cast<VrmlBox*>(originalGeometry)){
289  shapeInfo.primitiveType = SP_BOX;
290  param.length(3);
291  for(int i=0; i < 3; ++i){
292  param[i] = box->size[i];
293  }
294 
295  } else if(VrmlCone* cone = dynamic_cast<VrmlCone*>(originalGeometry)){
296  shapeInfo.primitiveType = SP_CONE;
297  param.length(4);
298  param[0] = cone->bottomRadius;
299  param[1] = cone->height;
300  param[2] = cone->bottom ? 1.0 : 0.0;
301  param[3] = cone->side ? 1.0 : 0.0;
302 
303  } else if(VrmlCylinder* cylinder = dynamic_cast<VrmlCylinder*>(originalGeometry)){
304  shapeInfo.primitiveType = SP_CYLINDER;
305  param.length(5);
306  param[0] = cylinder->radius;
307  param[1] = cylinder->height;
308  param[2] = cylinder->top ? 1.0 : 0.0;
309  param[3] = cylinder->bottom ? 1.0 : 0.0;
310  param[4] = cylinder->side ? 1.0 : 0.0;
311 
312 
313  } else if(VrmlSphere* sphere = dynamic_cast<VrmlSphere*>(originalGeometry)){
314  shapeInfo.primitiveType = SP_SPHERE;
315  param.length(1);
316  param[0] = sphere->radius;
317  }
318  }
319  }else{
320 
321  VrmlProtoInstance *protoInstance = dynamic_cast<VrmlProtoInstance *>(node);
322  if (protoInstance && protoInstance->proto->protoName == "Plane"){
323  VrmlBox *box = dynamic_cast<VrmlBox *>(protoInstance->actualNode.get());
324  shapeInfo.primitiveType = SP_PLANE;
325  param.length(3);
326  for (int i=0; i<3; i++){
327  param[i] = box->size[i];
328  }
329  }
330  }
331 }
332 
333 
338 (ShapeInfo& shapeInfo, VrmlShape* shapeNode, VrmlIndexedFaceSet* faceSet,
339  const SFString *url)
340 {
341  int appearanceIndex = appearances_.length();
342  appearances_.length(appearanceIndex + 1);
343  AppearanceInfo& appInfo = appearances_[appearanceIndex];
344 
345  appInfo.normalPerVertex = faceSet->normalPerVertex;
346  appInfo.colorPerVertex = faceSet->colorPerVertex;
347  appInfo.solid = faceSet->solid;
348  appInfo.creaseAngle = faceSet->creaseAngle;
349  appInfo.materialIndex = -1;
350  appInfo.textureIndex = -1;
351 
352  if(faceSet->color){
353  setColors(appInfo, faceSet);
354  }
355 
356  if(faceSet->normal){
357  setNormals(appInfo, faceSet);
358  }
359 
360  VrmlAppearancePtr& appNode = shapeNode->appearance;
361 
362  if(appNode) {
363  appInfo.materialIndex = createMaterialInfo(appNode->material);
364  appInfo.textureIndex = createTextureInfo (appNode->texture, url);
365  if(appInfo.textureIndex != -1 ){
366  createTextureTransformMatrix(appInfo, appNode->textureTransform);
367  if(!faceSet->texCoord){ // default Texture Mapping
368  triangleMeshShaper.defaultTextureMapping(shapeNode);
369  }
370  setTexCoords(appInfo, faceSet);
371  }
372  }
373 
374  return appearanceIndex;
375 }
376 
377 
378 void ShapeSetInfo_impl::setColors(AppearanceInfo& appInfo, VrmlIndexedFaceSet* triangleMesh)
379 {
380  const MFColor& colors = triangleMesh->color->color;
381  int numColors = colors.size();
382  appInfo.colors.length(numColors * 3);
383 
384  int pos = 0;
385  for(int i=0; i < numColors; ++i){
386  const SFColor& color = colors[i];
387  for(int j=0; j < 3; ++j){
388  appInfo.colors[pos++] = color[j];
389  }
390  }
391 
392  const MFInt32& orgIndices = triangleMesh->colorIndex;
393  const int numOrgIndices = orgIndices.size();
394  if(numOrgIndices > 0){
395  if(triangleMesh->colorPerVertex){
396  const int numTriangles = numOrgIndices / 4; // considering delimiter element '-1'
397  appInfo.colorIndices.length(numTriangles * 3);
398  int dpos = 0;
399  int spos = 0;
400  for(int i=0; i < numTriangles; ++i){
401  appInfo.colorIndices[dpos++] = orgIndices[spos++];
402  appInfo.colorIndices[dpos++] = orgIndices[spos++];
403  appInfo.colorIndices[dpos++] = orgIndices[spos++];
404  spos++; // skip delimiter '-1'
405  }
406  } else { // color per face
407  appInfo.colorIndices.length(numOrgIndices);
408  for(int i=0; i < numOrgIndices; ++i){
409  appInfo.colorIndices[i] = orgIndices[i];
410  }
411  }
412  }
413 }
414 
415 
416 void ShapeSetInfo_impl::setNormals(AppearanceInfo& appInfo, VrmlIndexedFaceSet* triangleMesh)
417 {
418  const MFVec3f& normals = triangleMesh->normal->vector;
419  int numNormals = normals.size();
420  appInfo.normals.length(numNormals * 3);
421 
422  int pos = 0;
423  for(int i=0; i < numNormals; ++i){
424  const SFVec3f& n = normals[i];
425  for(int j=0; j < 3; ++j){
426  appInfo.normals[pos++] = n[j];
427  }
428  }
429 
430  const MFInt32& orgIndices = triangleMesh->normalIndex;
431  const int numOrgIndices = orgIndices.size();
432  if(numOrgIndices > 0){
433  if(triangleMesh->normalPerVertex){
434  const int numTriangles = numOrgIndices / 4; // considering delimiter element '-1'
435  appInfo.normalIndices.length(numTriangles * 3);
436  int dpos = 0;
437  int spos = 0;
438  for(int i=0; i < numTriangles; ++i){
439  appInfo.normalIndices[dpos++] = orgIndices[spos++];
440  appInfo.normalIndices[dpos++] = orgIndices[spos++];
441  appInfo.normalIndices[dpos++] = orgIndices[spos++];
442  spos++; // skip delimiter '-1'
443  }
444  } else { // normal per face
445  appInfo.normalIndices.length(numOrgIndices);
446  for(int i=0; i < numOrgIndices; ++i){
447  appInfo.normalIndices[i] = orgIndices[i];
448  }
449  }
450  }
451 }
452 
453 void ShapeSetInfo_impl::setTexCoords(AppearanceInfo& appInfo, VrmlIndexedFaceSet* triangleMesh )
454 {
455  int numCoords = triangleMesh->texCoord->point.size();
456  appInfo.textureCoordinate.length(numCoords * 2);
457 
458  Matrix33 m;
459  for(int i=0,k=0; i<3; i++)
460  for(int j=0; j<3; j++)
461  m(i,j) = appInfo.textransformMatrix[k++];
462 
463  for(int i=0, pos=0; i < numCoords; i++ ){
464  Vector3 point(triangleMesh->texCoord->point[i][0], triangleMesh->texCoord->point[i][1], 1);
465  Vector3 texCoordinate(m * point);
466  appInfo.textureCoordinate[pos++] = texCoordinate(0);
467  appInfo.textureCoordinate[pos++] = texCoordinate(1);
468  }
469 
470  int numIndex = triangleMesh->texCoordIndex.size();
471  if(numIndex > 0){
472  appInfo.textureCoordIndices.length(numIndex * 3 / 4);
473  for(int i=0, j=0; i < numIndex; i++){
474  if(triangleMesh->texCoordIndex[i] != -1)
475  appInfo.textureCoordIndices[j++] = triangleMesh->texCoordIndex[i];
476  }
477  }
478 }
479 
480 void ShapeSetInfo_impl::createTextureTransformMatrix(AppearanceInfo& appInfo, VrmlTextureTransformPtr& textureTransform ){
481 
482  Matrix33 m;
483  if(textureTransform){
484  Matrix33 matCT;
485  matCT << 1, 0, textureTransform->translation[0]+textureTransform->center[0],
486  0, 1, textureTransform->translation[1]+textureTransform->center[1],
487  0,0,1 ;
488  Matrix33 matR;
489  matR << cos(textureTransform->rotation), -sin(textureTransform->rotation), 0,
490  sin(textureTransform->rotation), cos(textureTransform->rotation), 0,
491  0,0,1;
492  Matrix33 matCS;
493  matCS << textureTransform->scale[0], 0, -textureTransform->center[0],
494  0, textureTransform->scale[1], -textureTransform->center[1],
495  0,0,1 ;
496 
497  m = matCS * matR * matCT;
498  }else{
499  m = Matrix33::Identity();
500  }
501 
502  for(int i=0,k=0; i<3; i++)
503  for(int j=0; j<3; j++)
504  appInfo.textransformMatrix[k++] = m(i,j);
505 }
506 
516 {
517  int materialInfoIndex = -1;
518 
519  if(materialNode){
520  MaterialInfo_var material(new MaterialInfo());
521 
522  material->ambientIntensity = materialNode->ambientIntensity;
523  material->shininess = materialNode->shininess;
524  material->transparency = materialNode->transparency;
525 
526  for(int j = 0 ; j < 3 ; j++){
527  material->diffuseColor[j] = materialNode->diffuseColor[j];
528  material->emissiveColor[j] = materialNode->emissiveColor[j];
529  material->specularColor[j] = materialNode->specularColor[j];
530  }
531 
532  // materials_に追加する //
533  materialInfoIndex = materials_.length();
534  materials_.length(materialInfoIndex + 1 );
535  materials_[materialInfoIndex] = material;
536 
537  }
538 
539  return materialInfoIndex;
540 }
541 
542 
553 {
554  int textureInfoIndex = -1;
555 
556  if(textureNode){
557 
558  TextureInfo_var texture(new TextureInfo());
559 
560  VrmlPixelTexturePtr pixelTextureNode = dynamic_pointer_cast<VrmlPixelTexture>(textureNode);
561 
562  if(!pixelTextureNode){
563  VrmlImageTexturePtr imageTextureNode = dynamic_pointer_cast<VrmlImageTexture>(textureNode);
564  if(imageTextureNode){
565  string url = setTexturefileUrl(getModelFileDirPath(*currentUrl), imageTextureNode->url);
566  texture->url = CORBA::string_dup(url.c_str());
567  texture->repeatS = imageTextureNode->repeatS;
568  texture->repeatT = imageTextureNode->repeatT;
569  if(readImage && !url.empty()){
570  ImageConverter converter;
571  SFImage* image = converter.convert(url);
572  texture->height = image->height;
573  texture->width = image->width;
574  texture->numComponents = image->numComponents;
575  unsigned long pixelsLength = image->pixels.size();
576  texture->image.length( pixelsLength );
577  for(unsigned long j = 0 ; j < pixelsLength ; j++ ){
578  texture->image[j] = image->pixels[j];
579  }
580  }else{
581  texture->height = 0;
582  texture->width = 0;
583  texture->numComponents = 0;
584  }
585  }
586  }else if(pixelTextureNode){
587  texture->height = pixelTextureNode->image.height;
588  texture->width = pixelTextureNode->image.width;
589  texture->numComponents = pixelTextureNode->image.numComponents;
590 
591  size_t pixelsLength = pixelTextureNode->image.pixels.size();
592  texture->image.length( pixelsLength );
593  for(size_t j = 0 ; j < pixelsLength ; j++ ){
594  texture->image[j] = pixelTextureNode->image.pixels[j];
595  }
596  texture->repeatS = pixelTextureNode->repeatS;
597  texture->repeatT = pixelTextureNode->repeatT;
598  }
599 
600  textureInfoIndex = textures_.length();
601  textures_.length(textureInfoIndex + 1);
602  textures_[textureInfoIndex] = texture;
603  }
604 
605  return textureInfoIndex;
606 }
607 
608 
616 std::string ShapeSetInfo_impl::getModelFileDirPath(const std::string& url)
617 {
618  // BodyInfo::url_ から URLスキームを削除する //
619  string filepath = deleteURLScheme(url);
620 
621  // '/' または '\' の最後の位置を取得する //
622  size_t pos = filepath.find_last_of("/\\");
623 
624  string dirPath = "";
625 
626  // 存在すれば, //
627  if(pos != string::npos){
628  // ディレクトリパス文字列 //
629  dirPath = filepath;
630  dirPath.resize(pos + 1);
631  }
632 
633  return dirPath;
634 }
635 
636 void ShapeSetInfo_impl::setColdetModel(ColdetModelPtr& coldetModel, TransformedShapeIndexSequence shapeIndices, const Matrix44& Tparent, int& vertexIndex, int& triangleIndex){
637  for(unsigned int i=0; i < shapeIndices.length(); i++){
638  setColdetModelTriangles(coldetModel, shapeIndices[i], Tparent, vertexIndex, triangleIndex);
639  }
640 }
641 
643 (ColdetModelPtr& coldetModel, const TransformedShapeIndex& tsi, const Matrix44& Tparent, int& vertexIndex, int& triangleIndex)
644 {
645  short shapeIndex = tsi.shapeIndex;
646  const DblArray12& M = tsi.transformMatrix;;
647  Matrix44 T, Tlocal;
648  Tlocal << M[0], M[1], M[2], M[3],
649  M[4], M[5], M[6], M[7],
650  M[8], M[9], M[10], M[11],
651  0.0, 0.0, 0.0, 1.0;
652  T = Tparent * Tlocal;
653 
654  const ShapeInfo& shapeInfo = shapes_[shapeIndex];
655  int vertexIndexBase = coldetModel->getNumVertices();
656  const FloatSequence& vertices = shapeInfo.vertices;
657  const int numVertices = vertices.length() / 3;
658  coldetModel->setNumVertices(coldetModel->getNumVertices()+numVertices);
659  for(int j=0; j < numVertices; ++j){
660  Vector4 v(T * Vector4(vertices[j*3], vertices[j*3+1], vertices[j*3+2], 1.0));
661  coldetModel->setVertex(vertexIndex++, v[0], v[1], v[2]);
662  }
663  const LongSequence& triangles = shapeInfo.triangles;
664  const int numTriangles = triangles.length() / 3;
665  coldetModel->setNumTriangles(coldetModel->getNumTriangles()+numTriangles);
666  for(int j=0; j < numTriangles; ++j){
667  int t0 = triangles[j*3] + vertexIndexBase;
668  int t1 = triangles[j*3+1] + vertexIndexBase;
669  int t2 = triangles[j*3+2] + vertexIndexBase;
670  coldetModel->setTriangle( triangleIndex++, t0, t1, t2);
671  }
672 
673 }
674 
679 }
680 
681 void ShapeSetInfo_impl::setBoundingBoxData(const Vector3& boxSize, int shapeIndex){
682  VrmlBox* box = new VrmlBox();
683  VrmlIndexedFaceSetPtr triangleMesh;
684  box->size[0] = boxSize[0]*2;
685  box->size[1] = boxSize[1]*2;
686  box->size[2] = boxSize[2]*2;
687  triangleMesh = new VrmlIndexedFaceSet();
688  triangleMesh->coord = new VrmlCoordinate();
689  triangleMeshShaper.convertBox(box, triangleMesh);
690 
691  shapes_.length(shapeIndex+1);
692  ShapeInfo& shapeInfo = shapes_[shapeIndex];
693  VrmlIndexedFaceSet* faceSet = triangleMesh.get();
694  setTriangleMesh(shapeInfo, faceSet);
695  shapeInfo.primitiveType = SP_BOX;
696  FloatSequence& param = shapeInfo.primitiveParameters;
697  param.length(3);
698  for(int i=0; i < 3; ++i)
699  param[i] = box->size[i];
700  shapeInfo.appearanceIndex = 0;
701 
702  delete box;
703 }
704 
706  appearances_.length(1);
707  AppearanceInfo& appInfo = appearances_[0];
708  appInfo.normalPerVertex = false;
709  appInfo.colorPerVertex = false;
710  appInfo.solid = false;
711  appInfo.creaseAngle = 0.0;
712  appInfo.textureIndex = -1;
713  appInfo.normals.length(0);
714  appInfo.normalIndices.length(0);
715  appInfo.colors.length(0);
716  appInfo.colorIndices.length(0);
717  appInfo.materialIndex = 0;
718  appInfo.textureIndex = -1;
719 
720  materials_.length(1);
721  MaterialInfo& material = materials_[0];
722  material.ambientIntensity = 0.2;
723  material.shininess = 0.2;
724  material.transparency = 0.0;
725  for(int j = 0 ; j < 3 ; j++){
726  material.diffuseColor[j] = 0.8;
727  material.emissiveColor[j] = 0.0;
728  material.specularColor[j] = 0.0;
729  }
730 }
731 
736 }
737 
739  bool ret=true;
740  for( map<std::string, time_t>::iterator it=fileTimeMap.begin(); it != fileTimeMap.end(); ++it){
741  struct stat statbuff;
742  time_t mtime = 0;
743  if( stat( it->first.c_str(), &statbuff ) == 0 ){
744  mtime = statbuff.st_mtime;
745  }
746  if(it->second!=mtime){
747  ret=false;
748  break;
749  }
750  }
751  return ret;
752 }
ShapeSetInfo_impl::appearances
virtual AppearanceInfoSequence * appearances()
Definition: ShapeSetInfo_impl.cpp:93
ShapeSetInfo_impl::setTexCoords
void setTexCoords(AppearanceInfo &appInfo, VrmlIndexedFaceSet *triangleMesh)
Definition: ShapeSetInfo_impl.cpp:453
hrp::VrmlInline::urls
MFString urls
Definition: VrmlNodes.h:272
ShapeSetInfo_impl::setColdetModel
void setColdetModel(ColdetModelPtr &coldetModel, TransformedShapeIndexSequence shapeIndices, const Matrix44 &Tparent, int &vertexIndex, int &triangleIndex)
Definition: ShapeSetInfo_impl.cpp:636
ImageConverter.h
Header file of Image Converter class.
hrp::VrmlIndexedFaceSet::solid
SFBool solid
Definition: VrmlNodes.h:495
hrp::VrmlTransform
VRML Transform node.
Definition: VrmlNodes.h:254
i
png_uint_32 i
Definition: png.h:2732
hrp::VrmlInline
VRML Inline node.
Definition: VrmlNodes.h:268
setTexturefileUrl
string setTexturefileUrl(string modelfileDir, MFString urls)
Definition: VrmlUtil.cpp:210
hrp::VrmlPixelTexturePtr
boost::intrusive_ptr< VrmlPixelTexture > VrmlPixelTexturePtr
Definition: VrmlNodes.h:582
hrp::TriangleMeshShaper::setNormalGenerationMode
void setNormalGenerationMode(bool on)
Definition: TriangleMeshShaper.cpp:127
hrp::VrmlShape::geometry
SFNode geometry
Definition: VrmlNodes.h:290
hrp::deleteURLScheme
HRP_UTIL_EXPORT string deleteURLScheme(string url)
Definition: UrlUtil.cpp:25
ShapeSetInfo_impl::readImage
bool readImage
Definition: ShapeSetInfo_impl.h:57
hrp::VrmlTexturePtr
boost::intrusive_ptr< VrmlTexture > VrmlTexturePtr
Definition: VrmlNodes.h:298
hrp::VrmlAppearancePtr
boost::intrusive_ptr< VrmlAppearance > VrmlAppearancePtr
Definition: VrmlNodes.h:277
ShapeSetInfo_impl::saveOriginalData
void saveOriginalData()
Definition: ShapeSetInfo_impl.cpp:675
hrp::TriangleMeshShaper::sigMessage
boost::signal< void(const std::string &message)> sigMessage
Definition: TriangleMeshShaper.h:47
ShapeSetInfo_impl::shapes
virtual ShapeInfoSequence * shapes()
Definition: ShapeSetInfo_impl.cpp:87
ShapeSetInfo_impl::createShapeInfo
int createShapeInfo(VrmlShape *shapeNode, const SFString *url)
Definition: ShapeSetInfo_impl.cpp:222
ShapeSetInfo_impl::shapeInfoIndexMap
ShapeNodeToShapeInfoIndexMap shapeInfoIndexMap
Definition: ShapeSetInfo_impl.h:75
hrp::SFVec3f
boost::array< SFFloat, 3 > SFVec3f
Definition: VrmlNodes.h:55
hrp::VrmlImageTexturePtr
boost::intrusive_ptr< VrmlImageTexture > VrmlImageTexturePtr
Definition: VrmlNodes.h:350
hrp::SFString
std::string SFString
Definition: VrmlNodes.h:52
box
Definition: jquant2.c:258
hrp::VrmlCoordinate
VRML Coordinate node.
Definition: VrmlNodes.h:512
hrp::VrmlIndexedFaceSet::texCoord
VrmlTextureCoordinatePtr texCoord
Definition: VrmlNodes.h:489
autoplay.n
n
Definition: autoplay.py:12
hrp::ImageConverter
Definition: ImageConverter.h:19
hrp::VrmlShape::appearance
VrmlAppearancePtr appearance
Definition: VrmlNodes.h:289
hrp::VrmlIndexedFaceSet::normalIndex
MFInt32 normalIndex
Definition: VrmlNodes.h:493
hrp::TriangleMeshShaper::convertBox
bool convertBox(VrmlBox *box, VrmlIndexedFaceSetPtr &triangleMesh)
Definition: TriangleMeshShaper.cpp:1623
boost
Modifications controlling boost library behavior.
Definition: ColladaUtil.h:306
VrmlNodes.h
hrp::VrmlNode
Abstract base class of all vrml nodes.
Definition: VrmlNodes.h:121
hrp::VrmlIndexedFaceSet
VRML IndexedFaseSet node.
Definition: VrmlNodes.h:483
ShapeSetInfo_impl::textures
virtual TextureInfoSequence * textures()
Definition: ShapeSetInfo_impl.cpp:105
hrp::VrmlProtoInstance::proto
VrmlProtoPtr proto
Definition: VrmlNodes.h:886
ShapeSetInfo_impl::~ShapeSetInfo_impl
virtual ~ShapeSetInfo_impl()
Definition: ShapeSetInfo_impl.cpp:44
hrp::VrmlGroup
VRML Group node.
Definition: VrmlNodes.h:236
hrp::VrmlShape
VRML Shape node.
Definition: VrmlNodes.h:285
hrp::VrmlCone
VRML Cone node.
Definition: VrmlNodes.h:383
hrp::VrmlMaterialPtr
boost::intrusive_ptr< VrmlMaterial > VrmlMaterialPtr
Definition: VrmlNodes.h:295
hrp::VrmlIndexedLineSet::coord
VrmlCoordinatePtr coord
Definition: VrmlNodes.h:467
ShapeSetInfo_impl::appearances_
AppearanceInfoSequence appearances_
Definition: ShapeSetInfo_impl.h:64
hrp::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:11
hrp::VrmlIndexedFaceSetPtr
boost::intrusive_ptr< VrmlIndexedFaceSet > VrmlIndexedFaceSetPtr
Definition: VrmlNodes.h:498
ShapeSetInfo_impl::applyTriangleMeshShaper
void applyTriangleMeshShaper(VrmlNodePtr node)
Definition: ShapeSetInfo_impl.cpp:56
hrp::VrmlIndexedFaceSet::normalPerVertex
SFBool normalPerVertex
Definition: VrmlNodes.h:494
ShapeSetInfo_impl::originMaterials_
MaterialInfoSequence originMaterials_
Definition: ShapeSetInfo_impl.h:70
hrp::PROTO_INSTANCE_NODE
@ PROTO_INSTANCE_NODE
Definition: VrmlNodes.h:86
hrp::SFColor
SFVec3f SFColor
Definition: VrmlNodes.h:58
hrp::VrmlIndexedFaceSet::texCoordIndex
MFInt32 texCoordIndex
Definition: VrmlNodes.h:496
filename
char * filename
Definition: cdjpeg.h:133
VrmlUtil.h
hrp::Matrix44
Eigen::Matrix4d Matrix44
Definition: Eigen4d.h:18
ShapeSetInfo_impl.h
hrp::VrmlSwitch::whichChoice
SFInt32 whichChoice
Definition: VrmlNodes.h:666
ShapeSetInfo_impl::getModelFileDirPath
std::string getModelFileDirPath(const std::string &url)
Definition: ShapeSetInfo_impl.cpp:616
hrp::VrmlIndexedFaceSet::creaseAngle
SFFloat creaseAngle
Definition: VrmlNodes.h:492
image
png_bytepp image
Definition: png.h:1769
hrp::VrmlNode::isCategoryOf
bool isCategoryOf(VrmlNodeCategory category)
Definition: VrmlNodes.cpp:60
hrp::VrmlNodePtr
boost::intrusive_ptr< VrmlNode > VrmlNodePtr
Definition: VrmlNodes.h:155
ShapeSetInfo_impl::originShapes_
ShapeInfoSequence originShapes_
Definition: ShapeSetInfo_impl.h:68
ShapeSetInfo_impl::setBoundingBoxData
void setBoundingBoxData(const Vector3 &boxSize, int shapeIndex)
Definition: ShapeSetInfo_impl.cpp:681
hrp::Vector4
Eigen::Vector4d Vector4
Definition: Eigen4d.h:21
hrp::VrmlGeometry
Base class of VRML geometry nodes.
Definition: VrmlNodes.h:366
ShapeSetInfo_impl::fileTimeMap
std::map< std::string, time_t > fileTimeMap
Definition: ShapeSetInfo_impl.h:77
row
png_bytepp row
Definition: png.h:1756
ShapeSetInfo_impl::ShapeSetInfo_impl
ShapeSetInfo_impl(PortableServer::POA_ptr poa)
Definition: ShapeSetInfo_impl.cpp:36
hrp::SFImage::height
int height
Definition: VrmlNodes.h:63
ShapeSetInfo_impl::createAppearanceInfo
void createAppearanceInfo()
Definition: ShapeSetInfo_impl.cpp:705
hrp::MFColor
std::vector< SFColor > MFColor
Definition: VrmlNodes.h:76
hrp::VrmlGroup::countChildren
virtual int countChildren()
Definition: VrmlNodes.cpp:144
ShapeSetInfo_impl::setColors
void setColors(AppearanceInfo &appInfo, VrmlIndexedFaceSet *triangleMesh)
Definition: ShapeSetInfo_impl.cpp:378
hrp::SFImage
Definition: VrmlNodes.h:61
ShapeSetInfo_impl::_default_POA
virtual PortableServer::POA_ptr _default_POA()
Definition: ShapeSetInfo_impl.cpp:50
hrp::VrmlIndexedLineSet::coordIndex
MFInt32 coordIndex
Definition: VrmlNodes.h:470
hrp::VrmlIndexedLineSet::color
VrmlColorPtr color
Definition: VrmlNodes.h:466
ShapeSetInfo_impl::createMaterialInfo
int createMaterialInfo(VrmlMaterialPtr &materialNode)
Definition: ShapeSetInfo_impl.cpp:515
ShapeSetInfo_impl::checkFileUpdateTime
bool checkFileUpdateTime()
Definition: ShapeSetInfo_impl.cpp:738
hrp::GROUPING_NODE
@ GROUPING_NODE
Definition: VrmlNodes.h:90
hrp::VrmlGroup::getChild
virtual VrmlNode * getChild(int index)
Definition: VrmlNodes.cpp:150
hrp::MFInt32
std::vector< SFInt32 > MFInt32
Definition: VrmlNodes.h:69
hrp::VrmlProtoInstance
VRML node which is instance of VRML Prototype.
Definition: VrmlNodes.h:883
ShapeSetInfo_impl::restoreOriginalData
void restoreOriginalData()
Definition: ShapeSetInfo_impl.cpp:732
hrp::VrmlProtoInstance::actualNode
VrmlNodePtr actualNode
Definition: VrmlNodes.h:888
hrp::TriangleMeshShaper::apply
VrmlNodePtr apply(VrmlNodePtr topNode)
Definition: TriangleMeshShaper.cpp:169
ShapeSetInfo_impl::poa
PortableServer::POA_var poa
Definition: ShapeSetInfo_impl.h:61
hrp::VrmlTextureTransformPtr
boost::intrusive_ptr< VrmlTextureTransform > VrmlTextureTransformPtr
Definition: VrmlNodes.h:301
hrp::Matrix33
Eigen::Matrix3d Matrix33
Definition: EigenTypes.h:12
ShapeSetInfo_impl::originAppearances_
AppearanceInfoSequence originAppearances_
Definition: ShapeSetInfo_impl.h:69
hrp::VrmlCylinder
VRML Cylinder node.
Definition: VrmlNodes.h:397
ShapeSetInfo_impl::triangleMeshShaper
TriangleMeshShaper triangleMeshShaper
Definition: ShapeSetInfo_impl.h:72
ShapeSetInfo_impl::setPrimitiveProperties
void setPrimitiveProperties(ShapeInfo &shapeInfo, VrmlShape *shapeNode)
Definition: ShapeSetInfo_impl.cpp:274
hrp::VrmlIndexedFaceSet::normal
VrmlNormalPtr normal
Definition: VrmlNodes.h:488
hrp::VrmlIndexedLineSet::colorPerVertex
SFBool colorPerVertex
Definition: VrmlNodes.h:469
hrp::ColdetModelPtr
boost::intrusive_ptr< ColdetModel > ColdetModelPtr
Definition: ColdetModel.h:268
hrp::VrmlSphere
VRML Sphere node.
Definition: VrmlNodes.h:412
ShapeSetInfo_impl::setNormals
void setNormals(AppearanceInfo &appInfo, VrmlIndexedFaceSet *triangleMesh)
Definition: ShapeSetInfo_impl.cpp:416
ShapeSetInfo_impl::createTextureTransformMatrix
void createTextureTransformMatrix(AppearanceInfo &appInfo, VrmlTextureTransformPtr &textureTransform)
Definition: ShapeSetInfo_impl.cpp:480
hrp::VrmlSwitch::getChild
virtual VrmlNode * getChild(int index)
Definition: VrmlNodes.cpp:439
ShapeSetInfo_impl::materials
virtual MaterialInfoSequence * materials()
Definition: ShapeSetInfo_impl.cpp:99
ShapeSetInfo_impl::replace
std::string & replace(std::string &str, const std::string &sb, const std::string &sa)
Definition: ShapeSetInfo_impl.cpp:74
hrp::calcTransformMatrix
HRP_UTIL_EXPORT void calcTransformMatrix(VrmlTransform *transform, Matrix44 &out_T)
Definition: Eigen4d.cpp:49
length
png_bytep png_bytep png_size_t length
Definition: png.h:1538
ShapeSetInfo_impl::putMessage
static void putMessage(const std::string &message)
Definition: ShapeSetInfo_impl.cpp:62
hrp::VrmlIndexedLineSet::colorIndex
MFInt32 colorIndex
Definition: VrmlNodes.h:468
hrp::ImageConverter::convert
HRP_UTIL_EXPORT SFImage * convert(string url)
convert ImageTexture node to PixelTexture node
Definition: ImageConverter.cpp:60
hrp::SHAPE_NODE
@ SHAPE_NODE
Definition: VrmlNodes.h:98
ShapeSetInfo_impl::traverseShapeNodes
void traverseShapeNodes(VrmlNode *node, const Matrix44 &T, TransformedShapeIndexSequence &io_shapeIndices, DblArray12Sequence &inlinedShapeM, const SFString *url=NULL)
Definition: ShapeSetInfo_impl.cpp:124
ShapeSetInfo_impl::materials_
MaterialInfoSequence materials_
Definition: ShapeSetInfo_impl.h:65
ShapeSetInfo_impl::createTextureInfo
int createTextureInfo(VrmlTexturePtr &textureNode, const SFString *url)
Definition: ShapeSetInfo_impl.cpp:552
ShapeSetInfo_impl::setColdetModelTriangles
void setColdetModelTriangles(ColdetModelPtr &coldetModel, const TransformedShapeIndex &tsi, const Matrix44 &Tparent, int &vertexIndex, int &triangleIndex)
Definition: ShapeSetInfo_impl.cpp:643
hrp::VrmlSwitch
Definition: VrmlNodes.h:655
hrp::MFVec3f
std::vector< SFVec3f > MFVec3f
Definition: VrmlNodes.h:72
ShapeSetInfo_impl::shapes_
ShapeInfoSequence shapes_
Definition: ShapeSetInfo_impl.h:63
hrp::VrmlBox
VRML Box node.
Definition: VrmlNodes.h:373
ShapeSetInfo_impl::setTriangleMesh
void setTriangleMesh(ShapeInfo &shapeInfo, VrmlIndexedFaceSet *triangleMesh)
Definition: ShapeSetInfo_impl.cpp:245
hrp::TriangleMeshShaper::getOriginalGeometry
SFNode getOriginalGeometry(VrmlShapePtr shapeNode)
Definition: TriangleMeshShaper.cpp:140
ShapeSetInfo_impl::textures_
TextureInfoSequence textures_
Definition: ShapeSetInfo_impl.h:66


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04