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

#include "TextureTransform.H"
#include "xrmlP.H"

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

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

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

static bool assign_TextureTransform_center(SFNode* node, const fieldValue& value)
{
  TextureTransform* TextureTransform_node = dynamic_cast<TextureTransform*>(node);
  if (!TextureTransform_node)
    Fatal(-1, "assign_TextureTransform_center", "called for a non-TextureTransform node");
  return TextureTransform_node->assign_center((const SFVec2f&)value);
}

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

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

static bool assign_TextureTransform_rotation(SFNode* node, const fieldValue& value)
{
  TextureTransform* TextureTransform_node = dynamic_cast<TextureTransform*>(node);
  if (!TextureTransform_node)
    Fatal(-1, "assign_TextureTransform_rotation", "called for a non-TextureTransform node");
  return TextureTransform_node->assign_rotation((const SFFloat&)value);
}

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

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

static bool assign_TextureTransform_scale(SFNode* node, const fieldValue& value)
{
  TextureTransform* TextureTransform_node = dynamic_cast<TextureTransform*>(node);
  if (!TextureTransform_node)
    Fatal(-1, "assign_TextureTransform_scale", "called for a non-TextureTransform node");
  return TextureTransform_node->assign_scale((const SFVec2f&)value);
}

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

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

static bool assign_TextureTransform_translation(SFNode* node, const fieldValue& value)
{
  TextureTransform* TextureTransform_node = dynamic_cast<TextureTransform*>(node);
  if (!TextureTransform_node)
    Fatal(-1, "assign_TextureTransform_translation", "called for a non-TextureTransform node");
  return TextureTransform_node->assign_translation((const SFVec2f&)value);
}

void TextureTransform::set_translation(const SFVec2f& val)
{
  SFVec2f tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

TextureTransform::TextureTransform()
{
  interfaceMember* the_interface[4] = {
    new exposedField("center", fieldValue(&center), assign_TextureTransform_center),
    new exposedField("rotation", fieldValue(&rotation), assign_TextureTransform_rotation),
    new exposedField("scale", fieldValue(&scale), assign_TextureTransform_scale),
    new exposedField("translation", fieldValue(&translation), assign_TextureTransform_translation),
  };
  SFNode::construct(TextureTransformTypeId, 4, the_interface);

  center = SFVec2f(0,0);
  rotation = 0;
  scale = SFVec2f(1,1);
  translation = SFVec2f(0,0);
  
  TextureTransform::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
