#include <u_shape.h>
Nevrax France
Definition at line 47 of file u_shape.h.
Public Member Functions | |
void | attach (class IShape *shape) |
Attach a IShape to this proxy. | |
bool | cameraCollisionable () const |
bool | empty () const |
return true if the proxy is empty() (not attached) | |
bool | getMeshTriangles (std::vector< NLMISC::CVector > &vertices, std::vector< uint32 > &indices) const |
UShape () | |
Proxy interface. | |
Private Attributes | |
IShape * | _Shape |
|
Proxy interface.
Definition at line 42 of file u_shape.cpp.
00042 : _Shape(NULL) 00043 { 00044 } |
|
Attach a IShape to this proxy.
Definition at line 47 of file u_shape.cpp. Referenced by NL3D::CShapeBankUser::getShape().
00048 { 00049 _Shape= shape; 00050 } |
|
Return true if this mesh is candidate for Camera Collision For now return true if have some lightmap! Definition at line 125 of file u_shape.cpp. References NL3D::CMeshBase::_LightInfos.
00126 { 00127 /* For now do it easy, take only lightmapped (ie big) objects. An object that is lightmapped 00128 should have some lightInfos 00129 */ 00130 CMeshBase *mesh= dynamic_cast<CMeshBase*>(_Shape); 00131 if(mesh) 00132 { 00133 return !mesh->_LightInfos.empty(); 00134 } 00135 else 00136 return false; 00137 } |
|
return true if the proxy is empty() (not attached)
Definition at line 56 of file u_shape.h.
00056 {return _Shape==NULL;} |
|
Get the mesh under Triangle Form. For now only CMesh and CMeshMultiLod (CMeshGeom only) are supported.
Definition at line 53 of file u_shape.cpp. References NL3D::CMeshMultiLod::getMeshGeom(), NL3D::CMesh::getMeshGeom(), NL3D::CMeshGeom::getNbMatrixBlock(), NL3D::CMeshGeom::getNbRdrPass(), NL3D::CMeshMultiLod::getNumSlotMesh(), NL3D::CPrimitiveBlock::getNumTri(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CMeshGeom::getRdrPassPrimitiveBlock(), NL3D::CPrimitiveBlock::getTriPointer(), NL3D::CMeshGeom::getVertexBuffer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), uint, uint32, and uint8.
00054 { 00055 if(!_Shape) 00056 return false; 00057 00058 // **** try to get a CMeshGeom 00059 CMesh *mesh= dynamic_cast<CMesh*>(_Shape); 00060 CMeshMultiLod *meshMulti= dynamic_cast<CMeshMultiLod*>(_Shape); 00061 const CMeshGeom *meshGeom= NULL; 00062 if(mesh) 00063 { 00064 meshGeom= &mesh->getMeshGeom(); 00065 } 00066 else if(meshMulti) 00067 { 00068 // get the first (bigger) meshGeom 00069 if(meshMulti->getNumSlotMesh()) 00070 { 00071 meshGeom= dynamic_cast<const CMeshGeom*>(&meshMulti->getMeshGeom(0)); 00072 } 00073 } 00074 00075 if(!meshGeom) 00076 return false; 00077 00078 // **** Build the vertices and indices 00079 uint i; 00080 vertices.clear(); 00081 indices.clear(); 00082 00083 // build vertices 00084 const CVertexBuffer &vb= meshGeom->getVertexBuffer(); 00085 vertices.resize(vb.getNumVertices()); 00086 const uint8 *pVert= (const uint8*)vb.getVertexCoordPointer(0); 00087 uint vSize= vb.getVertexSize(); 00088 for(i=0;i<vertices.size();i++) 00089 { 00090 vertices[i]= *(const CVector*)pVert; 00091 pVert+= vSize; 00092 } 00093 00094 // count numTris 00095 uint numTris= 0; 00096 for(i=0;i<meshGeom->getNbMatrixBlock();i++) 00097 { 00098 for(uint rp=0;rp<meshGeom->getNbRdrPass(i);rp++) 00099 { 00100 numTris+= meshGeom->getRdrPassPrimitiveBlock(i, rp).getNumTri(); 00101 } 00102 } 00103 indices.resize(numTris*3); 00104 00105 // build indices 00106 uint triIdx= 0; 00107 for(i=0;i<meshGeom->getNbMatrixBlock();i++) 00108 { 00109 for(uint rp=0;rp<meshGeom->getNbRdrPass(i);rp++) 00110 { 00111 const CPrimitiveBlock &pb= meshGeom->getRdrPassPrimitiveBlock(i, rp); 00112 // copy 00113 memcpy(&indices[triIdx*3], pb.getTriPointer(), pb.getNumTri()*3*sizeof(uint32)); 00114 // next 00115 triIdx+= pb.getNumTri(); 00116 } 00117 } 00118 00119 // ok! 00120 return true; 00121 } |
|
|