rigidbody.go 859 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2016 The G3N Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package physics
  5. import (
  6. "github.com/g3n/engine/math32"
  7. "github.com/g3n/engine/core"
  8. )
  9. // Body represents a physics-driven solid body.
  10. type Body struct {
  11. core.INode
  12. mass float32 // Total mass
  13. velocity math32.Vector3 // Linear velocity
  14. angularMass math32.Matrix3 // Angular mass i.e. moment of inertia
  15. angularVelocity math32.Vector3 // Angular velocity
  16. position math32.Vector3 // World position of the center of gravity
  17. static bool // If true - the rigidBody does not move or rotate
  18. }
  19. // NewBody creates and returns a pointer to a new RigidBody.
  20. func NewBody(inode core.INode) *Body {
  21. b := new(Body)
  22. b.INode = inode
  23. b.mass = 1
  24. return b
  25. }