shape.go 932 B

12345678910111213141516171819202122232425262728293031323334353637
  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 shape
  5. import "github.com/g3n/engine/math32"
  6. // IShape is the interface for all collision shapes.
  7. // Shapes in this package satisfy this interface and also geometry.Geometry.
  8. type IShape interface {
  9. BoundingBox() math32.Box3
  10. BoundingSphere() math32.Sphere
  11. Area() float32
  12. Volume() float32
  13. RotationalInertia(mass float32) math32.Matrix3
  14. ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)
  15. }
  16. // Shape is a collision shape.
  17. // It can be an analytical geometry such as a sphere, plane, etc.. or it can be defined by a polygonal Geometry.
  18. type Shape struct {
  19. // TODO
  20. //material
  21. // Collision filtering
  22. colFilterGroup int
  23. colFilterMask int
  24. }
  25. func (s *Shape) initialize() {
  26. // Collision filtering
  27. s.colFilterGroup = 1
  28. s.colFilterMask = -1
  29. }