Class: Ray::Drawable
- Inherits:
-
Object
- Object
- Ray::Drawable
- Defined in:
- lib/ray/drawable.rb,
ext/drawable.c
Instance Method Summary collapse
-
#angle ⇒ Float
Angle is a rotation applied to a drawable.
-
#angle=(val) ⇒ Object
Sets the rotation applied to the drawable.
-
#changed! ⇒ Object
Marks the object as changed, meaning vertices must be updated.
-
#changed? ⇒ true, flase
True if the drawable has changed, and vertices must be updated.
-
#index_count ⇒ Integer
Amount of indices used by this drawable.
- #index_count=(val) ⇒ Object
- #initialize(vertex_class = Ray::Vertex) ⇒ Object constructor
- #initialize_copy(orig) ⇒ Object
-
#matrix ⇒ Ray::Matrix
The transformation matrix used by this object.
-
#matrix=(val) ⇒ Object
Sets the current matrix to a custom one, making Ray ignore attributes setting that change the transformation matrix.
-
#origin ⇒ Ray::Vector2
The origin is used as the origin for translations, rotations, and scalings.
-
#origin=(val) ⇒ Object
Sets the origin of the drawable.
-
#pos ⇒ Ray::Vector2
(also: #position)
Position of the drawable.
-
#pos=(val) ⇒ Object
(also: #position=)
Sets the position of the drawable.
-
#scale ⇒ Ray::Vector2
(also: #zoom)
The scaling factor multiplies the size of the object.
-
#scale=(val) ⇒ Object
(also: #zoom=)
Sets the scaling factor of the drawable.
- #scale_x ⇒ Object
- #scale_x=(val) ⇒ Object
- #scale_y ⇒ Object
- #scale_y=(val) ⇒ Object
- #shader ⇒ Ray::Shader
- #shader=(val) ⇒ Object
-
#textured=(val) ⇒ Object
Marks the object as changed, meaning vertices must be updated.
-
#textured? ⇒ true, flase
True if the drawable is textured.
-
#transform(point) ⇒ Ray::Vector3
Applies the transformations to a point.
-
#vertex_count ⇒ Integer
Amount of vertices used by this drawable.
- #vertex_count=(val) ⇒ Object
- #x ⇒ Object
- #x=(val) ⇒ Object
- #y ⇒ Object
- #y=(val) ⇒ Object
-
#z ⇒ Float
The Z order is a number between 1 and -1.
-
#z=(val) ⇒ Object
Sets the z order.
Constructor Details
#initialize(vertex_class = Ray::Vertex) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'ext/drawable.c', line 110
static
VALUE ray_drawable_init(int argc, VALUE *argv, VALUE self) {
if (rb_obj_is_kind_of(self, rb_path2class("Ray::Text")) ||
rb_obj_is_kind_of(self, rb_path2class("Ray::Sprite")) ||
rb_obj_is_kind_of(self, rb_path2class("Ray::Polygon"))) {
rb_raise(rb_eTypeError, "can't get drawable pointer from %s",
RAY_OBJ_CLASSNAME(self));
}
ray_drawable *obj = NULL;
Data_Get_Struct(self, ray_drawable, obj);
VALUE arg = Qnil;
rb_scan_args(argc, argv, "01", &arg);
size_t id = NIL_P(arg) ? 0 : ray_get_vtype(arg);
obj->drawable = say_drawable_create(id);
say_drawable_set_custom_data(obj->drawable, obj);
say_drawable_set_fill_proc(obj->drawable, ray_drawable_fill_proc);
say_drawable_set_render_proc(obj->drawable, ray_drawable_render_proc);
say_drawable_set_index_fill_proc(obj->drawable,
ray_drawable_indices_fill_proc);
say_drawable_set_changed(obj->drawable);
rb_iv_set(self, "@vertex_type_class", NIL_P(arg) ?
rb_path2class("Ray::Vertex") : arg);
obj->vsize = say_vertex_type_get_size(say_get_vertex_type(id));
return self;
}
|
Instance Method Details
#angle ⇒ Float
Angle is a rotation applied to a drawable. It is expressed in degrees, in the counter-clockwise direction.
269 270 271 272 |
# File 'ext/drawable.c', line 269 static VALUE ray_drawable_angle(VALUE self) { return rb_float_new(say_drawable_get_angle(ray_rb2drawable(self))); } |
#angle=(val) ⇒ Object
280 281 282 283 284 |
# File 'ext/drawable.c', line 280
static
VALUE ray_drawable_set_angle(VALUE self, VALUE val) {
say_drawable_set_angle(ray_rb2drawable(self), NUM2DBL(val));
return val;
}
|
#changed! ⇒ Object
Marks the object as changed, meaning vertices must be updated.
386 387 388 389 390 |
# File 'ext/drawable.c', line 386 static VALUE ray_drawable_set_changed(VALUE self) { say_drawable_set_changed(ray_rb2drawable(self)); return self; } |
#changed? ⇒ true, flase
Returns true if the drawable has changed, and vertices must be updated.
380 381 382 383 |
# File 'ext/drawable.c', line 380 static VALUE ray_drawable_has_changed(VALUE self) { return say_drawable_has_changed(ray_rb2drawable(self)) ? Qtrue : Qfalse; } |
#index_count ⇒ Integer
Returns Amount of indices used by this drawable.
370 371 372 373 374 375 |
# File 'ext/drawable.c', line 370 static VALUE ray_drawable_index_count(VALUE self) { say_drawable *drawable = ray_rb2drawable(self); size_t count = say_drawable_get_index_count(drawable); return ULONG2NUM(count); } |
#index_count=(val) ⇒ Object
362 363 364 365 366 367 |
# File 'ext/drawable.c', line 362
static
VALUE ray_drawable_set_index_count(VALUE self, VALUE val) {
ray_drawable *drawable = ray_rb2full_drawable(self);
say_drawable_set_index_count(drawable->drawable, NUM2ULONG(val));
return val;
}
|
#initialize_copy(orig) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'ext/drawable.c', line 143
static
VALUE ray_drawable_init_copy(VALUE self, VALUE orig) {
if (rb_obj_is_kind_of(self, rb_path2class("Ray::Text")) ||
rb_obj_is_kind_of(self, rb_path2class("Ray::Sprite")) ||
rb_obj_is_kind_of(self, rb_path2class("Ray::Polygon"))) {
rb_raise(rb_eTypeError, "can't get drawable pointer from %s",
RAY_OBJ_CLASSNAME(self));
}
ray_drawable *obj = NULL;
Data_Get_Struct(self, ray_drawable, obj);
ray_drawable *other = ray_rb2full_drawable(orig);
size_t vid = say_drawable_get_vertex_type(other->drawable);
obj->drawable = say_drawable_create(vid);
say_drawable_set_custom_data(obj->drawable, obj);
say_drawable_copy(obj->drawable, other->drawable);
say_drawable_set_changed(obj->drawable);
rb_iv_set(self, "@vertex_type_class", rb_iv_get(orig, "@vertex_type_class"));
obj->vsize = other->vsize;
return self;
}
|
#matrix ⇒ Ray::Matrix
Returns The transformation matrix used by this object.
289 290 291 292 |
# File 'ext/drawable.c', line 289 static VALUE ray_drawable_matrix(VALUE self) { return ray_matrix2rb(say_drawable_get_matrix(ray_rb2drawable(self))); } |
#matrix=(val) ⇒ Object
304 305 306 307 308 309 310 311 312 313 314 |
# File 'ext/drawable.c', line 304
static
VALUE ray_drawable_set_matrix(VALUE self, VALUE val) {
say_drawable *drawable = ray_rb2drawable(self);
if (NIL_P(val))
say_drawable_set_matrix(drawable, NULL);
else
say_drawable_set_matrix(drawable, ray_rb2matrix(val));
return val;
}
|
#origin ⇒ Ray::Vector2
The origin is used as the origin for translations, rotations, and scalings.
175 176 177 178 |
# File 'ext/drawable.c', line 175 static VALUE ray_drawable_origin(VALUE self) { return ray_vector2_to_rb(say_drawable_get_origin(ray_rb2drawable(self))); } |
#origin=(val) ⇒ Object
186 187 188 189 190 |
# File 'ext/drawable.c', line 186
static
VALUE ray_drawable_set_origin(VALUE self, VALUE val) {
say_drawable_set_origin(ray_rb2drawable(self), ray_convert_to_vector2(val));
return val;
}
|
#pos ⇒ Ray::Vector2 Also known as: position
Position of the drawable. This is thus the translation applied to it.
219 220 221 222 |
# File 'ext/drawable.c', line 219 static VALUE ray_drawable_pos(VALUE self) { return ray_vector2_to_rb(say_drawable_get_pos(ray_rb2drawable(self))); } |
#pos=(val) ⇒ Object Also known as: position=
230 231 232 233 234 |
# File 'ext/drawable.c', line 230
static
VALUE ray_drawable_set_pos(VALUE self, VALUE val) {
say_drawable_set_pos(ray_rb2drawable(self), ray_convert_to_vector2(val));
return val;
}
|
#scale ⇒ Ray::Vector2 Also known as: zoom
The scaling factor multiplies the size of the object. If it is set to (3,0.5), then te object is 3 times wider and 2 times shorter.
198 199 200 201 |
# File 'ext/drawable.c', line 198 static VALUE ray_drawable_scale(VALUE self) { return ray_vector2_to_rb(say_drawable_get_scale(ray_rb2drawable(self))); } |
#scale=(val) ⇒ Object Also known as: zoom=
209 210 211 212 |
# File 'ext/drawable.c', line 209
VALUE ray_drawable_set_scale(VALUE self, VALUE val) {
say_drawable_set_scale(ray_rb2drawable(self), ray_convert_to_vector2(val));
return val;
}
|
#scale_x ⇒ Object
19 20 21 |
# File 'lib/ray/drawable.rb', line 19 def scale_x scale.x end |
#scale_x=(val) ⇒ Object
27 28 29 |
# File 'lib/ray/drawable.rb', line 27 def scale_x=(val) self.scale = [val, scale_y] end |
#scale_y ⇒ Object
23 24 25 |
# File 'lib/ray/drawable.rb', line 23 def scale_y scale.y end |
#scale_y=(val) ⇒ Object
31 32 33 |
# File 'lib/ray/drawable.rb', line 31 def scale_y=(val) self.scale = [scale_x, val] end |
#shader ⇒ Ray::Shader
331 332 333 334 |
# File 'ext/drawable.c', line 331 static VALUE ray_drawable_shader(VALUE self) { return rb_iv_get(self, "@shader"); } |
#shader=(val) ⇒ Object
336 337 338 339 340 341 342 343 344 345 |
# File 'ext/drawable.c', line 336
static
VALUE ray_drawable_set_shader(VALUE self, VALUE val) {
if (NIL_P(val))
say_drawable_set_shader(ray_rb2drawable(self), NULL);
else
say_drawable_set_shader(ray_rb2drawable(self), ray_rb2shader(val));
rb_iv_set(self, "@shader", val);
return val;
}
|
#textured=(val) ⇒ Object
Marks the object as changed, meaning vertices must be updated.
399 400 401 402 403 |
# File 'ext/drawable.c', line 399
static
VALUE ray_drawable_set_textured(VALUE self, VALUE val) {
say_drawable_set_textured(ray_rb2drawable(self), RTEST(val));
return self;
}
|
#textured? ⇒ true, flase
Returns true if the drawable is textured.
393 394 395 396 |
# File 'ext/drawable.c', line 393 static VALUE ray_drawable_is_textured(VALUE self) { return say_drawable_is_textured(ray_rb2drawable(self)) ? Qtrue : Qfalse; } |
#transform(point) ⇒ Ray::Vector3
323 324 325 326 327 328 |
# File 'ext/drawable.c', line 323
static
VALUE ray_drawable_transform(VALUE self, VALUE point) {
say_vector3 res = say_drawable_transform(ray_rb2drawable(self),
ray_convert_to_vector3(point));
return ray_vector3_to_rb(res);
}
|
#vertex_count ⇒ Integer
Returns Amount of vertices used by this drawable.
355 356 357 358 359 360 |
# File 'ext/drawable.c', line 355 static VALUE ray_drawable_vertex_count(VALUE self) { say_drawable *drawable = ray_rb2drawable(self); size_t count = say_drawable_get_vertex_count(drawable); return ULONG2NUM(count); } |
#vertex_count=(val) ⇒ Object
347 348 349 350 351 352 |
# File 'ext/drawable.c', line 347
static
VALUE ray_drawable_set_vertex_count(VALUE self, VALUE val) {
ray_drawable *drawable = ray_rb2full_drawable(self);
say_drawable_set_vertex_count(drawable->drawable, NUM2ULONG(val));
return val;
}
|
#x ⇒ Object
7 8 9 |
# File 'lib/ray/drawable.rb', line 7 def x pos.x end |
#x=(val) ⇒ Object
15 16 17 |
# File 'lib/ray/drawable.rb', line 15 def x=(val) self.pos = [val, y] end |
#y ⇒ Object
3 4 5 |
# File 'lib/ray/drawable.rb', line 3 def y pos.y end |
#y=(val) ⇒ Object
11 12 13 |
# File 'lib/ray/drawable.rb', line 11 def y=(val) self.pos = [x, val] end |
#z ⇒ Float
The Z order is a number between 1 and -1. Numbers with a smaller Z order are drawn behind those with a higher one.
Notice that this is only true without transparency. When transparency is enabled, transparent parts of a drawable would hide what’s behind it if the scene isn’t drawn in pixel order.
246 247 248 249 |
# File 'ext/drawable.c', line 246 static VALUE ray_drawable_z(VALUE self) { return rb_float_new(say_drawable_get_z(ray_rb2drawable(self))); } |
#z=(val) ⇒ Object
257 258 259 260 261 |
# File 'ext/drawable.c', line 257
static
VALUE ray_drawable_set_z(VALUE self, VALUE val) {
say_drawable_set_z(ray_rb2drawable(self), NUM2DBL(val));
return val;
}
|