engine: github.com/g3n/engine/experimental/collision/shape Index | Files

package shape

import "github.com/g3n/engine/experimental/collision/shape"

Index

Package Files

box.go capsule.go cone.go convexhull.go cylinder.go heightfield.go plane.go shape.go sphere.go

type ConvexHull Uses

type ConvexHull struct {
    geometry.Geometry
    // contains filtered or unexported fields
}

ConvexHull is a convex triangle-based geometry used for collision detection and contact resolution.

func NewConvexHull Uses

func NewConvexHull(geom *geometry.Geometry) *ConvexHull

func (*ConvexHull) ClipAgainstHull Uses

func (ch *ConvexHull) ClipAgainstHull(chB *ConvexHull, posA, posB *math32.Vector3, quatA, quatB *math32.Quaternion, penAxis *math32.Vector3, minDist, maxDist float32) []collision.Contact

{array} result The an array of contact point objects, see clipFaceAgainstHull

func (*ConvexHull) ComputeWorldFaceNormalsAndUniqueEdges Uses

func (ch *ConvexHull) ComputeWorldFaceNormalsAndUniqueEdges(quat *math32.Quaternion)

ComputeWorldFaceNormalsAndUniqueEdges

func (*ConvexHull) FaceNormals Uses

func (ch *ConvexHull) FaceNormals() []math32.Vector3

func (*ConvexHull) Faces Uses

func (ch *ConvexHull) Faces() [][3]math32.Vector3

func (*ConvexHull) FindPenetrationAxis Uses

func (ch *ConvexHull) FindPenetrationAxis(chB *ConvexHull, posA, posB *math32.Vector3, quatA, quatB *math32.Quaternion) (bool, math32.Vector3)

FindPenetrationAxis finds the penetration axis between two convex bodies. The normal points from bodyA to bodyB. Returns false if there is no penetration. If there is a penetration - returns true and the penetration axis.

func (*ConvexHull) ProjectOntoWorldAxis Uses

func (ch *ConvexHull) ProjectOntoWorldAxis(worldAxis, pos *math32.Vector3, quat *math32.Quaternion) (float32, float32)

ProjectOntoWorldAxis projects the geometry onto the specified world axis.

func (*ConvexHull) TestPenetrationAxis Uses

func (ch *ConvexHull) TestPenetrationAxis(chB *ConvexHull, worldAxis, posA, posB *math32.Vector3, quatA, quatB *math32.Quaternion) (bool, float32)

Both hulls are projected onto the axis and the overlap size (penetration depth) is returned if there is one. return {number} The overlap depth, or FALSE if no penetration.

func (*ConvexHull) UniqueEdges Uses

func (ch *ConvexHull) UniqueEdges() []math32.Vector3

func (*ConvexHull) WorldFace Uses

func (ch *ConvexHull) WorldFace(face [3]math32.Vector3, pos *math32.Vector3, quat *math32.Quaternion) [3]math32.Vector3

func (*ConvexHull) WorldFaceNormals Uses

func (ch *ConvexHull) WorldFaceNormals() []math32.Vector3

func (*ConvexHull) WorldUniqueEdges Uses

func (ch *ConvexHull) WorldUniqueEdges() []math32.Vector3

type IShape Uses

type IShape interface {
    BoundingBox() math32.Box3
    BoundingSphere() math32.Sphere
    Area() float32
    Volume() float32
    RotationalInertia(mass float32) math32.Matrix3
    ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)
}

IShape is the interface for all collision shapes. Shapes in this package satisfy this interface and also geometry.Geometry.

type Plane Uses

type Plane struct {
    // contains filtered or unexported fields
}

Plane is an analytical collision Plane. A plane, facing in the +Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid.

func NewPlane Uses

func NewPlane() *Plane

NewPlane creates and returns a pointer to a new analytical collision plane.

func (*Plane) Area Uses

func (p *Plane) Area() float32

Area returns the surface area of the analytical collision plane.

func (*Plane) BoundingBox Uses

func (p *Plane) BoundingBox() math32.Box3

BoundingBox computes and returns the bounding box of the analytical collision plane.

func (*Plane) BoundingSphere Uses

func (p *Plane) BoundingSphere() math32.Sphere

BoundingSphere computes and returns the bounding sphere of the analytical collision plane.

func (*Plane) Normal Uses

func (p *Plane) Normal() math32.Vector3

Normal returns the normal of the analytical collision plane.

func (*Plane) ProjectOntoAxis Uses

func (p *Plane) ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)

ProjectOntoAxis returns the minimum and maximum distances of the analytical collision plane projected onto the specified local axis.

func (*Plane) RotationalInertia Uses

func (p *Plane) RotationalInertia(mass float32) math32.Matrix3

RotationalInertia computes and returns the rotational inertia of the analytical collision plane.

func (*Plane) Volume Uses

func (p *Plane) Volume() float32

Volume returns the volume of the analytical collision sphere.

type Shape Uses

type Shape struct {
    // contains filtered or unexported fields
}

Shape is a collision shape. It can be an analytical geometry such as a sphere, plane, etc.. or it can be defined by a polygonal Geometry.

type Sphere Uses

type Sphere struct {
    // contains filtered or unexported fields
}

Sphere is an analytical collision sphere.

func NewSphere Uses

func NewSphere(radius float32) *Sphere

NewSphere creates and returns a pointer to a new analytical collision sphere.

func (*Sphere) Area Uses

func (s *Sphere) Area() float32

Area computes and returns the surface area of the analytical collision sphere.

func (*Sphere) BoundingBox Uses

func (s *Sphere) BoundingBox() math32.Box3

BoundingBox computes and returns the bounding box of the analytical collision sphere.

func (*Sphere) BoundingSphere Uses

func (s *Sphere) BoundingSphere() math32.Sphere

BoundingSphere computes and returns the bounding sphere of the analytical collision sphere.

func (*Sphere) ProjectOntoAxis Uses

func (s *Sphere) ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)

ProjectOntoAxis computes and returns the minimum and maximum distances of the analytical collision sphere projected onto the specified local axis.

func (*Sphere) Radius Uses

func (s *Sphere) Radius() float32

Radius returns the radius of the analytical collision sphere.

func (*Sphere) RotationalInertia Uses

func (s *Sphere) RotationalInertia(mass float32) math32.Matrix3

RotationalInertia computes and returns the rotational inertia of the analytical collision sphere.

func (*Sphere) SetRadius Uses

func (s *Sphere) SetRadius(radius float32)

SetRadius sets the radius of the analytical collision sphere.

func (*Sphere) Volume Uses

func (s *Sphere) Volume() float32

Volume computes and returns the volume of the analytical collision sphere.

Package shape imports 3 packages (graph) and is imported by 3 packages. Updated 2018-07-30. Refresh now. Tools for package owners.