44 m_textureCoords = NULL;
51 if (
this == &original_obj) {
81 m_triangles = triangles_array;
126 m_textureCoords = map_array;
132 return m_textureCoords;
148 triangles_vertices = getLocationsArrayHavingIndicesArray<btVector3>(m_positions, triangles_obj.
getVerticesIndices());
149 triangles_normals = getLocationsArrayHavingIndicesArray<btVector3>(m_normals, triangles_obj.
getNormalsIndices());
150 triangles_texture_coords = getLocationsArrayHavingIndicesArray<TextureCoord>(m_textureCoords, triangles_obj.
getTextureCoordIndices());
163 std::vector<CLPolygon>* polygons_array =
new std::vector<CLPolygon>();
165 for (
unsigned int i = 0; i < m_triangles->
size(); i++) {
181 QVector<float> x_values, y_values, z_values;
182 for (std::vector<CLPolygon>::iterator it = polygons_array->begin();
183 it != polygons_array->end();
185 for (uint j = 0; j < (*it).getTriangleVertices()->size(); j++) {
186 btVector3 vec = (*it).getTriangleVertices()->
objectAtIndex(j);
187 x_values.append(vec.x());
188 y_values.append(vec.y());
189 z_values.append(vec.z());
197 float x_min = x_values.first();
198 float y_min = y_values.first();
199 float z_min = z_values.first();
201 float x_max = x_values.last();
202 float y_max = y_values.last();
203 float z_max = z_values.last();
205 float Lx = fabs(x_max - x_min);
206 float Ly = fabs(y_max - y_min);
207 float Lz = fabs(z_max - z_min);
210 float Cx = x_min + fabs(x_max - x_min) / 2.0f;
211 float Cy = y_min + fabs(y_max - y_min) / 2.0f;
212 float Cz = z_min + fabs(z_max - z_min) / 2.0f;
214 btVector3 centroid = btVector3(Cx, Cy, Cz);
216 float max_axis_length = qMax(Lx, qMax(Ly, Lz));
217 float scale_down_factor = 1.0f;
218 if (max_axis_length > k_CLMesh_MaxAxisLength) {
219 scale_down_factor = k_CLMesh_MaxAxisLength / max_axis_length;
222 std::vector<CLPolygon>* fixed_polygons =
new std::vector<CLPolygon>();
223 for (std::vector<CLPolygon>::iterator it = polygons_array->begin();
224 it != polygons_array->end();
226 std::vector<btVector3> vec_array = std::vector<btVector3>();
228 for (uint j = 0; j < polygon.getTriangleVertices()->size(); j++) {
230 btVector3 fixed_vec = vec - centroid;
231 fixed_vec *= scale_down_factor;
232 vec_array.push_back(fixed_vec);
235 polygon.setTriangleVertices(triangleVerticesArray);
236 fixed_polygons->push_back(polygon);
240 fixed_polygons->clear();
243 return polygons_array;
void setTriangleMaps(CArray< TextureCoord > *maps)
CArray< btVector3 > * normals() const
CArray< int > * getVerticesIndices() const
CArray< btVector3 > * getTriangleVertices() const
CArray< btVector3 > * positions() const
void setTriangles(CArray< CLTriangles > *triangles_array)
CArray< int > * getTextureCoordIndices() const
void setNormals(CArray< btVector3 > *normals)
CArray< CLTriangles > * triangles() const
bool valueLessThan(const float &p1, const float &p2)
valueLessThan Used by qSort method
void setMapArray(CArray< TextureCoord > *map_array)
void setPositions(CArray< btVector3 > *positions)
CArray< CLPolygon > * getPolygonsArray()
T objectAtIndex(unsigned int index) const
void setMaterialId(const std::string &material_id)
CLMesh & operator=(const CLMesh &mesh)
CArray< TextureCoord > * mapArray() const
CArray< int > * getNormalsIndices() const
virtual void copyValuesFromObject(const CLMesh &mesh)
CArray< CLPolygon > * fixPolygonsArray(std::vector< CLPolygon > *polygons_array)
CLPolygon getPolygonForTrianglesIndex(unsigned int index)
const std::string & getMaterialId() const
void setTriangleNormals(CArray< btVector3 > *normals)
unsigned int size() const
static CArray * fromStdVector(std::vector< T > *vec)
void setTriangleVertices(CArray< btVector3 > *vertices)