NLPACS::CCollisionMeshBuild Class Reference

#include <collision_mesh_build.h>


Detailed Description

The collision intermediate mesh, used to build the real collision meshes.
Author:
Benjamin Legros

Nevrax France

Date:
2001

Definition at line 107 of file collision_mesh_build.h.

Public Member Functions

NLMISC::CVector computeTrivialTranslation () const
void link (bool linkInterior, std::vector< std::string > &errors)
void serial (NLMISC::IStream &f)
void transform (const NLMISC::CMatrix &tranfo)
void translate (const NLMISC::CVector &translation)

Data Fields

std::vector< CCollisionFaceFaces
 The faces of the mesh.

std::vector< NLMISC::CVectorVertices
 The vertices of the mesh.


Private Types

typedef TLinkRelloc::iterator ItTLinkRelloc
typedef std::map< CEdgeKey,
CEdgeInfo, CEdgeKey
TLinkRelloc


Member Typedef Documentation

typedef TLinkRelloc::iterator NLPACS::CCollisionMeshBuild::ItTLinkRelloc [private]
 

Definition at line 135 of file collision_mesh_build.h.

Referenced by link().

typedef std::map<CEdgeKey, CEdgeInfo, CEdgeKey> NLPACS::CCollisionMeshBuild::TLinkRelloc [private]
 

Definition at line 134 of file collision_mesh_build.h.

Referenced by link().


Member Function Documentation

NLMISC::CVector NLPACS::CCollisionMeshBuild::computeTrivialTranslation  )  const [inline]
 

Definition at line 169 of file collision_mesh_build.h.

References NLMISC::CAABBox::extend(), NLMISC::CAABBox::getCenter(), NLMISC::CAABBox::setCenter(), and uint.

Referenced by NLPACS::computeRetriever().

00170         {
00171                 uint    i;
00172                 NLMISC::CAABBox bbox;
00173 
00174                 if (!Vertices.empty())
00175                 {
00176                         bbox.setCenter(Vertices[0]);
00177                         for (i=1; i<Vertices.size(); ++i)
00178                                 bbox.extend(Vertices[i]);
00179                 }
00180 
00181                 return -bbox.getCenter();
00182         }

void NLPACS::CCollisionMeshBuild::link bool  linkInterior,
std::vector< std::string > &  errors
[inline]
 

Definition at line 185 of file collision_mesh_build.h.

References ItTLinkRelloc, NLPACS::CCollisionFace::Material, sint32, NLPACS::CCollisionFace::Surface, TLinkRelloc, uint, uint32, NLPACS::CCollisionFace::V, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.

Referenced by NLPACS::computeRetriever().

