VrmlNodes.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 
14 #include "VrmlNodes.h"
15 
16 using namespace hrp;
17 
18 
20 {
21  switch(type){
22  case SFINT32: return "SFInt32";
23  case MFINT32: return "MFInt32";
24  case SFFLOAT: return "SFFloat";
25  case MFFLOAT: return "MFFloat";
26  case SFVEC2F: return "SFVec3f";
27  case MFVEC2F: return "MFVec2f";
28  case SFVEC3F: return "SFVec3f";
29  case MFVEC3F: return "MFVec3f";
30  case SFROTATION: return "SFRotation";
31  case MFROTATION: return "MFRotation";
32  case SFTIME: return "SFTime";
33  case MFTIME: return "MFTime";
34  case SFCOLOR: return "SFColor";
35  case MFCOLOR: return "MFColor";
36  case SFSTRING: return "SFString";
37  case MFSTRING: return "MFString";
38  case SFNODE: return "SFNode";
39  case MFNODE: return "MFNode";
40  case SFBOOL: return "SFBool";
41  case SFIMAGE: return "SFImage";
42  default: return "Unknown Field Type";
43  break;
44  }
45 }
46 
47 
49 {
50  refCounter = 0;
51 }
52 
53 
55 {
56 
57 }
58 
59 
61 {
62  return (category == ANY_NODE) ? true : categorySet.test(category);
63 }
64 
65 
66 
67 VrmlUnsupportedNode::VrmlUnsupportedNode(const std::string& nodeTypeName) :
68  nodeTypeName(nodeTypeName)
69 {
70  categorySet.set(TOP_NODE);
72 }
73 
74 
76 {
77  categorySet.set(TOP_NODE);
80 
81  fieldOfView = 0.785398;
82  jump = true;
83 
84  orientation[0] = orientation[1] = orientation[3] = 0.0;
85  orientation[2] = 1.0;
86 
87  position[0] = position[1] = 0.0;
88  position[2] = 10;
89 }
90 
91 
93  avatarSize(3)
94 {
95  categorySet.set(TOP_NODE);
98 
99  avatarSize[0] = 0.25;
100  avatarSize[1] = 1.6;
101  avatarSize[2] = 0.75;
102 
103  headlight = true;
104  speed = 1.0;
105  visibilityLimit = 0.0;
106 
107  type.push_back("WALK");
108 }
109 
110 
112 {
113  categorySet.set(TOP_NODE);
115  categorySet.set(CHILD_NODE);
116 }
117 
118 
120 {
121  categorySet.set(TOP_NODE);
123  categorySet.set(CHILD_NODE);
124 }
125 
126 
127 void AbstractVrmlGroup::removeChild(int childIndex)
128 {
129  replaceChild(childIndex, 0);
130 }
131 
132 
134 {
135  bboxCenter[0] = bboxCenter[1] = bboxCenter[2] = 0.0;
136  bboxSize[0] = bboxSize[1] = bboxSize[2] = -1;
137 }
138 
140 {
141  return children;
142 }
143 
145 {
146  return children.size();
147 }
148 
149 
151 {
152  return children[index].get();
153 }
154 
155 
156 void VrmlGroup::replaceChild(int childIndex, VrmlNode* childNode)
157 {
158  if(!childNode){
159  children.erase(children.begin() + childIndex);
160  } else {
161  children[childIndex] = childNode;
162  }
163 }
164 
165 
167 {
168  center[0] = center[1] = center[2] = 0.0;
169  rotation[0] = rotation[1] = rotation[3] = 0.0;
170  rotation[2] = 1.0;
171  scale[0] = scale[1] = scale[2] = 1.0;
172  scaleOrientation[0] = scaleOrientation[1] = scaleOrientation[3] = 0.0;
173  scaleOrientation[2] = 1.0;
174  translation[0] = translation[1] = translation[2] = 0.0;
175 }
176 
178 {
180 }
181 
183 {
184  categorySet.set(TOP_NODE);
185  categorySet.set(CHILD_NODE);
186  categorySet.set(SHAPE_NODE);
187 }
188 
189 
191 {
193 }
194 
195 
197 {
199 
200  diffuseColor [0] = diffuseColor [1] = diffuseColor [2] = 0.8;
201  emissiveColor[0] = emissiveColor[1] = emissiveColor[2] = 0.0;
202  specularColor[0] = specularColor[1] = specularColor[2] = 0.0;
203  ambientIntensity = 0.2;
204  shininess = 0.2;
205  transparency = 0.0;
206 }
207 
208 
210 {
212 }
213 
214 
216 {
217  repeatS = true;
218  repeatT = true;
219 }
220 
221 
223 {
225 
226  center[0] = center[1] = 0.0;
227  scale[0] = scale[1] = 1.0;
228  translation[0] = translation[1] = 0.0;
229  rotation = 0.0;
230 }
231 
232 
234 {
236 }
237 
238 
240 {
241  size[0] = size[1] = size[2] = 2.0;
242 }
243 
244 
246 {
247  bottom = true;
248  bottomRadius = 1.0;
249  height = 2.0;
250  side = true;
251 }
252 
253 
255 {
256  height = 2.0;
257  radius = 1.0;
258  bottom = true;
259  side = true;
260  top = true;
261 }
262 
263 
265 {
266  radius = 1.0;
267 }
268 
269 
271 {
273 
274  family.push_back("SERIF");
275  horizontal = true;
276  justify.push_back("BEGIN");
277  leftToRight = true;
278  size = 1.0;
279  spacing = 1.0;
280  style = "PLAIN";
281  topToBottom = true;
282 }
283 
284 
286 {
287  maxExtent = 0.0;
288 }
289 
290 
292 {
293  colorPerVertex = true;
294 }
295 
296 
298 {
299  ccw = true;
300  convex = true;
301  creaseAngle = 0.0;
302  normalPerVertex = true;
303  solid = true;
304 }
305 
306 
308 {
309  categorySet.set(COLOR_NODE);
310 }
311 
312 
314 {
316 }
317 
318 
320 {
322 }
323 
324 
326 {
328 }
329 
330 
332 {
333  categorySet.set(CHILD_NODE);
335 
336  autoOffset = true;
337  diskAngle = 0.262;
338  enabled = true;
339  maxAngle = -1;
340  minAngle = 0;
341  offset = 0;
342 }
343 
344 
345 
346 
347 // ##### VrmlPointSet()
349 {
350  coord = NULL;
351  color = NULL;
352 }
353 
354 
355 
356 // ##### VrmlPixelTexture()
358 {
359  image.width = 0;
360  image.height = 0;
361  image.numComponents = 0;
362  image.pixels.clear();
363 
364  repeatS = true;
365  repeatT = true;
366 }
367 
368 
369 
370 // ##### VrmlMovieTexture()
372 {
373  // url
374  loop = false;
375  speed = 0;
376  startTime = 0;
377  stopTime = 0;
378  repeatS = true;
379  repeatT = true;
380 }
381 
382 
383 
384 // ##### VrmlElevationGrid()
386 {
387  xDimension = 0;
388  zDimension = 0;
389  xSpacing = 0.0;
390  zSpacing = 0.0;
391  // height // MFFloat
392  ccw = true;
393  colorPerVertex = true;
394  creaseAngle = 0.0;
395  normalPerVertex = true;
396  solid = true;
397  color = NULL;
398  normal = NULL;
399  texCoord = NULL;
400 }
401 
402 
403 
404 // ##### VrmlExtrusion()
406 {
407  // crossSection
408  // spine
409  beginCap = true;
410  endCap = true;
411  solid = true;
412  ccw = true;
413  convex = true;
414  creaseAngle = 0;
415  SFRotation ori= {0,0,1,0};
416  orientation.push_back(ori);
417  SFVec2f sc ={ 1,1 };
418  scale.push_back(sc);
419 
420 }
421 
422 
424 {
425  whichChoice = -1;
426 }
427 
429 {
430  return choice;
431 }
432 
434 {
435  return choice.size();
436 }
437 
438 
440 {
441  return choice[index].get();
442 }
443 
444 
445 void VrmlSwitch::replaceChild(int childIndex, VrmlNode* childNode)
446 {
447  if(!childNode){
448  choice.erase(choice.begin() + childIndex);
449  if(whichChoice == childIndex){
450  whichChoice = -1;
451  } else if(whichChoice > childIndex){
452  whichChoice -= 1;
453  }
454  } else {
455  choice[childIndex] = childNode;
456  }
457 }
458 
459 
461 {
462  center[0] = center[1] = center[2] = 0.0;
463 }
464 
466 {
467  return level;
468 }
469 
471 {
472  return level.size();
473 }
474 
475 
477 {
478  return level[index].get();
479 }
480 
481 
482 void VrmlLOD::replaceChild(int childIndex, VrmlNode* childNode)
483 {
484  if(!childNode){
485  level.erase(level.begin() + childIndex);
486  if(!level.empty()){
487  int rangeIndexToRemove = (childIndex > 0) ? (childIndex - 1) : 0;
488  range.erase(range.begin() + rangeIndexToRemove);
489  }
490  } else {
491  level[childIndex] = childNode;
492  }
493 }
494 
495 
497 {
498  collide = true;
499 }
500 
501 
503 {
504 
505 }
506 
507 
509 {
510  axisOfRotation[0] = axisOfRotation[1] = axisOfRotation[3] = 0;
511 }
512 
513 
515 {
516  color[0] = color[1] = color[3] = 0.0f;
517  visibilityRange = 0.0f;
518  fogType = "LINEAR";
519 }
520 
521 
523 {
524  categorySet.set(TOP_NODE);
525 }
526 
527 
529 {
530  categorySet.set(TOP_NODE);
531  categorySet.set(CHILD_NODE);
532  categorySet.set(LIGHT_NODE);
533 
534  location[0] = location[1] = location[2] = 0.0f;
535  on = true;
536  intensity = 1.0f;
537  color[0] = color[1] = color[2] = 1.0f;
538  radius = 100.0f;
539  ambientIntensity = 0.0f;
540  attenuation[0] = 1;
541  attenuation[1] = attenuation[2] = 0;
542 }
543 
544 
546 {
547  categorySet.set(TOP_NODE);
548  categorySet.set(CHILD_NODE);
549  categorySet.set(LIGHT_NODE);
550 
551  ambientIntensity = 0.0f;
552  color[0] = color[1] = color[2] = 1.0f;
553  direction[0] = direction[1] = 0.0f;
554  direction[2] = -1.0f;
555  intensity = 1.0f;
556  on = true;
557 }
558 
559 
561 {
562  categorySet.set(TOP_NODE);
563  categorySet.set(CHILD_NODE);
564  categorySet.set(LIGHT_NODE);
565 
566  location[0] = location[1] = location[2] = 0.0f;
567  direction[0] = direction[1] = 0.0f;
568  direction[2] = -1.0f;
569  on = true;
570  color[0] = color[1] = color[2] = 1.0f;
571  intensity = 1.0f;
572  radius = 100.0f;
573  ambientIntensity = 0.0f;
574  attenuation[0] = 1.0f;
575  attenuation[1] = attenuation[2] = 0.0f;
576  beamWidth = 1.570796f;
577  cutOffAngle = 0.785398f;
578 }
579 
580 
581 
583 {
584  typeId_ = UNDETERMINED_FIELD_TYPE;
585  valueObj = 0;
586  setType(initialTypeId);
587 }
588 
590 {
591  typeId_ = UNDETERMINED_FIELD_TYPE;
592  valueObj = 0;
593 }
594 
596 {
597  valueObj = 0;
598  copy(org);
599 }
600 
602 {
603  deleteObj();
604  copy(org);
605  return *this;
606 }
607 
609 {
610  typeId_ = org.typeId_;
611 
612  if(!org.valueObj){
613  v = org.v;
614  } else {
615  switch(typeId_){
616  case MFINT32: valueObj = new MFInt32(*((MFInt32*)org.valueObj)); break;
617  case MFFLOAT: valueObj = new MFFloat(*((MFFloat*)org.valueObj)); break;
618  case MFVEC2F: valueObj = new MFVec2f(*((MFVec2f*)org.valueObj)); break;
619  case MFVEC3F: valueObj = new MFVec3f(*((MFVec3f*)org.valueObj)); break;
620  case MFROTATION: valueObj = new MFRotation(*((MFRotation*)org.valueObj)); break;
621  case MFTIME: valueObj = new MFTime(*((MFTime*)org.valueObj)); break;
622  case MFCOLOR: valueObj = new MFColor(*((MFColor*)org.valueObj)); break;
623  case SFSTRING: valueObj = new SFString(*((SFString*)org.valueObj)); break;
624  case MFSTRING: valueObj = new MFString(*((MFString*)org.valueObj)); break;
625  case SFNODE: valueObj = new SFNode(*((SFNode*)org.valueObj)); break;
626  case MFNODE: valueObj = new MFNode(*((MFNode*)org.valueObj)); break;
627  case SFIMAGE: valueObj = new SFImage(*((SFImage*)org.valueObj)); break;
628  default:
629  break;
630  }
631  }
632 }
633 
634 
637 {
638  if(typeId_ == UNDETERMINED_FIELD_TYPE){
639  typeId_ = typeId0;
640 
641  switch(typeId_){
642  case MFINT32: valueObj = new MFInt32; break;
643  case MFFLOAT: valueObj = new MFFloat; break;
644  case MFVEC2F: valueObj = new MFVec2f; break;
645  case MFVEC3F: valueObj = new MFVec3f; break;
646  case MFROTATION: valueObj = new MFRotation; break;
647  case MFTIME: valueObj = new MFTime; break;
648  case MFCOLOR: valueObj = new MFColor; break;
649  case SFSTRING: valueObj = new SFString; break;
650  case MFSTRING: valueObj = new MFString; break;
651  case SFNODE: valueObj = new SFNode; break;
652  case MFNODE: valueObj = new MFNode; break;
653  case SFIMAGE: valueObj = new SFImage; break;
654  default:
655  break;
656  }
657  }
658 }
659 
660 
662 {
663  if(valueObj){
664  switch(typeId_){
665  case MFINT32: delete (MFInt32*)valueObj; break;
666  case MFFLOAT: delete (MFFloat*)valueObj; break;
667  case MFVEC2F: delete (MFVec2f*)valueObj; break;
668  case MFVEC3F: delete (MFVec3f*)valueObj; break;
669  case MFROTATION: delete (MFRotation*)valueObj; break;
670  case MFTIME: delete (MFTime*)valueObj; break;
671  case MFCOLOR: delete (MFColor*)valueObj; break;
672  case SFSTRING: delete (SFString*)valueObj; break;
673  case MFSTRING: delete (MFString*)valueObj; break;
674  case SFNODE: delete (SFNode*)valueObj; break;
675  case MFNODE: delete (MFNode*)valueObj; break;
676  case SFIMAGE: delete (SFImage*)valueObj; break;
677  default:
678  break;
679  }
680  valueObj = 0;
681  }
682 }
683 
684 
686 {
687  deleteObj();
688 }
689 
690 
691 VrmlProto::VrmlProto(const std::string& n) : protoName(n)
692 {
693  categorySet.set(TOP_NODE);
695 }
696 
697 
699  proto(proto0),
700  fields(proto0->fields)
701 {
702  categorySet.set(TOP_NODE);
704  categorySet.set(CHILD_NODE);
705 }
std::vector< SFNode > MFNode
Definition: VrmlNodes.h:158
std::vector< SFFloat > MFFloat
Definition: VrmlNodes.h:70
union hrp::VrmlVariantField::@8 v
virtual VrmlNode * getChild(int index)
Definition: VrmlNodes.cpp:476
std::vector< SFColor > MFColor
Definition: VrmlNodes.h:76
png_infop png_charp png_int_32 png_int_32 int * type
Definition: png.h:2332
VrmlVariantField & operator=(const VrmlVariantField &org)
Definition: VrmlNodes.cpp:601
virtual ~VrmlNode()
Definition: VrmlNodes.cpp:54
Abstract base class of all vrml nodes.
Definition: VrmlNodes.h:121
VrmlFieldTypeId typeId_
Definition: VrmlNodes.h:814
virtual MFNode & getChildren()
Definition: VrmlNodes.cpp:139
png_uint_32 size
Definition: png.h:1521
static const char * getLabelOfFieldType(int type)
Definition: VrmlNodes.cpp:19
void copy(const VrmlVariantField &org)
Definition: VrmlNodes.cpp:608
virtual void replaceChild(int childIndex, VrmlNode *childNode)
Definition: VrmlNodes.cpp:156
VrmlUnsupportedNode(const std::string &nodeTypeName)
Definition: VrmlNodes.cpp:67
virtual void replaceChild(int childIndex, VrmlNode *childNode)
Definition: VrmlNodes.cpp:445
virtual int countChildren()
Definition: VrmlNodes.cpp:144
png_bytepp image
Definition: png.h:1772
virtual void replaceChild(int childIndex, VrmlNode *childNode)
Definition: VrmlNodes.cpp:482
VrmlProto(const std::string &n)
Definition: VrmlNodes.cpp:691
bool isCategoryOf(VrmlNodeCategory category)
Definition: VrmlNodes.cpp:60
std::string SFString
Definition: VrmlNodes.h:52
virtual int countChildren()
Definition: VrmlNodes.cpp:433
boost::intrusive_ptr< VrmlProto > VrmlProtoPtr
Definition: VrmlNodes.h:879
png_infop png_uint_32 png_uint_32 * height
Definition: png.h:2309
virtual VrmlNode * getChild(int index)
Definition: VrmlNodes.cpp:150
virtual int countChildren()
Definition: VrmlNodes.cpp:470
std::vector< SFRotation > MFRotation
Definition: VrmlNodes.h:74
VrmlNodeCategory
Definition: VrmlNodes.h:81
std::vector< SFVec3f > MFVec3f
Definition: VrmlNodes.h:72
boost::array< SFFloat, 2 > SFVec2f
Definition: VrmlNodes.h:54
void setType(VrmlFieldTypeId typeId0)
This can be called once.
Definition: VrmlNodes.cpp:636
void removeChild(int childIndex)
Definition: VrmlNodes.cpp:127
VrmlProtoInstance(VrmlProtoPtr proto0)
Definition: VrmlNodes.cpp:698
png_infop int int location
Definition: png.h:2487
std::vector< SFVec2f > MFVec2f
Definition: VrmlNodes.h:71
virtual VrmlNode * getChild(int index)
Definition: VrmlNodes.cpp:439
TProtoFieldMap fields
Definition: VrmlNodes.h:863
std::bitset< NUM_VRML_NODE_CATEGORIES > categorySet
Definition: VrmlNodes.h:135
virtual MFNode & getChildren()
Definition: VrmlNodes.cpp:465
SFVec4f SFRotation
Definition: VrmlNodes.h:59
std::vector< SFString > MFString
Definition: VrmlNodes.h:77
int level
Definition: png.h:1926
std::vector< SFInt32 > MFInt32
Definition: VrmlNodes.h:69
virtual MFNode & getChildren()
Definition: VrmlNodes.cpp:428
VrmlFieldTypeId
Definition: VrmlNodes.h:33
VrmlNodePtr SFNode
Definition: VrmlNodes.h:157
std::vector< SFTime > MFTime
Definition: VrmlNodes.h:75


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