Module: MSPhysics::Collision

Defined in:
RubyExtension/MSPhysics/collision.rb

Overview

Since:

  • 1.0.0

Constant Summary

ENTITY_VALIDATION_PROC =

Since:

  • 1.0.0

Proc.new { |entity|
  next true if (!entity.is_a?(Sketchup::Group) && !entity.is_a?(Sketchup::ComponentInstance))
  entity.get_attribute('MSPhysics', 'Type', 'Body') == 'Body' && !entity.get_attribute('MSPhysics Body', 'Ignore')
}

Class Method Summary collapse

Class Method Details

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

Create a physics collision.

Parameters:

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

    Shape ID. See SHAPE_NAMES

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

    A local transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Since:

  • 1.0.0

.create_box(world, entity, transformation) ⇒ Fixnum

Create a box collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transformation (Geom::Transformation, nil)

    A transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if calculated bounding box turns out flat.

Since:

  • 1.0.0

.create_capsule(world, entity, transformation) ⇒ Fixnum

Create a capsule collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transformation (Geom::Transformation, nil)

    A transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if calculated bounding box turns out flat.

Since:

  • 1.0.0

.create_chamfer_cylinder(world, entity, transformation) ⇒ Fixnum

Create a chamfer cylinder collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transformation (Geom::Transformation, nil)

    A transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if calculated bounding box turns out flat.

Since:

  • 1.0.0

.create_compound(world, entity) ⇒ Fixnum

Create a compound collision. In a compound collision every sub-group is considered a convex collision.

Parameters:

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

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if entity doesn't have any valid sub-collisions.

Since:

  • 1.0.0

.create_compound2(world, entity) ⇒ Fixnum

Create a compound collision. In a compound collision every sub-group is considered a convex collision.

Parameters:

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

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if entity doesn't have any valid sub-collisions.

Since:

  • 1.0.0

.create_cone(world, entity, transformation) ⇒ Fixnum

Create a cone collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transformation (Geom::Transformation, nil)

    A transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if calculated bounding box turns out flat.

Since:

  • 1.0.0

.create_convex_hull(world, entity, transform = false) ⇒ Fixnum

Create a convex hull collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transform (Boolean) (defaults to: false)

    Whether to offset the collision. Usually this parameter is set true if the entity is a sub-collision of some parent collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if entity has too few vertices.

  • (TypeError)

    if entity has all vertices coplanar.

  • (TypeError)

    if the engine failed to generate convex hull.

Since:

  • 1.0.0

.create_cylinder(world, entity, transformation) ⇒ Fixnum

Create a cylinder collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transformation (Geom::Transformation, nil)

    A transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if calculated bounding box turns out flat.

Since:

  • 1.0.0

.create_null(world) ⇒ Fixnum

Create a null collision.

Parameters:

Returns:

  • (Fixnum)

    Collision address

Since:

  • 1.0.0

.create_sphere(world, entity, transformation) ⇒ Fixnum

Create a sphere collision.

Parameters:

  • world (World)
  • entity (Sketchup::Group, Sketchup::ComponentInstance)
  • transformation (Geom::Transformation, nil)

    A transform to apply to the collision.

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if calculated bounding box turns out flat.

Since:

  • 1.0.0

.create_static_mesh(world, entity) ⇒ Fixnum

Create a static tree/scene collision.

Parameters:

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

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if entity has no faces.

Since:

  • 1.0.0

.create_static_mesh2(world, entity) ⇒ Fixnum

Create a static tree/scene collision.

Parameters:

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

Returns:

  • (Fixnum)

    Collision address

Raises:

  • (TypeError)

    if entity has no faces.

Since:

  • 1.0.0

.validate_entity(entity) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Verify that entity is valid for collision generation.

Parameters:

  • entity (Sketchup::Group, Sketchup::ComponentInstance)

Raises:

  • (TypeError)

    if entity is deleted.

  • (TypeError)

    if entity has a transformation matrix with non-perpendicular axis.

  • (TypeError)

    if entity has at least one of the axis scaled to zero.

Since:

  • 1.0.0