24 ColdetModel::ColdetModel()
29 dataSet->neighbor.clear();
36 isValid_(org.isValid_)
163 if(triangles.size() > 0){
167 iMesh.SetPointers(&triangles[0], &vertices[0]);
168 iMesh.SetNbTriangles(triangles.size());
169 iMesh.SetNbVertices(vertices.size());
180 for(
int i=0;
i<AABBTreeMaxDepth;
i++)
181 for(
int j=0; j<
i; j++)
182 numBBMap.at(i) += numLeafMap.at(j);
192 if(minNumofBB <= dataSet->getNumofBB(
i))
208 if(currentDepth == depth || node->IsLeaf() ){
215 if(currentDepth > depth)
return;
241 if(max < currentDepth){
243 numBBMap.push_back(0);
244 numLeafMap.push_back(0);
246 numBBMap.at(currentDepth)++;
250 max = computeDepth(node->GetPos(), currentDepth,
max);
251 max = computeDepth(node->GetNeg(), currentDepth,
max);
253 numLeafMap.at(currentDepth)++;
260 transform->
Set((
float)R(0,0), (
float)R(1,0), (
float)R(2,0), 0.0
f,
261 (
float)R(0,1), (
float)R(1,1), (
float)R(2,1), 0.0
f,
262 (
float)R(0,2), (
float)R(1,2), (
float)R(2,2), 0.0
f,
263 (
float)p(0), (
float)p(1), (
float)p(2), 1.0
f);
270 (
float)R[1], (
float)R[4], (
float)R[7], 0.0
f,
271 (
float)R[2], (
float)R[5], (
float)R[8], 0.0
f,
272 (
float)p[0], (
float)p[1], (
float)p[2], 1.0
f);
309 (
float)R[1], (
float)R[4], (
float)R[7], 0.0
f,
310 (
float)R[2], (
float)R[5], (
float)R[8], 0.0
f,
311 (
float)p[0], (
float)p[1], (
float)p[2], 1.0
f);
318 Ray world_ray(
Point(point[0], point[1], point[2]),
319 Point(dir[0], dir[1], dir[2]));
338 IceMaths::Matrix4x4 sphereTrans(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
339 for (
unsigned int i=0;
i<i_cloud.size();
i++){
341 sphereTrans.
m[3][0] = p[0];
342 sphereTrans.
m[3][1] = p[1];
343 sphereTrans.
m[3][2] = p[2];
345 if (!isOk) std::cerr <<
"SphereCollider::Collide() failed" << std::endl;
358 Edge edge(vertex0, vertex1);
359 EdgeToTriangleMap::iterator p =
triangleMap.find(edge);
366 if( triangles.
t[1] != -1 ){
375 triangles.
t[1] = triangle;
int getNumTriangles() const
void setPosition(const Matrix33 &R, const Vector3 &p)
set position and orientation of this model
PrimitiveType getPrimitiveType() const
get primitive type
void setTriangle(int index, int v1, int v2, int v3)
add a triangle
EdgeToTriangleMap triangleMap
int getNumVertices() const
get the number of vertices
bool mKeepOriginal
true => keep a copy of the original tree (debug purpose)
ColdetModelSharedDataSet * dataSet
bool setPrimitiveParam(unsigned int index, float value)
set a parameter of primitive
int numofBBtoDepth(int minNumofBB)
void build()
build tree of bounding boxes to accelerate collision check
bool Collide(const Ray &world_ray, const Model &model, const Matrix4x4 *world=null, udword *cache=null)
void setPrimitiveType(PrimitiveType ptype)
set primitive type
void setNeighbor(int triangle0, int triangle1)
void setVertex(int index, float x, float y, float z)
add a vertex
void setNeighborTriangle(int triangle, int vertex0, int vertex1, int vertex2)
Model creation structure.
bool Collide(SphereCache &cache, const Sphere &sphere, const Model &model, const Matrix4x4 *worlds=null, const Matrix4x4 *worldm=null)
IceMaths::Matrix4x4 * transform
bool mQuantized
true => quantize the tree (else use a normal tree)
void getTriangle(int index, int &out_v1, int &out_v2, int &out_v3) const
void addTriangle(int v1, int v2, int v3)
OPCODE_API bool SetupClosestHit(RayCollider &collider, CollisionFace &closest_contact)
inline_ void Identity()
Sets the identity matrix.
void setPrimitivePosition(const double *R, const double *p)
set position and orientation of primitive
inline_ void SetFirstContact(bool flag)
bool setNeighborTriangleSub(int triangle, int vertex0, int vertex1)
unsigned int udword
sizeof(udword) must be 4
inline_ BOOL GetContactStatus() const
void getBoundingBoxData(const int depth, std::vector< Vector3 > &out_boxes)
ColdetModelSharedDataSet()
void setNumTriangles(int n)
set the number of triangles
bool checkCollisionWithPointCloud(const std::vector< Vector3 > &i_cloud, double i_radius)
check collision between this triangle mesh and a point cloud
vector< IceMaths::IndexedTriangle > triangles
void setNumPrimitiveParams(unsigned int nparam)
set the number of parameters of primitive
bool getPrimitiveParam(unsigned int index, float &value) const
get a parameter of primitive
bool mNoLeaf
true => discard leaf nodes (else use a normal tree)
float mDistance
Distance from collider to hitpoint.
static void getBoundingBoxDataSub(const Opcode::AABBCollisionNode *node, unsigned int currentDepth, unsigned int depth, std::vector< Vector3 > &out_data)
inline_ Matrix4x4 & Set(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
Assign values (rotation only)
vector< IceMaths::Point > vertices
ColdetModel::PrimitiveType pType
void addVertex(float x, float y, float z)
IceMaths::Matrix4x4 * pTransform
transform of primitive
virtual ~ColdetModel()
destructor
MeshInterface * mIMesh
Mesh interface (access to triangles & vertices) (*)
void getVertex(int index, float &out_x, float &out_y, float &out_z) const
get a vertex
double computeDistanceWithRay(const double *point, const double *dir)
compute distance between a point and this mesh along ray
NeighborTriangleSetArray neighbor
void initialize()
common part of constuctors
static int max(int a, int b)
std::vector< float > pParams
void setNumVertices(int n)
set the number of vertices
inline_ const AABBOptimizedTree * GetTree() const
int computeDepth(const Opcode::AABBCollisionNode *node, int currentDepth, int max)