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

#include "PhBSchlickReflector.H"
#include "xrmlP.H"

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

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

bool PhBSchlickReflector::assign_roughness(const SFFloat& value)
{
  // TODO: value range check!
  roughness = value;
  status |= roughness_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSchlickReflector_roughness(SFNode* node, const fieldValue& value)
{
  PhBSchlickReflector* PhBSchlickReflector_node = dynamic_cast<PhBSchlickReflector*>(node);
  if (!PhBSchlickReflector_node)
    Fatal(-1, "assign_PhBSchlickReflector_roughness", "called for a non-PhBSchlickReflector node");
  return PhBSchlickReflector_node->assign_roughness((const SFFloat&)value);
}

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

bool PhBSchlickReflector::assign_isotropy(const SFFloat& value)
{
  // TODO: value range check!
  isotropy = value;
  status |= isotropy_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSchlickReflector_isotropy(SFNode* node, const fieldValue& value)
{
  PhBSchlickReflector* PhBSchlickReflector_node = dynamic_cast<PhBSchlickReflector*>(node);
  if (!PhBSchlickReflector_node)
    Fatal(-1, "assign_PhBSchlickReflector_isotropy", "called for a non-PhBSchlickReflector node");
  return PhBSchlickReflector_node->assign_isotropy((const SFFloat&)value);
}

void PhBSchlickReflector::set_isotropy(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

bool PhBSchlickReflector::assign_selfShadowing(const SFBool& value)
{
  // TODO: value range check!
  selfShadowing = value;
  status |= selfShadowing_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhBSchlickReflector_selfShadowing(SFNode* node, const fieldValue& value)
{
  PhBSchlickReflector* PhBSchlickReflector_node = dynamic_cast<PhBSchlickReflector*>(node);
  if (!PhBSchlickReflector_node)
    Fatal(-1, "assign_PhBSchlickReflector_selfShadowing", "called for a non-PhBSchlickReflector node");
  return PhBSchlickReflector_node->assign_selfShadowing((const SFBool&)value);
}

void PhBSchlickReflector::set_selfShadowing(const SFBool& val)
{
  SFBool tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

PhBSchlickReflector::PhBSchlickReflector()
{
  interfaceMember* the_interface[3] = {
    new exposedField("roughness", fieldValue(&roughness), assign_PhBSchlickReflector_roughness),
    new exposedField("isotropy", fieldValue(&isotropy), assign_PhBSchlickReflector_isotropy),
    new exposedField("selfShadowing", fieldValue(&selfShadowing), assign_PhBSchlickReflector_selfShadowing),
  };
  SFNode::construct(PhBSchlickReflectorTypeId, 3, the_interface);

  roughness = 1;
  isotropy = 1;
  selfShadowing = 1;
  
  PhBScatterer::util_init();
  PhBSchlickReflector::util_init();
}

void PhBSchlickReflector::destruct(void)
{
  PhBSchlickReflector::util_destruct();
  PhBScatterer::util_destruct();
  SFNode::destruct();
}

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

void PhBSchlickReflector::clone_here(const PhBSchlickReflector& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&roughness);
  interface[1]->value = fieldValue(&isotropy);
  interface[2]->value = fieldValue(&selfShadowing);
  
  roughness = src.roughness;
  isotropy = src.isotropy;
  selfShadowing = src.selfShadowing;
  
  PhBScatterer::util_clone(src);
  PhBSchlickReflector::util_clone(src);
}

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

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

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

}  // namespace xrml
