void AssimpScene::uncompress_recursive( aiNode* nd, float * arr_vertex, int arr_vertex_length, int & arr_vertex_index, float * arr_normal, int arr_normal_length, int * arr_indices, int arr_indices_size, int & arr_indices_index) { int arr_normal_index = 0; //aiScene* scene; for (int i = 0; i < scene->mNumMeshes; i++) { aiMesh *mesh = scene->mMeshes[i]; arr_vertex_index = uncompress_vertex(mesh, arr_vertex, arr_vertex_length, arr_vertex_index); uncompress_normal(mesh, arr_normal, arr_normal_length, arr_normal_index); arr_indices_index = uncompress_indices(mesh, arr_indices, arr_indices_size, arr_indices_index); } return; for (int n = 0; n < nd->mNumChildren; ++n) { uncompress_recursive(nd->mChildren[n], arr_vertex, arr_vertex_length, arr_vertex_index, arr_normal, arr_normal_length, arr_indices, arr_indices_size, arr_indices_index); } }
static void read_vertex_buffer(el_file_ptr file, float* buffer, const Uint32 vertex_count, const Uint32 vertex_size, const Uint32 options, const Uint32 format) { float temp[3]; Uint16 tmp[3]; Uint32 i, idx, offset; Uint8 color[4]; idx = 0; offset = el_tell(file); for (i = 0; i < vertex_count; i++) { el_seek(file, offset + i * vertex_size, SEEK_SET); if (half_uv(format)) { el_read(file, 2 * sizeof(Uint16), tmp); temp[0] = half_to_float(SDL_SwapLE16(tmp[0])); temp[1] = half_to_float(SDL_SwapLE16(tmp[1])); } else { el_read(file, 2 * sizeof(float), temp); temp[0] = SwapLEFloat(temp[0]); temp[1] = SwapLEFloat(temp[1]); } buffer[idx + 0] = temp[0]; buffer[idx + 1] = temp[1]; idx += 2; if (has_secondary_texture_coordinate(options)) { if (half_extra_uv(format)) { el_seek(file, 2 * sizeof(Uint16), SEEK_CUR); } else { el_seek(file, 2 * sizeof(float), SEEK_CUR); } } if (has_normal(options)) { if (compressed_normal(format)) { el_read(file, sizeof(Uint16), tmp); uncompress_normal(SDL_SwapLE16(tmp[0]), temp); } else { el_read(file, 3 * sizeof(float), temp); temp[0] = SwapLEFloat(temp[0]); temp[1] = SwapLEFloat(temp[1]); temp[2] = SwapLEFloat(temp[2]); } buffer[idx + 0] = temp[0]; buffer[idx + 1] = temp[1]; buffer[idx + 2] = temp[2]; idx += 3; } if (has_tangent(options)) { if (compressed_normal(format)) { el_seek(file, sizeof(Uint16), SEEK_CUR); } else { el_seek(file, 3 * sizeof(float), SEEK_CUR); } } if (half_position(format)) { el_read(file, 3 * sizeof(Uint16), tmp); temp[0] = half_to_float(SDL_SwapLE16(tmp[0])); temp[1] = half_to_float(SDL_SwapLE16(tmp[1])); temp[2] = half_to_float(SDL_SwapLE16(tmp[2])); } else { el_read(file, 3 * sizeof(float), temp); temp[0] = SwapLEFloat(temp[0]); temp[1] = SwapLEFloat(temp[1]); temp[2] = SwapLEFloat(temp[2]); } buffer[idx + 0] = temp[0]; buffer[idx + 1] = temp[1]; buffer[idx + 2] = temp[2]; idx += 3; if (has_color(options)) { el_read(file, 4 * sizeof(Uint8), color); memcpy(&buffer[idx], color, 4 * sizeof(Uint8)); idx += 1; } } }