// PixelTextureP.C: PixelTexture nodes (private source).
// Automatically generated with nodegen 0.51 - do not edit.

#include "PixelTexture.H"
#include "xrmlP.H"

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

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

bool PixelTexture::assign_image(const SFImage& value)
{
  // TODO: value range check!
  image = value;
  status |= image_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PixelTexture_image(SFNode* node, const fieldValue& value)
{
  PixelTexture* PixelTexture_node = dynamic_cast<PixelTexture*>(node);
  if (!PixelTexture_node)
    Fatal(-1, "assign_PixelTexture_image", "called for a non-PixelTexture node");
  return PixelTexture_node->assign_image((const SFImage&)value);
}

void PixelTexture::set_image(const SFImage& val)
{
  SFImage tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

bool PixelTexture::assign_repeatS(const SFBool& value)
{
  // TODO: value range check!
  repeatS = value;
  status |= repeatS_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PixelTexture_repeatS(SFNode* node, const fieldValue& value)
{
  PixelTexture* PixelTexture_node = dynamic_cast<PixelTexture*>(node);
  if (!PixelTexture_node)
    Fatal(-1, "assign_PixelTexture_repeatS", "called for a non-PixelTexture node");
  return PixelTexture_node->assign_repeatS((const SFBool&)value);
}

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

static bool assign_PixelTexture_repeatT(SFNode* node, const fieldValue& value)
{
  PixelTexture* PixelTexture_node = dynamic_cast<PixelTexture*>(node);
  if (!PixelTexture_node)
    Fatal(-1, "assign_PixelTexture_repeatT", "called for a non-PixelTexture node");
  return PixelTexture_node->assign_repeatT((const SFBool&)value);
}

PixelTexture::PixelTexture()
{
  interfaceMember* the_interface[3] = {
    new exposedField("image", fieldValue(&image), assign_PixelTexture_image),
    new field("repeatS", fieldValue(&repeatS), assign_PixelTexture_repeatS),
    new field("repeatT", fieldValue(&repeatT), assign_PixelTexture_repeatT),
  };
  SFNode::construct(PixelTextureTypeId, 3, the_interface);

  image = SFImage(0,0,0);
  repeatS = 1;
  repeatT = 1;
  
  PhBTexture::util_init();
  Texture::util_init();
  PixelTexture::util_init();
}

void PixelTexture::destruct(void)
{
  PixelTexture::util_destruct();
  Texture::util_destruct();
  PhBTexture::util_destruct();
  SFNode::destruct();
}

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

void PixelTexture::clone_here(const PixelTexture& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&image);
  interface[1]->value = fieldValue(&repeatS);
  interface[2]->value = fieldValue(&repeatT);
  
  image = src.image;
  repeatS = src.repeatS;
  repeatT = src.repeatT;
  
  PhBTexture::util_clone(src);
  Texture::util_clone(src);
  PixelTexture::util_clone(src);
}

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

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

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

}  // namespace xrml
