Method: MSPhysics::Collision.create

Defined in:
RubyExtension/MSPhysics/collision.rb

.create(world, entity, shape_id, transformation = nil) ⇒ Integer

Create a physics collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • shape_id (Integer)

    Shape ID. See SHAPE_NAMES

  • transformation (Geom::Transformation, nil) (defaults to: nil)

    A local transform to apply to the collision.

Returns:

  • (Integer)

    Collision address

Since:

  • 1.0.0



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'RubyExtension/MSPhysics/collision.rb', line 55

def create(world, entity, shape_id, transformation = nil)
  MSPhysics::World.validate(world)
  validate_entity(entity)
  case shape_id
    when 0
      create_null(world)
    when 1
      create_box(world, entity, transformation)
    when 2
      create_sphere(world, entity, transformation)
    when 3
      create_cone(world, entity,transformation)
    when 4
      create_cylinder(world, entity, transformation)
    when 5
      create_chamfer_cylinder(world, entity, transformation)
    when 6
      create_capsule(world, entity, transformation)
    when 7
      create_convex_hull(world, entity, false)
    when 8
      create_compound2(world, entity)
    when 9
      create_static_mesh2(world, entity)
  else
    raise(TypeError, "The given shape ID, \"#{shape_id}\", does not reference a valid shape!", caller)
  end
end