Class: ODE::Geom

Inherits:
Object
  • Object
show all
Includes:
ObjectID
Defined in:
lib/ode.rb

Instance Attribute Summary

Attributes included from ObjectID

#id

Instance Method Summary collapse

Methods included from ObjectID

by_id, #method_missing, set_by_id

Constructor Details

#initialize(type, space, *rest) ⇒ Geom

Returns a new instance of Geom.



417
418
419
420
# File 'lib/ode.rb', line 417

def initialize(type, space, *rest)
  @id = ODE.method("dCreate#{ODE.camelize_method_name(type.to_s)}").call((space == nil)? nil : space.id, *(ODE.convert_args(rest)))
  ObjectID.set_by_id(@id, self)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODE::ObjectID

Instance Method Details

#aabbObject

capitalization…



465
466
467
468
469
470
471
# File 'lib/ode.rb', line 465

def aabb
  c_vector = SWIG::TYPE_p_float.create(6)
  ODE.dGeomGetAABB(@id, c_vector)
  ruby_vector = c_vector.to_a
  c_vector.destroy
  ruby_vector
end

#bodyObject



434
435
436
437
438
439
440
# File 'lib/ode.rb', line 434

def body
  if (placeable?)
    ODE.dGeomGetBody(@id)
  else
	nil
  end
end

#placeable?Boolean

Returns:

  • (Boolean)


422
423
424
425
426
427
428
429
430
431
432
# File 'lib/ode.rb', line 422

def placeable?
  [
   ODE::DSphereClass,
   ODE::DBoxClass,
#       ODE::DCCylinderClass,
   ODE::DCylinderClass,
   ODE::DGeomTransformClass,
   ODE::DRayClass,
   ODE::DTriMeshClass
  ].include?(ODE.dGeomGetClass(@id))
end

#ray_getObject



442
443
444
445
446
447
448
449
450
451
# File 'lib/ode.rb', line 442

def ray_get
  c_start = SWIG::TYPE_p_float.create(3)
  c_dir = SWIG::TYPE_p_float.create(3)
  ODE.dGeomRayGet(@id, c_start, c_dir)
  ruby_start = c_start.to_a
  ruby_dir = c_dir.to_a
  c_start.destroy
  c_dir.destroy
  [ruby_start, ruby_dir]
end