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

#include "DirectionalLight.H"
#include "xrmlP.H"

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

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

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

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

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

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

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

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

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

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

bool DirectionalLight::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_DirectionalLight_intensity(SFNode* node, const fieldValue& value)
{
  DirectionalLight* DirectionalLight_node = dynamic_cast<DirectionalLight*>(node);
  if (!DirectionalLight_node)
    Fatal(-1, "assign_DirectionalLight_intensity", "called for a non-DirectionalLight node");
  return DirectionalLight_node->assign_intensity((const SFFloat&)value);
}

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

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

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

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

DirectionalLight::DirectionalLight()
{
  interfaceMember* the_interface[5] = {
    new exposedField("ambientIntensity", fieldValue(&ambientIntensity), assign_DirectionalLight_ambientIntensity),
    new exposedField("color", fieldValue(&color), assign_DirectionalLight_color),
    new exposedField("direction", fieldValue(&direction), assign_DirectionalLight_direction),
    new exposedField("intensity", fieldValue(&intensity), assign_DirectionalLight_intensity),
    new exposedField("on", fieldValue(&on), assign_DirectionalLight_on),
  };
  SFNode::construct(DirectionalLightTypeId, 5, the_interface);

  ambientIntensity = 0;
  color = SFColor(1,1,1);
  direction = SFVec3f(0,0,-1);
  intensity = 1;
  on = 1;
  
  Children::util_init();
  LightSource::util_init();
  DirectionalLight::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
