Class Joyau::Vector3f
In: Drawable.cpp
Parent: Object

audio objects and listeners are somewhere in the world. This class is mainly used for their positions.

Methods

==   new   x   x=   y   y=   z   z=  

Public Class methods

Creates a new Vector3f. Its position can be set too. Examples :

  vector = Joyau::Vector3f.new
  vector = Joyau::Vector3f.new(10, 15, 5)

[Source]

/*
  call-seq: Joyau::Vector3f.new
            Joyau::Vector3f.new(x, y, z)

    Creates a new Vector3f. Its position can be set too.
    Examples :
      vector = Joyau::Vector3f.new
      vector = Joyau::Vector3f.new(10, 15, 5)
*/
VALUE wrap<Vector3f>(int argc, VALUE *argv, VALUE info)
{
   Vector3f *ptr = new Vector3f;

   VALUE x, y, z;
   rb_scan_args(argc, argv, "03", &x, &y, &z);
   
   if (!NIL_P(x)) {
      if (NIL_P(y) || NIL_P(z))
         rb_raise(rb_eArgError, "3 arguments expected if at least on is given.");
      
      ptr->x = NUM2DBL(x);
      ptr->y = NUM2DBL(y);
      ptr->z = NUM2DBL(z);
   }

   VALUE tdata = Data_Wrap_Struct(info, 0, wrapped_free<Vector3f>, ptr);
   return tdata;
}

Public Instance methods

Returns true when the vectors have the same x, y, and z values.

[Source]

/*
  call-seq: vector == vector2

  Returns true when the vectors have the same x, y, and z values.
*/
VALUE Vector3f_eq(VALUE self, VALUE op)
{
   Vector3f &first = getRef<Vector3f>(self);
   Vector3f &second = getRef<Vector3f>(op);

   return first == second ? Qtrue : Qfalse;
}

Returns a vector’s x value.

[Source]

/*
  Returns a vector's x value.
*/
VALUE Vector3f_x(VALUE self)
{
   Vector3f &ref = getRef<Vector3f>(self);
   return rb_float_new(ref.x);
}

Sets a vector’s x value to a new value.

[Source]

/*
  call-seq: x=(value)

  Sets a vector's x value to a new value.
*/
VALUE Vector3f_setX(VALUE self, VALUE val)
{
   Vector3f &ref = getRef<Vector3f>(self);
   ref.x = NUM2DBL(val);

   return val;
}

Returns a vector’s y value.

[Source]

/*
  Returns a vector's y value.
*/
VALUE Vector3f_y(VALUE self)
{
   Vector3f &ref = getRef<Vector3f>(self);
   return rb_float_new(ref.y);
}

Sets a vector’s y value to a new value.

[Source]

/*
  call-seq: y=(value)

  Sets a vector's y value to a new value.
*/
VALUE Vector3f_setY(VALUE self, VALUE val)
{
   Vector3f &ref = getRef<Vector3f>(self);
   ref.y = NUM2DBL(val);

   return val;
}

Returns a vector’s z value.

[Source]

/*
  Returns a vector's z value.
*/
VALUE Vector3f_z(VALUE self)
{
   Vector3f &ref = getRef<Vector3f>(self);
   return rb_float_new(ref.z);
}

Sets a vector’s z value to a new value.

[Source]

/*
  call-seq: z=(value)

  Sets a vector's z value to a new value.
*/
VALUE Vector3f_setZ(VALUE self, VALUE val)
{
   Vector3f &ref = getRef<Vector3f>(self);
   ref.z = NUM2DBL(val);

   return val;
}

[Validate]