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

#include "PhB3DTextureTransform.H"
#include "xrmlP.H"

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

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

bool PhB3DTextureTransform::assign_center(const SFVec3f& value)
{
  // TODO: value range check!
  center = value;
  status |= center_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhB3DTextureTransform_center(SFNode* node, const fieldValue& value)
{
  PhB3DTextureTransform* PhB3DTextureTransform_node = dynamic_cast<PhB3DTextureTransform*>(node);
  if (!PhB3DTextureTransform_node)
    Fatal(-1, "assign_PhB3DTextureTransform_center", "called for a non-PhB3DTextureTransform node");
  return PhB3DTextureTransform_node->assign_center((const SFVec3f&)value);
}

void PhB3DTextureTransform::set_center(const SFVec3f& val)
{
  SFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool PhB3DTextureTransform::assign_rotation(const SFRotation& value)
{
  // TODO: value range check!
  rotation = value;
  status |= rotation_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhB3DTextureTransform_rotation(SFNode* node, const fieldValue& value)
{
  PhB3DTextureTransform* PhB3DTextureTransform_node = dynamic_cast<PhB3DTextureTransform*>(node);
  if (!PhB3DTextureTransform_node)
    Fatal(-1, "assign_PhB3DTextureTransform_rotation", "called for a non-PhB3DTextureTransform node");
  return PhB3DTextureTransform_node->assign_rotation((const SFRotation&)value);
}

void PhB3DTextureTransform::set_rotation(const SFRotation& val)
{
  SFRotation tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

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

static bool assign_PhB3DTextureTransform_scale(SFNode* node, const fieldValue& value)
{
  PhB3DTextureTransform* PhB3DTextureTransform_node = dynamic_cast<PhB3DTextureTransform*>(node);
  if (!PhB3DTextureTransform_node)
    Fatal(-1, "assign_PhB3DTextureTransform_scale", "called for a non-PhB3DTextureTransform node");
  return PhB3DTextureTransform_node->assign_scale((const SFVec3f&)value);
}

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

bool PhB3DTextureTransform::assign_scaleOrientation(const SFRotation& value)
{
  // TODO: value range check!
  scaleOrientation = value;
  status |= scaleOrientation_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PhB3DTextureTransform_scaleOrientation(SFNode* node, const fieldValue& value)
{
  PhB3DTextureTransform* PhB3DTextureTransform_node = dynamic_cast<PhB3DTextureTransform*>(node);
  if (!PhB3DTextureTransform_node)
    Fatal(-1, "assign_PhB3DTextureTransform_scaleOrientation", "called for a non-PhB3DTextureTransform node");
  return PhB3DTextureTransform_node->assign_scaleOrientation((const SFRotation&)value);
}

void PhB3DTextureTransform::set_scaleOrientation(const SFRotation& val)
{
  SFRotation tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

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

static bool assign_PhB3DTextureTransform_translation(SFNode* node, const fieldValue& value)
{
  PhB3DTextureTransform* PhB3DTextureTransform_node = dynamic_cast<PhB3DTextureTransform*>(node);
  if (!PhB3DTextureTransform_node)
    Fatal(-1, "assign_PhB3DTextureTransform_translation", "called for a non-PhB3DTextureTransform node");
  return PhB3DTextureTransform_node->assign_translation((const SFVec3f&)value);
}

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

PhB3DTextureTransform::PhB3DTextureTransform()
{
  interfaceMember* the_interface[5] = {
    new exposedField("center", fieldValue(&center), assign_PhB3DTextureTransform_center),
    new exposedField("rotation", fieldValue(&rotation), assign_PhB3DTextureTransform_rotation),
    new exposedField("scale", fieldValue(&scale), assign_PhB3DTextureTransform_scale),
    new exposedField("scaleOrientation", fieldValue(&scaleOrientation), assign_PhB3DTextureTransform_scaleOrientation),
    new exposedField("translation", fieldValue(&translation), assign_PhB3DTextureTransform_translation),
  };
  SFNode::construct(PhB3DTextureTransformTypeId, 5, the_interface);

  center = SFVec3f(0,0,0);
  rotation = SFRotation(0,0,1,0);
  scale = SFVec3f(1,1,1);
  scaleOrientation = SFRotation(0,0,1,0);
  translation = SFVec3f(0,0,0);
  
  PhB3DTextureTransform::util_init();
}

void PhB3DTextureTransform::destruct(void)
{
  PhB3DTextureTransform::util_destruct();
  SFNode::destruct();
}

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

void PhB3DTextureTransform::clone_here(const PhB3DTextureTransform& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&center);
  interface[1]->value = fieldValue(&rotation);
  interface[2]->value = fieldValue(&scale);
  interface[3]->value = fieldValue(&scaleOrientation);
  interface[4]->value = fieldValue(&translation);
  
  center = src.center;
  rotation = src.rotation;
  scale = src.scale;
  scaleOrientation = src.scaleOrientation;
  translation = src.translation;
  
  PhB3DTextureTransform::util_clone(src);
}

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

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

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

}  // namespace xrml
