Claudette
 All Classes Namespaces Files Functions Enumerations Enumerator Friends Macros
collision_model_3d.h
Go to the documentation of this file.
1 /* ColDet - C++ 3D Collision Detection Library
2  * Copyright (C) 2000 Amir Geva
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Any comments, questions and bug reports send to:
20  * photon@photoneffect.com
21  *
22  * Or visit the home page: http://photoneffect.com/coldet/
23  */
24 
32 #pragma once
33 
34 #include "global.h"
35 #include <cstddef>
36 
37 namespace Claudette {
38 
39 class ModelCollisionTest;
40 class RayCollisionTest;
41 class SphereCollisionTest;
42 
71 {
72 public:
74  enum ModelType
75  {
80  StaticModel
81  };
82 
83  CollisionModel3D(ModelType type = StaticModel);
85 
87  void setTriangleCount(std::size_t count);
88 
90  void addTriangle(float x1, float y1, float z1,
91  float x2, float y2, float z2,
92  float x3, float y3, float z3);
94  void addTriangle(const float v1[3], const float v2[3], const float v3[3]);
95 
97  void finalize();
98 
115  void setTransform(const float m[16]);
116 
128  bool modelCollision(ModelCollisionTest* test, int maxProcessingTime = 0) const;
129 
131  bool rayCollision(RayCollisionTest* test) const;
132 
134  bool sphereCollision(SphereCollisionTest* test) const;
135 
136 private:
137  class Private;
138  Private* const d;
139 };
140 
148 class Inconsistency {};
149 
150 
151 
153 // Utility Functions
155 
159 CLAUDETTE_LIB_EXPORT bool SphereRayCollision(const float sphereCenter[3],
160  float sphereRadius,
161  const float rayOrigin[3],
162  const float rayDirection[3],
163  float point[3]);
164 
167 CLAUDETTE_LIB_EXPORT bool SphereSphereCollision(const float c1[3], float r1,
168  const float c2[3], float r2,
169  float point[3]);
170 
171 } // namespace Claudette
Collision test with a ray.
#define CLAUDETTE_LIB_EXPORT
Definition: global.h:21
CLAUDETTE_LIB_EXPORT bool SphereSphereCollision(const float c1[3], float r1, const float c2[3], float r2, float point[3])
Checks for intersection between 2 spheres.
Collision test with a sphere.
The model is dynamic ie. can move.
ModelType
Various model types.
CLAUDETTE_LIB_EXPORT bool SphereRayCollision(const float sphereCenter[3], float sphereRadius, const float rayOrigin[3], const float rayDirection[3], float point[3])
Checks for intersection between a ray and a sphere.
Inconsistency exception.
Collision Model, will represent the mesh to be tested for collisions.
Collision test between two meshes.