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

#include "PointLight.H"
#include "xrmlP.H"

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

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

bool PointLight::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_PointLight_ambientIntensity(SFNode* node, const fieldValue& value)
{
  PointLight* PointLight_node = dynamic_cast<PointLight*>(node);
  if (!PointLight_node)
    Fatal(-1, "assign_PointLight_ambientIntensity", "called for a non-PointLight node");
  return PointLight_node->assign_ambientIntensity((const SFFloat&)value);
}

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

bool PointLight::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_PointLight_attenuation(SFNode* node, const fieldValue& value)
{
  PointLight* PointLight_node = dynamic_cast<PointLight*>(node);
  if (!PointLight_node)
    Fatal(-1, "assign_PointLight_attenuation", "called for a non-PointLight node");
  return PointLight_node->assign_attenuation((const SFVec3f&)value);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

PointLight::PointLight()
{
  interfaceMember* the_interface[7] = {
    new exposedField("ambientIntensity", fieldValue(&ambientIntensity), assign_PointLight_ambientIntensity),
    new exposedField("attenuation", fieldValue(&attenuation), assign_PointLight_attenuation),
    new exposedField("color", fieldValue(&color), assign_PointLight_color),
    new exposedField("intensity", fieldValue(&intensity), assign_PointLight_intensity),
    new exposedField("location", fieldValue(&location), assign_PointLight_location),
    new exposedField("on", fieldValue(&on), assign_PointLight_on),
    new exposedField("radius", fieldValue(&radius), assign_PointLight_radius),
  };
  SFNode::construct(PointLightTypeId, 7, the_interface);

  ambientIntensity = 0;
  attenuation = SFVec3f(1,0,0);
  color = SFColor(1,1,1);
  intensity = 1;
  location = SFVec3f(0,0,0);
  on = 1;
  radius = 100;
  
  Children::util_init();
  LightSource::util_init();
  PointLight::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
