2
0

PolyCollisionSceneEntity.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #pragma once
  20. #include "PolyGlobals.h"
  21. #include "PolyVector3.h"
  22. class btConvexShape;
  23. class btConcaveShape;
  24. class btCollisionShape;
  25. class btCollisionObject;
  26. namespace Polycode {
  27. class Entity;
  28. /**
  29. * A wrapped around Entity that provides collision information.
  30. */
  31. class _PolyExport CollisionEntity {
  32. public:
  33. /**
  34. * Main constructor.
  35. */
  36. CollisionEntity(Entity *entity, int type, bool compoundChildren = false);
  37. virtual ~CollisionEntity();
  38. /** @name Collision scene entity
  39. * Public methods
  40. */
  41. //@{
  42. Entity *getEntity();
  43. int getType() { return type; }
  44. //@}
  45. // ----------------------------------------------------------------------------------------------------------------
  46. virtual void Update();
  47. btConvexShape *getConvexShape(){ return convexShape; }
  48. btCollisionShape *createCollisionShape(Entity *entity, int type);
  49. btCollisionObject *collisionObject;
  50. Vector3 lastPosition;
  51. /**
  52. * Box shape
  53. */
  54. static const int SHAPE_BOX = 0;
  55. /**
  56. * Terrain shape
  57. */
  58. static const int SHAPE_TERRAIN = 1;
  59. /**
  60. * Sphere shape
  61. */
  62. static const int SHAPE_SPHERE = 2;
  63. /**
  64. * Mesh shape
  65. */
  66. static const int SHAPE_MESH = 3;
  67. /**
  68. * Character controller shape
  69. */
  70. static const int CHARACTER_CONTROLLER = 4;
  71. /**
  72. * Capsule shape
  73. */
  74. static const int SHAPE_CAPSULE = 5;
  75. /**
  76. * Plane shape
  77. */
  78. static const int SHAPE_PLANE = 6;
  79. /**
  80. * Cone shape
  81. */
  82. static const int SHAPE_CONE = 7;
  83. /**
  84. * Cylinder shape
  85. */
  86. static const int SHAPE_CYLINDER = 8;
  87. bool enabled;
  88. btCollisionShape *shape;
  89. protected:
  90. btConvexShape *convexShape;
  91. btConcaveShape *concaveShape;
  92. int type;
  93. Entity *entity;
  94. };
  95. }