00001 #include "X3DBoundedObject.h" 00002 00003 using namespace X3DTK; 00004 00005 X3DBoundedObject::X3DBoundedObject() 00006 : X3DObject(), bboxCenter_(SFVec3f(0.0f, 0.0f, 0.0f)), bboxSize_(SFVec3f(-1.0f, -1.0f, -1.0f)) 00007 { 00008 } 00009 00010 X3DBoundedObject::X3DBoundedObject(const SFVec3f &bboxCenter, const SFVec3f &bboxSize) 00011 : X3DObject(), bboxCenter_(bboxCenter), bboxSize_(bboxSize) 00012 { 00013 } 00014 00015 X3DBoundedObject::X3DBoundedObject(const X3DBoundedObject &N) 00016 : X3DObject(N), bboxCenter_(N.bboxCenter_), bboxSize_(N.bboxSize_) 00017 { 00018 } 00019 00020 X3DBoundedObject::~X3DBoundedObject() 00021 { 00022 } 00023 00024 void X3DBoundedObject::setBboxCenter(const SFVec3f &bboxCenter) 00025 { 00026 bboxCenter_ = bboxCenter; 00027 } 00028 00029 void X3DBoundedObject::setBboxSize(const SFVec3f &bboxSize) 00030 { 00031 bboxSize_ = bboxSize; 00032 } 00033 00034 void X3DBoundedObject::loadAttributes(const X3DFileElement *element) 00035 { 00036 int index; 00037 index = element->getIndexAttribute("bboxCenter"); 00038 if (index != -1) 00039 bboxCenter_ = SFVec3f(element->getAttribute(index)); 00040 00041 index = element->getIndexAttribute("bboxSize"); 00042 if (index != -1) 00043 bboxSize_ = SFVec3f(element->getAttribute(index)); 00044 } 00045 00046 SFString X3DBoundedObject::writeAttributes() const 00047 { 00048 SFString attr; 00049 if (bboxCenter_ != SFVec3f(0.0f, 0.0f, 0.0f)) 00050 attr += " bboxCenter=\"" + toSFString(bboxCenter_) + "\""; 00051 if (bboxSize_ != SFVec3f(-1.0f, -1.0f, -1.0f)) 00052 attr += " bboxSize=\"" + toSFString(bboxSize_) + "\""; 00053 00054 return attr; 00055 }