// SpotLightP.C: SpotLight nodes (private source).
// Automatically generated with nodegen 0.5a - do not edit.

#include "SpotLight.H"
#include "xrmlP.H"

namespace xrml {
int SpotLight::major_version(void) { return 0; }
int SpotLight::minor_version(void) { return 5; }
bool SpotLight::is_leaf_class(void) { return true; }

bool IsSpotLight(SFNode* node)
{
  return (dynamic_cast<SpotLight*>(node) != 0);
}

bool SpotLight::assign_ambientIntensity(const SFFloat& value)
{
  // TODO: value range check!
  ambientIntensity = value;
  status |= ambientIntensity_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_ambientIntensity(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_ambientIntensity", "called for a non-SpotLight node");
  return SpotLight_node->assign_ambientIntensity((const SFFloat&)value);
}

void SpotLight::set_ambientIntensity(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool SpotLight::assign_attenuation(const SFVec3f& value)
{
  // TODO: value range check!
  attenuation = value;
  status |= attenuation_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_attenuation(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_attenuation", "called for a non-SpotLight node");
  return SpotLight_node->assign_attenuation((const SFVec3f&)value);
}

void SpotLight::set_attenuation(const SFVec3f& val)
{
  SFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

bool SpotLight::assign_beamWidth(const SFFloat& value)
{
  // TODO: value range check!
  beamWidth = value;
  status |= beamWidth_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_beamWidth(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_beamWidth", "called for a non-SpotLight node");
  return SpotLight_node->assign_beamWidth((const SFFloat&)value);
}

void SpotLight::set_beamWidth(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

bool SpotLight::assign_color(const SFColor& value)
{
  // TODO: value range check!
  color = value;
  status |= color_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_color(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_color", "called for a non-SpotLight node");
  return SpotLight_node->assign_color((const SFColor&)value);
}

void SpotLight::set_color(const SFColor& val)
{
  SFColor tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

bool SpotLight::assign_cutOffAngle(const SFFloat& value)
{
  // TODO: value range check!
  cutOffAngle = value;
  status |= cutOffAngle_updated;
  timestamp = interface[4]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_cutOffAngle(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_cutOffAngle", "called for a non-SpotLight node");
  return SpotLight_node->assign_cutOffAngle((const SFFloat&)value);
}

void SpotLight::set_cutOffAngle(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[4]->assign(this, v);
}

bool SpotLight::assign_direction(const SFVec3f& value)
{
  // TODO: value range check!
  direction = value;
  status |= direction_updated;
  timestamp = interface[5]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_direction(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_direction", "called for a non-SpotLight node");
  return SpotLight_node->assign_direction((const SFVec3f&)value);
}

void SpotLight::set_direction(const SFVec3f& val)
{
  SFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[5]->assign(this, v);
}

bool SpotLight::assign_intensity(const SFFloat& value)
{
  // TODO: value range check!
  intensity = value;
  status |= intensity_updated;
  timestamp = interface[6]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_intensity(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_intensity", "called for a non-SpotLight node");
  return SpotLight_node->assign_intensity((const SFFloat&)value);
}

void SpotLight::set_intensity(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[6]->assign(this, v);
}

bool SpotLight::assign_location(const SFVec3f& value)
{
  // TODO: value range check!
  location = value;
  status |= location_updated;
  timestamp = interface[7]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_location(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_location", "called for a non-SpotLight node");
  return SpotLight_node->assign_location((const SFVec3f&)value);
}

void SpotLight::set_location(const SFVec3f& val)
{
  SFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[7]->assign(this, v);
}

bool SpotLight::assign_on(const SFBool& value)
{
  // TODO: value range check!
  on = value;
  status |= on_updated;
  timestamp = interface[8]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_on(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_on", "called for a non-SpotLight node");
  return SpotLight_node->assign_on((const SFBool&)value);
}

void SpotLight::set_on(const SFBool& val)
{
  SFBool tmpval(val);
  fieldValue v(&tmpval);
  interface[8]->assign(this, v);
}

bool SpotLight::assign_radius(const SFFloat& value)
{
  // TODO: value range check!
  radius = value;
  status |= radius_updated;
  timestamp = interface[9]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SpotLight_radius(SFNode* node, const fieldValue& value)
{
  SpotLight* SpotLight_node = dynamic_cast<SpotLight*>(node);
  if (!SpotLight_node)
    Fatal(-1, "assign_SpotLight_radius", "called for a non-SpotLight node");
  return SpotLight_node->assign_radius((const SFFloat&)value);
}

void SpotLight::set_radius(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[9]->assign(this, v);
}

SpotLight::SpotLight()
{
  interfaceMember* the_interface[10] = {
    new exposedField("ambientIntensity", fieldValue(&ambientIntensity), assign_SpotLight_ambientIntensity),
    new exposedField("attenuation", fieldValue(&attenuation), assign_SpotLight_attenuation),
    new exposedField("beamWidth", fieldValue(&beamWidth), assign_SpotLight_beamWidth),
    new exposedField("color", fieldValue(&color), assign_SpotLight_color),
    new exposedField("cutOffAngle", fieldValue(&cutOffAngle), assign_SpotLight_cutOffAngle),
    new exposedField("direction", fieldValue(&direction), assign_SpotLight_direction),
    new exposedField("intensity", fieldValue(&intensity), assign_SpotLight_intensity),
    new exposedField("location", fieldValue(&location), assign_SpotLight_location),
    new exposedField("on", fieldValue(&on), assign_SpotLight_on),
    new exposedField("radius", fieldValue(&radius), assign_SpotLight_radius),
  };
  SFNode::construct(SpotLightTypeId, 10, the_interface);

  ambientIntensity = 0;
  attenuation = SFVec3f(1,0,0);
  beamWidth = 1.5708;
  color = SFColor(1,1,1);
  cutOffAngle = 0.785398;
  direction = SFVec3f(0,0,-1);
  intensity = 1;
  location = SFVec3f(0,0,0);
  on = 1;
  radius = 100;
  
  Children::util_init();
  LightSource::util_init();
  SpotLight::util_init();
}

void SpotLight::destruct(void)
{
  SpotLight::util_destruct();
  Children::util_destruct();
  LightSource::util_destruct();
  SFNode::destruct();
}

SpotLight::~SpotLight()
{
  destruct();
}

void SpotLight::clone_here(const SpotLight& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&ambientIntensity);
  interface[1]->value = fieldValue(&attenuation);
  interface[2]->value = fieldValue(&beamWidth);
  interface[3]->value = fieldValue(&color);
  interface[4]->value = fieldValue(&cutOffAngle);
  interface[5]->value = fieldValue(&direction);
  interface[6]->value = fieldValue(&intensity);
  interface[7]->value = fieldValue(&location);
  interface[8]->value = fieldValue(&on);
  interface[9]->value = fieldValue(&radius);
  
  ambientIntensity = src.ambientIntensity;
  attenuation = src.attenuation;
  beamWidth = src.beamWidth;
  color = src.color;
  cutOffAngle = src.cutOffAngle;
  direction = src.direction;
  intensity = src.intensity;
  location = src.location;
  on = src.on;
  radius = src.radius;
  
  Children::util_clone(src);
  LightSource::util_clone(src);
  SpotLight::util_clone(src);
}

SpotLight::SpotLight(const SpotLight& src)
{
  clone_here(src);
}

SpotLight& SpotLight::operator=(const SpotLight& src)
{
  if (this != &src) {
    destruct();
    clone_here(src);
  }
  return *this;
}

SFNode* SpotLight::instantiate(Proto *enclosing_proto)
{
  if (nameIndex>=0)
    // named node: return pointer to pre-made instance
    return enclosing_proto ? enclosing_proto->namedNodes[nameIndex] : this;
  
  SpotLight* instance = new SpotLight(*this);
  instance->instantiate_interface(enclosing_proto);
  return instance;
}

}  // namespace xrml