00186         {
00187                 uint                    i, j;
00188                 TLinkRelloc             relloc;
00189 
00190 
00191                 // check each edge of each face
00192                 for (i=0; i<Faces.size(); ++i)
00193                 {
00194                         if (Faces[i].Surface == CCollisionFace::ExteriorSurface && linkInterior ||
00195                                 Faces[i].Surface >= CCollisionFace::InteriorSurfaceFirst && !linkInterior)
00196                                 continue;
00197 
00198                         for (j=0; j<3; ++j)
00199                         {
00200                                 Faces[i].Edge[j] = -1;
00201 
00202                                 uint    edge = (j+2)%3;
00203                                 uint32  va = Faces[i].V[j],
00204                                                 vb = Faces[i].V[(j+1)%3];
00205 
00206                                 ItTLinkRelloc   it;
00207                                 if ((it = relloc.find(CEdgeKey(va, vb))) != relloc.end())
00208                                 {
00209                                         CCollisionFace  &left0 = Faces[(*it).second.Left];
00210                                         CCollisionFace  &left1 = Faces[i];
00211                                         // in this case, the left triangle of the edge has already been found.
00212                                         // should throw an error
00213                                         NLMISC::CVector eva = Vertices[va], evb = Vertices[vb];
00214                                         static char     buf[512];
00215                                         sprintf(buf, "Edge issue: (%.2f,%.2f,%.2f)-(%.2f,%.2f,%.2f) [left face already found]\n"
00216                                                                  "left.0:%d: v0:(%.2f,%.2f) v1:(%.2f,%.2f), v2:(%.2f,%.2f) surf=%d material=%d\n"
00217                                                                  "left.1:%d: v0:(%.2f,%.2f) v1:(%.2f,%.2f), v2:(%.2f,%.2f) surf=%d material=%d",
00218                                                                         eva.x, eva.y, eva.z, evb.x, evb.y, evb.z,
00219                                                                         (*it).second.Left, Vertices[left0.V[0]].x, Vertices[left0.V[0]].y, Vertices[left0.V[1]].x, Vertices[left0.V[1]].y, Vertices[left0.V[2]].x, Vertices[left0.V[2]].y, Faces[(*it).second.Left].Surface, Faces[(*it).second.Left].Material, 
00220                                                                         i,                 Vertices[left1.V[0]].x, Vertices[left1.V[0]].y, Vertices[left1.V[1]].x, Vertices[left1.V[1]].y, Vertices[left1.V[2]].x, Vertices[left1.V[2]].y, Faces[i].Surface, Faces[i].Material);
00221                                         errors.push_back(std::string(buf));
00222                                         continue;
00223 /*                                      nlerror("On face %d, edge %d: left side of edge (%d,%d) already linked to face %d",
00224                                                         i, edge, va, vb, (*it).second.Left);*/
00225                                 }
00226                                 else if ((it = relloc.find(CEdgeKey(vb, va))) != relloc.end())
00227                                 {
00228                                         // in this case, we must check the right face has been set yet
00229                                         if ((*it).second.Right != -1)
00230                                         {
00231                                                 CCollisionFace  &right0 = Faces[(*it).second.Right];
00232                                                 CCollisionFace  &right1 = Faces[i];
00233                                                 NLMISC::CVector eva = Vertices[va], evb = Vertices[vb];
00234                                                 static char     buf[512];
00235                                                 sprintf(buf, "Edge issue: (%.2f,%.2f,%.2f)-(%.2f,%.2f,%.2f) [right face already found]\n"
00236                                                                          "right.0:%d: v0:(%.2f,%.2f) v1:(%.2f,%.2f), v2:(%.2f,%.2f)\n"
00237                                                                          "right.1:%d: v0:(%.2f,%.2f) v1:(%.2f,%.2f), v2:(%.2f,%.2f)",
00238                                                                                 eva.x, eva.y, eva.z, evb.x, evb.y, evb.z,
00239                                                                                 (*it).second.Right, Vertices[right0.V[0]].x, Vertices[right0.V[0]].y, Vertices[right0.V[1]].x, Vertices[right0.V[1]].y, Vertices[right0.V[2]].x, Vertices[right0.V[2]].y,
00240                                                                                 i,                  Vertices[right1.V[0]].x, Vertices[right1.V[0]].y, Vertices[right1.V[1]].x, Vertices[right1.V[1]].y, Vertices[right1.V[2]].x, Vertices[right1.V[2]].y);
00241                                                 errors.push_back(std::string(buf));
00242                                                 continue;
00243 /*                                              nlerror("On face %d, edge %d: right side of edge (%d,%d) already linked to face %d",
00244                                                                 i, edge, vb, va, (*it).second.Right);*/
00245                                         }
00246 
00247                                         (*it).second.Right = i;
00248                                         (*it).second.RightEdge = edge;
00249                                 }
00250                                 else
00251                                 {
00252                                         // if the edge wasn't present yet, create it and set it up.
00253                                         relloc.insert(std::make_pair(CEdgeKey(va, vb), CEdgeInfo(i, edge, -1, -1)));
00254                                 }
00255                         }
00256                 }
00257 
00258                 // for each checked edge, update the edge info inside the faces
00259                 ItTLinkRelloc   it;
00260                 for (it=relloc.begin(); it!=relloc.end(); ++it)
00261                 {
00262                         sint32  left, leftEdge;
00263                         sint32  right, rightEdge;
00264 
00265                         // get the link info on the edge
00266                         left = (*it).second.Left;
00267                         leftEdge = (*it).second.LeftEdge;
00268                         right = (*it).second.Right;
00269                         rightEdge = (*it).second.RightEdge;
00270 
00271                         // update both faces
00272                         if (left != -1)
00273                                 Faces[left].Edge[leftEdge] = right;
00274                         if (right != -1)
00275                                 Faces[right].Edge[rightEdge] = left;
00276                 }
00277         }

void NLPACS::CCollisionMeshBuild::serial NLMISC::IStream f  )  [inline]
 

Definition at line 149 of file collision_mesh_build.h.

References NLMISC::IStream::serialCont().

00150         {
00151                 f.serialCont(Vertices);
00152                 f.serialCont(Faces);
00153         }

void NLPACS::CCollisionMeshBuild::transform const NLMISC::CMatrix tranfo  )  [inline]
 

Definition at line 162 of file collision_mesh_build.h.

References uint.

00163         {
00164                 uint    i;
00165                 for (i=0; i<Vertices.size(); ++i)
00166                         Vertices[i] = tranfo * Vertices[i];
00167         }

void NLPACS::CCollisionMeshBuild::translate const NLMISC::CVector translation  )  [inline]
 

Definition at line 155 of file collision_mesh_build.h.

References uint.

Referenced by NLPACS::computeRetriever().

00156         {
00157                 uint    i;
00158                 for (i=0; i<Vertices.size(); ++i)
00159                         Vertices[i] += translation;
00160         }


Field Documentation

std::vector<CCollisionFace> NLPACS::CCollisionMeshBuild::Faces
 

The faces of the mesh.

Definition at line 145 of file collision_mesh_build.h.

Referenced by NLPACS::buildExteriorMesh(), NLPACS::buildSnapping(), NLPACS::computeSurfaceBorders(), NLPACS::computeSurfaceQuadTree(), NLPACS::floodFillSurfaces(), NLPACS::followBorder(), NLPACS::CInteriorSurface::getFace(), NLPACS::CInteriorSurface::getNeighbor(), and NLPACS::resetEdgeFlags().

std::vector<NLMISC::CVector> NLPACS::CCollisionMeshBuild::Vertices
 

The vertices of the mesh.

Definition at line 142 of file collision_mesh_build.h.

Referenced by NLPACS::buildExteriorMesh(), NLPACS::buildSnapping(), NLPACS::computeSurfaceCenter(), NLPACS::computeSurfaceQuadTree(), and NLPACS::followBorder().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 14:10:12 2004 for NeL by doxygen 1.3.6