server/ModelLoader/VrmlWriter.cpp
Go to the documentation of this file.
1 #include <hrpUtil/Eigen3d.h>
2 #include "VrmlWriter.h"
3 #include <fstream>
4 
5 using namespace hrp;
6 using namespace OpenHRP;
7 
8 void VrmlWriter::write(OpenHRP::BodyInfo_var binfo, std::ostream &ofs)
9 {
10  m_indent = 0;
11  writeProtoNodes(ofs);
12  writeHumanoidNode(binfo, ofs);
13 }
14 
15 void VrmlWriter::indent(std::ostream &ofs)
16 {
17  for (int i=0; i<m_indent; i++) ofs << " ";
18 }
19 
20 void VrmlWriter::useInlineShape(bool use_inline)
21 {
22  m_use_inline_shape = use_inline;
23 }
24 
25 void VrmlWriter::writeLink(int index, std::ostream &ofs)
26 {
27  LinkInfo &linfo = links[index];
28  indent(ofs); ofs << "DEF " << linfo.name << " Joint {" << std::endl;
29  m_indent += 2;
30  if (linfo.translation[0] || linfo.translation[1] || linfo.translation[2]){
31  indent(ofs); ofs << "translation " << linfo.translation[0] << " "
32  << linfo.translation[1] << " " << linfo.translation[2]
33  << std::endl;
34  }
35  if (linfo.rotation[3]){
36  indent(ofs); ofs << "rotation " << linfo.rotation[0] << " "
37  << linfo.rotation[1] << " " << linfo.rotation[2]
38  << " " << linfo.rotation[3] << std::endl;
39  }
40  if (linfo.jointId != -1){
41  indent(ofs); ofs << "jointId " << linfo.jointId << std::endl;
42  }
43  indent(ofs); ofs << "jointType \"" << linfo.jointType << "\"" << std::endl;
44  indent(ofs); ofs << "jointAxis " << linfo.jointAxis[0] << " "
45  << linfo.jointAxis[1] << " " << linfo.jointAxis[2]
46  << std::endl;
47  if (linfo.ulimit.length()){
48  indent(ofs); ofs << "ulimit " << linfo.ulimit[0] << std::endl;
49  }
50  if (linfo.llimit.length()){
51  indent(ofs); ofs << "llimit " << linfo.llimit[0] << std::endl;
52  }
53  if (linfo.uvlimit.length()){
54  indent(ofs); ofs << "uvlimit " << linfo.uvlimit[0] << std::endl;
55  }
56  if (linfo.lvlimit.length()){
57  indent(ofs); ofs << "lvlimit " << linfo.lvlimit[0] << std::endl;
58  }
59  if (linfo.gearRatio != 1){
60  indent(ofs); ofs << "gearRatio " << linfo.gearRatio << std::endl;
61  }
62  if (linfo.rotorInertia){
63  indent(ofs); ofs << "rotorInertia " << linfo.rotorInertia << std::endl;
64  }
65  if (linfo.rotorResistor){
66  indent(ofs); ofs << "rotorResistor " << linfo.rotorResistor << std::endl;
67  }
68  if (linfo.torqueConst != 1){
69  indent(ofs); ofs << "torqueConst " << linfo.torqueConst << std::endl;
70  }
71  if (linfo.encoderPulse != 1){
72  indent(ofs); ofs << "encoderPulse " << linfo.encoderPulse << std::endl;
73  }
74  indent(ofs); ofs << "children [" << std::endl;
75  m_indent += 2;
76  if (linfo.segments.length() > 0) {
77  indent(ofs); ofs << "DEF " << linfo.segments[0].name << " Segment {" << std::endl;
78  } else {
79  indent(ofs); ofs << "DEF " << linfo.name << "_s Segment {" << std::endl;
80  }
81  m_indent += 2;
82  indent(ofs); ofs << "mass " << linfo.mass << std::endl;
83  indent(ofs); ofs << "centerOfMass " << linfo.centerOfMass[0] << " "
84  << linfo.centerOfMass[1] << " "
85  << linfo.centerOfMass[2] << std::endl;
86  indent(ofs); ofs << "momentsOfInertia [";
87  for (size_t i=0; i<9; i++) ofs << linfo.inertia[i] << " ";
88  ofs << "]" << std::endl;
89  indent(ofs); ofs << "children [" << std::endl;
90  m_indent +=2;
91  TransformedShapeIndexSequence &tsis = linfo.shapeIndices;
92  if (m_use_inline_shape) {
93  std::string fname ( linfo.segments.length() > 0?linfo.segments[0].name:linfo.name );
94  fname += ".wrl";
95  indent(ofs); ofs << "Inline { url \"" << fname << "\" }" << std::endl;
96  std::ofstream sofs(fname.c_str());
97  for (size_t i=0; i<tsis.length(); i++){
98  writeShape(tsis[i], sofs);
99  }
100  sofs.close();
101  } else {
102  for (size_t i=0; i<tsis.length(); i++){
103  writeShape(tsis[i], ofs);
104  }
105  }
106  for (size_t i=0; i<linfo.sensors.length(); i++){
107  SensorInfo &si = linfo.sensors[i];
108  std::string type = (const char *)si.type;
109  indent(ofs); ofs << "DEF " << si.name << " ";
110  if (type == "Force"){
111  ofs << "ForceSensor{" << std::endl;
112  }else if (type == "RateGyro"){
113  ofs << "Gyro{" << std::endl;
114  }else if (type == "Acceleration"){
115  ofs << "AccelerationSensor{" << std::endl;
116  }else if (type == "Vision"){
117  ofs << "VisionSensor{" << std::endl;
118  }else if (type == "Range"){
119  ofs << "RangeSensor{" << std::endl;
120  }else{
121  std::cerr << "unknown sensor type(" << type << ")" << std::endl;
122  }
123  m_indent += 2;
124  indent(ofs); ofs << "translation " << si.translation[0] << " "
125  << si.translation[1] << " " << si.translation[2]
126  << std::endl;
127  indent(ofs); ofs << "rotation " << si.rotation[0] << " "
128  << si.rotation[1] << " " << si.rotation[2] << " "
129  << si.rotation[3] << std::endl;
130  indent(ofs); ofs << "sensorId " << si.id << std::endl;
131  if (si.shapeIndices.length()){
132  indent(ofs); ofs << "children[" << std::endl;
133  m_indent += 2;
134  if (m_use_inline_shape) {
135  std::string fname (si.name);
136  fname += ".wrl";
137  indent(ofs); ofs << "inline {url \"" << fname << "\" }" << std::endl;
138  std::ofstream sofs( fname.c_str() );
139  for (size_t j=0; j<si.shapeIndices.length(); j++){
140  writeShape(si.shapeIndices[j], sofs);
141  }
142  sofs.close();
143  } else {
144  for (size_t j=0; j<si.shapeIndices.length(); j++){
145  writeShape(si.shapeIndices[j], ofs);
146  }
147  }
148  m_indent -= 2;
149  indent(ofs); ofs << "]" << std::endl;
150  }
151  m_indent -= 2;
152  indent(ofs); ofs << "} #Sensor" << std::endl;
153  }
154  m_indent -=2;
155  indent(ofs); ofs << "]" << std::endl;
156  m_indent -= 2;
157  if (linfo.segments.length() > 0) {
158  indent(ofs); ofs << "} #Segment " << linfo.segments[0].name << std::endl;
159  } else {
160  indent(ofs); ofs << "} #Segment " << linfo.name << "_s" << std::endl;
161  }
162  for (size_t i=0; i<linfo.childIndices.length(); i++){
163  writeLink(linfo.childIndices[i], ofs);
164  }
165  m_indent -= 2;
166  indent(ofs); ofs << "]" << std::endl;
167  m_indent -= 2;
168  indent(ofs); ofs << "} #Joint " << linfo.name << std::endl;
169 }
170 
171 void VrmlWriter::writeShape(TransformedShapeIndex &tsi, std::ostream &ofs)
172 {
173  indent(ofs); ofs << "Transform {" << std::endl;
174  m_indent += 2;
175  if (tsi.transformMatrix[3] || tsi.transformMatrix[7] || tsi.transformMatrix[11]){
176  indent(ofs); ofs << "translation " << tsi.transformMatrix[3] << " "
177  << tsi.transformMatrix[7] << " "
178  << tsi.transformMatrix[11] << " " << std::endl;
179  }
180  Vector3 xaxis, yaxis, zaxis;
181  xaxis << tsi.transformMatrix[0],tsi.transformMatrix[4],tsi.transformMatrix[8];
182  yaxis << tsi.transformMatrix[1],tsi.transformMatrix[5],tsi.transformMatrix[9];
183  zaxis << tsi.transformMatrix[2],tsi.transformMatrix[6],tsi.transformMatrix[10];
184  indent(ofs); ofs << "scale " << xaxis.norm() << " " << yaxis.norm() << " " << zaxis.norm() << std::endl;
185  xaxis.normalize();
186  yaxis.normalize();
187  zaxis.normalize();
188  Matrix33 R;
189  R << xaxis[0], yaxis[0], zaxis[0],
190  xaxis[1], yaxis[1], zaxis[1],
191  xaxis[2], yaxis[2], zaxis[2];
192  Vector3 omega = omegaFromRot(R);
193  double th = omega.norm();
194  Vector3 axis = omega/th;
195  if (th){
196  indent(ofs); ofs << "rotation " << axis[0] << " " << axis[1] << " "
197  << axis[2] << " " << th << std::endl;
198  }
199  indent(ofs); ofs << "children [" << std::endl;
200  m_indent += 2;
201  indent(ofs); ofs << "Shape {" << std::endl;
202  m_indent += 2;
203  ShapeInfo &si = shapes[tsi.shapeIndex];
204  AppearanceInfo &app = appearances[si.appearanceIndex];
205  switch(si.primitiveType){
206  case SP_MESH:
207  indent(ofs); ofs << "geometry IndexedFaceSet{" << std::endl;
208  m_indent += 2;
209  indent(ofs); ofs << "coord Coordinate{" << std::endl;
210  m_indent += 2;
211  indent(ofs); ofs << "point[" << std::endl;
212  for (size_t i=0; i<si.vertices.length()/3; i++){
213  indent(ofs); ofs << " " << si.vertices[i*3] << " "
214  << si.vertices[i*3+1] << " " << si.vertices[i*3+2]
215  << std::endl;
216  }
217  indent(ofs); ofs << "]" << std::endl;
218  m_indent -= 2;
219  indent(ofs); ofs << "} #Coordinates" << std::endl;
220  indent(ofs); ofs << "coordIndex [" << std::endl;
221  for (size_t i=0; i<si.triangles.length()/3; i++){
222  indent(ofs); ofs << " " << si.triangles[i*3] << ","
223  << si.triangles[i*3+1] << ","
224  << si.triangles[i*3+2] << ", -1," << std::endl;
225  }
226  indent(ofs); ofs << "]" << std::endl;
227  indent(ofs); ofs << "normal Normal{" << std::endl;
228  m_indent += 2;
229  indent(ofs); ofs << "vector [" << std::endl;
230  for (size_t i=0; i<app.normals.length()/3; i++){
231  indent(ofs); ofs << " " << app.normals[i*3] << " "
232  << app.normals[i*3+1] << " " << app.normals[i*3+2]
233  << "," << std::endl;
234  }
235  indent(ofs); ofs << "]" << std::endl;
236  m_indent -= 2;
237  indent(ofs); ofs << "} #Normal" << std::endl;
238  indent(ofs); ofs << "normalIndex [" << std::endl;
239  for (size_t i=0; i< app.normalIndices.length()/3; i++){
240  indent(ofs); ofs << " " << app.normalIndices[i*3] << ","
241  << app.normalIndices[i*3+1] << ","
242  << app.normalIndices[i*3+2] << ", -1,"
243  << std::endl;
244  }
245  indent(ofs); ofs << "]" << std::endl;
246  indent(ofs); ofs << "normalPerVertex " << (app.normalPerVertex ? "TRUE" : "FALSE") << std::endl;
247  indent(ofs); ofs << "solid " << (app.solid ? "TRUE" : "FALSE") << std::endl;
248  if (app.creaseAngle){
249  indent(ofs); ofs << "creaseAngle " << app.creaseAngle << std::endl;
250  }
251  if (app.colors.length()){
252  indent(ofs); ofs << "color Color{" << std::endl;
253  indent(ofs); ofs << " color " << app.colors[0] << " " << app.colors[1] << " " << app.colors[2] << std::endl;;
254  indent(ofs); ofs << "}" << std::endl;
255  }
256  if (app.colorIndices.length()){
257  indent(ofs); ofs << "colorIndex [" << std::endl;
258  m_indent += 2;
259  for (size_t j=0; j<app.colorIndices.length(); j++){
260  ofs << app.colorIndices[j] << ",";
261  }
262  ofs << std::endl;
263  m_indent -= 2;
264  indent(ofs); ofs << "]" << std::endl;
265  }
266  indent(ofs); ofs << "colorPerVertex " << (app.colorPerVertex ? "TRUE" : "FALSE") << std::endl;
267  if (app.textureCoordinate.length()){
268  indent(ofs); ofs << "texCoord TextureCoordinate {" << std::endl;
269  m_indent += 2;
270  indent(ofs); ofs <<"point [" << std::endl;
271  m_indent += 2;
272  for (size_t j=0; j<app.textureCoordinate.length()/2; j++){
273  indent(ofs); ofs << app.textureCoordinate[j*2] << " "
274  << app.textureCoordinate[j*2+1] << ","
275  << std::endl;
276  }
277  m_indent -= 2;
278  indent(ofs); ofs << "]" << std::endl;
279  m_indent -= 2;
280  indent(ofs); ofs << "}" << std::endl;
281  }
282  if (app.textureCoordIndices.length()){
283  indent(ofs); ofs << "texCoordIndex [" << std::endl;
284  m_indent += 2;
285  for (size_t j=0; j<app.textureCoordIndices.length()/3; j++){
286  indent(ofs); ofs << app.textureCoordIndices[j*3] << ","
287  << app.textureCoordIndices[j*3+1] << ","
288  << app.textureCoordIndices[j*3+2] << ",-1," << std::endl;
289 
290  }
291  m_indent -= 2;
292  indent(ofs); ofs << "]" << std::endl;
293  }
294  //
295  m_indent -= 2;
296  indent(ofs); ofs << "} #IndexedFaceSet" << std::endl;
297  break;
298  case SP_BOX:
299  indent(ofs); ofs << "geometry Box{" << std::endl;
300  indent(ofs); ofs << " size " << si.primitiveParameters[0] << " "
301  << si.primitiveParameters[1] << " "
302  << si.primitiveParameters[2] << std::endl;
303  indent(ofs); ofs << "}" << std::endl;
304  break;
305  case SP_CYLINDER:
306  indent(ofs); ofs << "geometry Cylinder{" << std::endl;
307  indent(ofs); ofs << " radius " << si.primitiveParameters[0] << std::endl;
308  indent(ofs); ofs << " height " << si.primitiveParameters[1] << std::endl;
309  indent(ofs); ofs << " top " << (si.primitiveParameters[2] ? "TRUE" : "FALSE") << std::endl;
310  indent(ofs); ofs << " bottom " << (si.primitiveParameters[3] ? "TRUE" : "FALSE") << std::endl;
311  indent(ofs); ofs << " side " << (si.primitiveParameters[4] ? "TRUE" : "FALSE") << std::endl;
312  indent(ofs); ofs << "}" << std::endl;
313  break;
314  case SP_CONE:
315  indent(ofs); ofs << "geometry Cone {" << std::endl;
316  indent(ofs); ofs << " bottomRadius " << si.primitiveParameters[0] << std::endl;
317  indent(ofs); ofs << " height " << si.primitiveParameters[1] << std::endl;
318  indent(ofs); ofs << " bottom " << (si.primitiveParameters[2] ? "TRUE" : "FALSE") << std::endl;
319  indent(ofs); ofs << " side " << (si.primitiveParameters[3] ? "TRUE" : "FALSE") << std::endl;
320  indent(ofs); ofs << "}" << std::endl;
321  break;
322  case SP_SPHERE:
323  indent(ofs); ofs << "geometry Sphere {" << std::endl;
324  indent(ofs); ofs << " radius " << si.primitiveParameters[0] << std::endl;
325  indent(ofs); ofs << "}" << std::endl;
326  break;
327  case SP_PLANE:
328  indent(ofs); ofs << "geometry Plane{" << std::endl;
329  indent(ofs); ofs << " size " << si.primitiveParameters[0] << " "
330  << si.primitiveParameters[1] << " "
331  << si.primitiveParameters[2] << std::endl;
332  indent(ofs); ofs << "}" << std::endl;
333  break;
334  default:
335  std::cerr << "unknown primitive type:" << si.primitiveType << std::endl;
336  }
337  if (app.materialIndex >= 0){
338  MaterialInfo &mat = materials[app.materialIndex];
339  indent(ofs); ofs << "appearance Appearance{" << std::endl;
340  m_indent += 2;
341  indent(ofs); ofs << "material Material{" << std::endl;
342  m_indent += 2;
343  indent(ofs); ofs << "ambientIntensity " << mat.ambientIntensity
344  << std::endl;
345  indent(ofs); ofs << "diffuseColor " << mat.diffuseColor[0] << " "
346  << mat.diffuseColor[1] << " " << mat.diffuseColor[2]
347  << std::endl;
348  indent(ofs); ofs << "emissiveColor " << mat.emissiveColor[0] << " "
349  << mat.emissiveColor[1] << " "
350  << mat.emissiveColor[2] << std::endl;
351  indent(ofs); ofs << "shininess " << mat.shininess << std::endl;
352  indent(ofs); ofs << "specularColor " << mat.specularColor[0] << " "
353  << mat.specularColor[1] << " "
354  << mat.specularColor[2] << std::endl;
355  indent(ofs); ofs << "transparency " << mat.transparency << std::endl;
356  m_indent -= 2;
357  indent(ofs); ofs << "} #Material" << std::endl;
358  if (app.textureIndex >= 0){
359  TextureInfo &ti = textures[app.textureIndex];
360  indent(ofs); ofs << "texture ImageTexture{" << std::endl;
361  indent(ofs); ofs << " repeatS " << (ti.repeatS ? "TRUE" : "FALSE")
362  << std::endl;
363  indent(ofs); ofs << " repeatT " << (ti.repeatT ? "TRUE" : "FALSE")
364  << std::endl;
365  indent(ofs); ofs << " url \"" << ti.url << "\"" << std::endl;
366  indent(ofs); ofs << "}" << std::endl;
367  indent(ofs); ofs << "textureTransform TextureTransform{" << std::endl;
368  m_indent += 2;
369  // TODO:textransformMatrix
370  m_indent -= 2;
371  indent(ofs); ofs << "}" << std::endl;
372  }
373  //
374  m_indent -= 2;
375  indent(ofs); ofs << "} #Appearance" << std::endl;
376  }
377  m_indent -= 2;
378  indent(ofs); ofs << "} #Shape" << std::endl;
379  m_indent -= 2;
380  indent(ofs); ofs << "]" << std::endl;
381  m_indent -= 2;
382  indent(ofs); ofs << "} #Transform" << std::endl;
383 }
384 void VrmlWriter::writeHumanoidNode(OpenHRP::BodyInfo_var binfo,
385  std::ostream &ofs)
386 {
387  ofs << "DEF " << binfo->name() << " Humanoid {" << std::endl;
388  ofs << " humanoidBody [" << std::endl;
389  links = binfo->links();
390  shapes = binfo->shapes();
391  appearances = binfo->appearances();
392  materials = binfo->materials();
393  textures = binfo->textures();
394  m_indent = 4;
395  writeLink(0, ofs);
396  ofs << " ]" << std::endl;
397  ofs << " joints [" << std::endl;
398  for (size_t i=0; i<links->length(); i++){
399  ofs << " USE " << links[i].name << "," << std::endl;
400  }
401  ofs << " ]" << std::endl;
402  ofs << " segments [" << std::endl;
403  for (size_t i=0; i<links->length(); i++){
404  if (links[i].segments.length() > 0) {
405  ofs << " USE " << links[i].segments[0].name << "," << std::endl;
406  } else {
407  ofs << " USE " << links[i].name << "_s," << std::endl;
408  }
409  }
410  ofs << " ]" << std::endl;
411  ofs << " name \"" << binfo->name() << "\"" << std::endl;
412  ofs << " info [" << std::endl;
413  StringSequence_var info = binfo->info();
414  for (size_t i=0; i<info->length(); i++){
415  ofs << " \"" << info[i] << "\"" << std::endl;
416  }
417  ofs << " ]" << std::endl;
418  ofs << "}" << std::endl;
419 }
420 
421 void VrmlWriter::writeProtoNodes(std::ostream &ofs)
422 {
423  ofs << "#VRML V2.0 utf8" << std::endl;
424  ofs << "" << std::endl;
425  ofs << "PROTO Joint [" << std::endl;
426  ofs << " exposedField SFVec3f center 0 0 0" << std::endl;
427  ofs << " exposedField MFNode children []" << std::endl;
428  ofs << " exposedField MFFloat llimit []" << std::endl;
429  ofs << " exposedField MFFloat lvlimit []" << std::endl;
430  ofs << " exposedField SFRotation limitOrientation 0 0 1 0" << std::endl;
431  ofs << " exposedField SFString name \"\"" << std::endl;
432  ofs << " exposedField SFRotation rotation 0 0 1 0" << std::endl;
433  ofs << " exposedField SFVec3f scale 1 1 1" << std::endl;
434  ofs << " exposedField SFRotation scaleOrientation 0 0 1 0" << std::endl;
435  ofs << " exposedField MFFloat stiffness [ 0 0 0 ]" << std::endl;
436  ofs << " exposedField SFVec3f translation 0 0 0" << std::endl;
437  ofs << " exposedField MFFloat ulimit []" << std::endl;
438  ofs << " exposedField MFFloat uvlimit []" << std::endl;
439  ofs << " exposedField SFString jointType \"\"" << std::endl;
440  ofs << " exposedField SFInt32 jointId -1" << std::endl;
441  ofs << " exposedField SFVec3f jointAxis 0 0 1" << std::endl;
442  ofs << "" << std::endl;
443  ofs << " exposedField SFFloat gearRatio 1" << std::endl;
444  ofs << " exposedField SFFloat rotorInertia 0" << std::endl;
445  ofs << " exposedField SFFloat rotorResistor 0" << std::endl;
446  ofs << " exposedField SFFloat torqueConst 1" << std::endl;
447  ofs << " exposedField SFFloat encoderPulse 1" << std::endl;
448  ofs << "]" << std::endl;
449  ofs << "{" << std::endl;
450  ofs << " Transform {" << std::endl;
451  ofs << " center IS center" << std::endl;
452  ofs << " children IS children" << std::endl;
453  ofs << " rotation IS rotation" << std::endl;
454  ofs << " scale IS scale" << std::endl;
455  ofs << " scaleOrientation IS scaleOrientation" << std::endl;
456  ofs << " translation IS translation" << std::endl;
457  ofs << " }" << std::endl;
458  ofs << "}" << std::endl;
459  ofs << "" << std::endl;
460  ofs << "PROTO Segment [" << std::endl;
461  ofs << " field SFVec3f bboxCenter 0 0 0" << std::endl;
462  ofs << " field SFVec3f bboxSize -1 -1 -1" << std::endl;
463  ofs << " exposedField SFVec3f centerOfMass 0 0 0" << std::endl;
464  ofs << " exposedField MFNode children [ ]" << std::endl;
465  ofs << " exposedField SFNode coord NULL" << std::endl;
466  ofs << " exposedField MFNode displacers [ ]" << std::endl;
467  ofs << " exposedField SFFloat mass 0 " << std::endl;
468  ofs << " exposedField MFFloat momentsOfInertia [ 0 0 0 0 0 0 0 0 0 ]" << std::endl;
469  ofs << " exposedField SFString name \"\"" << std::endl;
470  ofs << " eventIn MFNode addChildren" << std::endl;
471  ofs << " eventIn MFNode removeChildren" << std::endl;
472  ofs << "]" << std::endl;
473  ofs << "{" << std::endl;
474  ofs << " Group {" << std::endl;
475  ofs << " addChildren IS addChildren" << std::endl;
476  ofs << " bboxCenter IS bboxCenter" << std::endl;
477  ofs << " bboxSize IS bboxSize" << std::endl;
478  ofs << " children IS children" << std::endl;
479  ofs << " removeChildren IS removeChildren" << std::endl;
480  ofs << " }" << std::endl;
481  ofs << "}" << std::endl;
482  ofs << "" << std::endl;
483  ofs << "PROTO Humanoid [" << std::endl;
484  ofs << " field SFVec3f bboxCenter 0 0 0" << std::endl;
485  ofs << " field SFVec3f bboxSize -1 -1 -1" << std::endl;
486  ofs << " exposedField SFVec3f center 0 0 0" << std::endl;
487  ofs << " exposedField MFNode humanoidBody [ ]" << std::endl;
488  ofs << " exposedField MFString info [ ]" << std::endl;
489  ofs << " exposedField MFNode joints [ ]" << std::endl;
490  ofs << " exposedField SFString name \"\"" << std::endl;
491  ofs << " exposedField SFRotation rotation 0 0 1 0" << std::endl;
492  ofs << " exposedField SFVec3f scale 1 1 1" << std::endl;
493  ofs << " exposedField SFRotation scaleOrientation 0 0 1 0" << std::endl;
494  ofs << " exposedField MFNode segments [ ]" << std::endl;
495  ofs << " exposedField MFNode sites [ ]" << std::endl;
496  ofs << " exposedField SFVec3f translation 0 0 0" << std::endl;
497  ofs << " exposedField SFString version \"1.1\"" << std::endl;
498  ofs << " exposedField MFNode viewpoints [ ]" << std::endl;
499  ofs << "]" << std::endl;
500  ofs << "{" << std::endl;
501  ofs << " Transform {" << std::endl;
502  ofs << " bboxCenter IS bboxCenter" << std::endl;
503  ofs << " bboxSize IS bboxSize" << std::endl;
504  ofs << " center IS center" << std::endl;
505  ofs << " rotation IS rotation" << std::endl;
506  ofs << " scale IS scale" << std::endl;
507  ofs << " scaleOrientation IS scaleOrientation" << std::endl;
508  ofs << " translation IS translation" << std::endl;
509  ofs << " children [" << std::endl;
510  ofs << " Group {" << std::endl;
511  ofs << " children IS viewpoints" << std::endl;
512  ofs << " }" << std::endl;
513  ofs << " Group {" << std::endl;
514  ofs << " children IS humanoidBody " << std::endl;
515  ofs << " }" << std::endl;
516  ofs << " ]" << std::endl;
517  ofs << " }" << std::endl;
518  ofs << "}" << std::endl;
519  ofs << "" << std::endl;
520  ofs << "PROTO VisionSensor [" << std::endl;
521  ofs << " exposedField SFVec3f translation 0 0 0" << std::endl;
522  ofs << " exposedField SFRotation rotation 0 0 1 0" << std::endl;
523  ofs << " exposedField MFNode children [ ]" << std::endl;
524  ofs << " exposedField SFFloat fieldOfView 0.785398" << std::endl;
525  ofs << " exposedField SFString name \"\"" << std::endl;
526  ofs << " exposedField SFFloat frontClipDistance 0.01" << std::endl;
527  ofs << " exposedField SFFloat backClipDistance 10.0" << std::endl;
528  ofs << " exposedField SFString type \"NONE\"" << std::endl;
529  ofs << " exposedField SFInt32 sensorId -1" << std::endl;
530  ofs << " exposedField SFInt32 width 320" << std::endl;
531  ofs << " exposedField SFInt32 height 240" << std::endl;
532  ofs << " exposedField SFFloat frameRate 30" << std::endl;
533  ofs << "]" << std::endl;
534  ofs << "{" << std::endl;
535  ofs << " Transform {" << std::endl;
536  ofs << " rotation IS rotation" << std::endl;
537  ofs << " translation IS translation" << std::endl;
538  ofs << " children IS children" << std::endl;
539  ofs << " }" << std::endl;
540  ofs << "}" << std::endl;
541  ofs << "" << std::endl;
542  ofs << "" << std::endl;
543  ofs << "PROTO ForceSensor [ " << std::endl;
544  ofs << " exposedField SFVec3f maxForce -1 -1 -1" << std::endl;
545  ofs << " exposedField SFVec3f maxTorque -1 -1 -1" << std::endl;
546  ofs << " exposedField SFVec3f translation 0 0 0" << std::endl;
547  ofs << " exposedField SFRotation rotation 0 0 1 0" << std::endl;
548  ofs << " exposedField SFInt32 sensorId -1" << std::endl;
549  ofs << "]" << std::endl;
550  ofs << "{" << std::endl;
551  ofs << " Transform {" << std::endl;
552  ofs << " translation IS translation" << std::endl;
553  ofs << " rotation IS rotation" << std::endl;
554  ofs << " }" << std::endl;
555  ofs << "}" << std::endl;
556  ofs << "" << std::endl;
557  ofs << "PROTO Gyro [" << std::endl;
558  ofs << " exposedField SFVec3f maxAngularVelocity -1 -1 -1" << std::endl;
559  ofs << " exposedField SFVec3f translation 0 0 0" << std::endl;
560  ofs << " exposedField SFRotation rotation 0 0 1 0" << std::endl;
561  ofs << " exposedField SFInt32 sensorId -1" << std::endl;
562  ofs << "]" << std::endl;
563  ofs << "{" << std::endl;
564  ofs << " Transform {" << std::endl;
565  ofs << " translation IS translation" << std::endl;
566  ofs << " rotation IS rotation" << std::endl;
567  ofs << " }" << std::endl;
568  ofs << "}" << std::endl;
569  ofs << "" << std::endl;
570  ofs << "PROTO AccelerationSensor [" << std::endl;
571  ofs << " exposedField SFVec3f maxAcceleration -1 -1 -1" << std::endl;
572  ofs << " exposedField SFVec3f translation 0 0 0" << std::endl;
573  ofs << " exposedField SFRotation rotation 0 0 1 0" << std::endl;
574  ofs << " exposedField SFInt32 sensorId -1" << std::endl;
575  ofs << "]" << std::endl;
576  ofs << "{" << std::endl;
577  ofs << " Transform {" << std::endl;
578  ofs << " translation IS translation" << std::endl;
579  ofs << " rotation IS rotation" << std::endl;
580  ofs << " }" << std::endl;
581  ofs << "}" << std::endl;
582 }
void writeLink(int index, std::ostream &ofs)
png_infop png_charp png_int_32 png_int_32 int * type
Definition: png.h:2332
png_uint_32 i
Definition: png.h:2735
Eigen::Vector3d Vector3
Definition: EigenTypes.h:11
Eigen::Matrix3d Matrix33
Definition: EigenTypes.h:12
void writeHumanoidNode(OpenHRP::BodyInfo_var binfo, std::ostream &ofs)
def j(str, encoding="cp932")
backing_store_ptr info
Definition: jmemsys.h:181
std::string indent(int index)
void writeProtoNodes(std::ostream &ofs)
void useInlineShape(bool use_inline)
HRP_UTIL_EXPORT Vector3 omegaFromRot(const Matrix33 &r)
Definition: Eigen3d.cpp:63
void write(OpenHRP::BodyInfo_var binfo, std::ostream &ofs)
void writeShape(OpenHRP::TransformedShapeIndex &tsi, std::ostream &ofs)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat Apr 13 2019 02:14:26