00001 #include "Sphere.h" 00002 00003 using namespace X3DTK; 00004 00005 Sphere::Sphere() 00006 : X3DGeometry3DNode(), radius_(1.0f) 00007 { 00008 defineTagName("Sphere", "Geometry3D"); 00009 } 00010 00011 Sphere::Sphere(SFFloat radius) 00012 : X3DGeometry3DNode(), radius_(radius) 00013 { 00014 defineTagName("Sphere", "Geometry3D"); 00015 } 00016 00017 Sphere::Sphere(const Sphere &C) 00018 : X3DGeometry3DNode(C), radius_(C.radius_) 00019 { 00020 defineTagName("Sphere", "Geometry3D"); 00021 } 00022 00023 SFNode Sphere::clone() const 00024 { 00025 return new Sphere(*this); 00026 } 00027 00028 Sphere::~Sphere() 00029 { 00030 } 00031 00032 void Sphere::setRadius(SFFloat radius) 00033 { 00034 radius_ = radius; 00035 } 00036 00037 void Sphere::loadAttributes(const X3DFileElement *element) 00038 { 00039 int index; 00040 index = element->getIndexAttribute("radius"); 00041 if (index != -1) 00042 radius_ = element->getAttribute(index).toFloat(); 00043 } 00044 00045 SFString Sphere::writeAttributes() const 00046 { 00047 SFString attr; 00048 if (radius_ != 1.0f) 00049 attr += " radius=\"" + toSFString(radius_) + "\""; 00050 00051 return attr; 00052 }