00001
00002
00003 #include "Iguana/Inventor/interface/IgSoSphereHit.h"
00004 #include <Inventor/nodes/SoSphere.h>
00005 #include <Inventor/nodes/SoTransform.h>
00006
00007
00008
00009
00010
00011
00012
00013
00014 SO_KIT_SOURCE (IgSoSphereHit);
00015
00016
00017
00018
00019
00020 void
00021 IgSoSphereHit::initClass (void)
00022 { SO_KIT_INIT_CLASS (IgSoSphereHit, IgSoShapeKit, "IgSoShapeKit"); }
00023
00024 IgSoSphereHit::IgSoSphereHit (void)
00025 {
00026 SO_KIT_CONSTRUCTOR (IgSoSphereHit);
00027 SO_KIT_ADD_FIELD (scale, (1.0));
00028 SO_KIT_ADD_FIELD (energy, (1.0));
00029 SO_KIT_ADD_FIELD (centre, (0.0, 0.0, 0.0));
00030 SO_KIT_ADD_CATALOG_ENTRY (transform, SoTransform, FALSE, separator,\x0, TRUE);
00031 SO_KIT_ADD_CATALOG_ENTRY (sphere, SoSphere, FALSE, separator,\x0, TRUE);
00032 SO_KIT_INIT_INSTANCE ();
00033 setUpConnections (true, true);
00034 }
00035
00036 void
00037 IgSoSphereHit::refresh (void)
00038 {
00039 if (energy.getValue () < 0)
00040 {
00041 setPart ("transform", NULL);
00042 setPart ("sphere", NULL);
00043 return;
00044 }
00045
00046
00047 SoTransform *transform = new SoTransform;
00048 SoSphere *sphere = new SoSphere;
00049
00050
00051 sphere->radius = sqrt (energy.getValue ()) * scale.getValue ();
00052 transform->translation = centre;
00053
00054 setPart ("transform", transform);
00055 setPart ("sphere", sphere);
00056 }