1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program 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
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "nel/3d/u_shape.h"
20 #include "nel/3d/mesh.h"
21 #include "nel/3d/mesh_multi_lod.h"
22 #include "nel/3d/u_visual_collision_mesh.h"
26 using namespace NLMISC
;
35 // ***************************************************************************
36 bool UShape::getMeshTriangles(std::vector
<NLMISC::CVector
> &vertices
, std::vector
<uint32
> &indices
) const
41 // **** try to get a CMeshGeom
42 CMesh
*mesh
= dynamic_cast<CMesh
*>(_Object
);
43 CMeshMultiLod
*meshMulti
= dynamic_cast<CMeshMultiLod
*>(_Object
);
44 const CMeshGeom
*meshGeom
= NULL
;
47 meshGeom
= &mesh
->getMeshGeom();
51 // get the first (bigger) meshGeom
52 if(meshMulti
->getNumSlotMesh())
54 meshGeom
= dynamic_cast<const CMeshGeom
*>(&meshMulti
->getMeshGeom(0));
61 // **** try to retrieve data
62 if(! (meshGeom
->retrieveVertices(vertices
) && meshGeom
->retrieveTriangles(indices
)) )
74 // ***************************************************************************
75 void UShape::getVisualCollisionMesh(UVisualCollisionMesh
&colMesh
) const
79 CMeshBase
*mesh
= dynamic_cast<CMeshBase
*>(_Object
);
82 // attach the possible col mesh
83 colMesh
.attach(mesh
->getVisualCollisionMesh());
87 // ***************************************************************************
88 uint
UShape::getNumMaterials() const
90 CMeshBase
*mesh
= dynamic_cast<CMeshBase
*>(_Object
);
93 return mesh
->getNbMaterial();
100 // ***************************************************************************
101 UMaterial
UShape::getMaterial(uint materialId
) const
103 CMeshBase
*mesh
= dynamic_cast<CMeshBase
*>(_Object
);
106 if(materialId
<mesh
->getNbMaterial())
107 return UMaterial(&mesh
->getMaterial(materialId
));
110 // fails => return NULL material
114 // ***************************************************************************
115 bool UShape::getDefaultOpacity() const
117 CMeshBase
*mesh
= dynamic_cast<CMeshBase
*>(_Object
);
120 return mesh
->getDefaultOpacity();
126 // ***************************************************************************
127 bool UShape::getDefaultTransparency() const
129 CMeshBase
*mesh
= dynamic_cast<CMeshBase
*>(_Object
);
132 return mesh
->getDefaultTransparency();