class Eagle::Physics3D::Body

Overview

A 3D physics body: position, rotation, velocities, mass and shapes. Physics nodes create them for you.

Defined in:

eagle/physics/physics3d.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(type : BodyType = BodyType::Dynamic, position : Vec3 = Vec3::ZERO, shape : Shape | Nil = nil) #

Creates a body, optionally with a first shape.


Instance Method Detail

def aabb : AABB #

World-space bounds.


def add_shape(s : Shape) : Shape #

Adds a shape and recomputes mass. Returns the shape.


def angular_damping : Float32 #

Drag on spin.


def angular_damping=(angular_damping : Float32) #

Drag on spin.


def angular_velocity : Vec3 #

Spin axis scaled by radians per second.


def angular_velocity=(angular_velocity : Vec3) #

Spin axis scaled by radians per second.


def apply_force(f : Vec3, point : Vec3 | Nil = nil) : Nil #

Adds a force for the next step, at point if given.


def apply_impulse(i : Vec3, point : Vec3 | Nil = nil) : Nil #

Changes velocity instantly, at point if given.


def apply_torque(t : Vec3) : Nil #

Adds torque for the next step.


def collides_with?(o : Body) : Bool #

True when layer and mask bits allow a collision.


def contacts : Set(Eagle::Physics3D::Body) #

Bodies touching this one after the last step.


def contains_point?(p : Vec3) : Bool #

True when a world-space point is inside any shape.


def density : Float32 #

Mass per unit volume.


def density=(density : Float32) #

Mass per unit volume.


def dynamic? : Bool #

True for dynamic bodies.


def enabled=(enabled : Bool) #

Disabled bodies are skipped.


def enabled? : Bool #

Disabled bodies are skipped.


def fixed_rotation=(v : Bool) #

Enables or disables rotation.


def fixed_rotation=(fixed_rotation : Bool) #

Prevents rotation.


def fixed_rotation? : Bool #

Prevents rotation.


def force : Vec3 #

Force accumulated for the next step.


def force=(force : Vec3) #

Force accumulated for the next step.


def friction : Float32 #

Surface grip.


def friction=(friction : Float32) #

Surface grip.


def gravity_scale : Float32 #

Multiplies gravity for this body.


def gravity_scale=(gravity_scale : Float32) #

Multiplies gravity for this body.


def id : Int32 #

A unique id.


def inv_inertia_apply(v : Vec3) : Vec3 #

Applies the world-space inverse inertia to v.


def inv_inertia_local : Vec3 #

Inverse inertia in body space.


def inv_mass : Float32 #

1 / mass, or 0 for non-dynamic bodies.


def kinematic? : Bool #

True for kinematic bodies.


def layer : UInt32 #

Layer bits. See Physics2D::Body#layer for how layers and masks combine.


def layer=(layer : UInt32) #

Layer bits. See Physics2D::Body#layer for how layers and masks combine.


def linear_damping : Float32 #

Drag on linear velocity.


def linear_damping=(linear_damping : Float32) #

Drag on linear velocity.


def mask : UInt32 #

Mask bits.


def mask=(mask : UInt32) #

Mask bits.


def mass : Float32 #

Mass.


def mass=(m : Number) #

Sets the mass directly.


def owner : Node | Nil #

The node that owns this body, if any.


def owner=(owner : Node | Nil) #

The node that owns this body, if any.


def position : Vec3 #

World-space position.


def position=(position : Vec3) #

World-space position.


def restitution : Float32 #

Bounciness from 0 to 1.


def restitution=(restitution : Float32) #

Bounciness from 0 to 1.


def rotation : Quat #

Orientation.


def rotation=(rotation : Quat) #

Orientation.


def sensor=(sensor : Bool) #

Sensors report overlaps but don't collide.


def sensor? : Bool #

Sensors report overlaps but don't collide.


def shapes : Array(Eagle::Physics3D::Shape) #

Shapes in local space.


def static? : Bool #

True for static bodies.


def to_s(io : IO) : Nil #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

def torque : Vec3 #

Torque accumulated for the next step.


def torque=(torque : Vec3) #

Torque accumulated for the next step.


def transform : Mat4 #

The body's transform.


def type : BodyType #

Static, kinematic or dynamic.


def type=(t : BodyType) #

Changes the body type.


def velocity : Vec3 #

Linear velocity in meters per second.


def velocity=(velocity : Vec3) #

Linear velocity in meters per second.


def velocity_at(point : Vec3) : Vec3 #

Velocity of a world-space point on the body.