void writeIndices(t_Node* ptTree, FILE* ofp) { if(ptTree->nId == INTERNAL){ writeIndices(ptTree->ptLeft, ofp); writeIndices(ptTree->ptRight, ofp); } else{ fprintf(ofp,"%d,",ptTree->nId); } }
void G3D::write(AbstractWriter& writer, const GeometrySoA& geometry, uint32_t vertexType) { if (writer.isOpen()) { if (vertexType == SoA) { writeHeader(writer, geometry.info); writeContent(writer, geometry); } else if (vertexType == AoS) { writeHeader(writer, geometry.info, &vertexType); writeIndices(writer, geometry.indices, geometry.info); auto vertices = convertVertices(geometry.vertexAttributes, geometry.info); writeVertices(writer, vertices, geometry.info); } } }
void G3D::write(const std::string & file, const GeometryAoS * const geometry, const uint32_t vertexType) { std::fstream fs; fs.open(file.c_str(), std::fstream::out | std::fstream::binary | std::fstream::trunc); if (fs.is_open()) { if (vertexType == AoS) { writeHeader(fs, geometry->info); writeContent(fs, *geometry); } else if (vertexType == SoA) { writeHeader(fs, geometry->info, &vertexType); writeIndices(fs, geometry->indices, geometry->info); std::vector<float*> vertexAttributes; convertVertices(geometry->vertices, vertexAttributes, geometry->info); writeVertices(fs, vertexAttributes, geometry->info); cleanVertices(vertexAttributes); } fs.close(); } }
void G3D::writeContent(std::fstream & fs, const GeometryAoS & geometry) { writeIndices(fs, geometry.indices, geometry.info); writeVertices(fs, geometry.vertices, geometry.info); }
void G3D::writeContent(AbstractWriter& writer, const GeometrySoA& geometry) { writeIndices(writer, geometry.indices, geometry.info); writeVertexAttributes(writer, geometry.vertexAttributes, geometry.info); }
void G3D::writeContent(AbstractWriter& writer, const GeometryAoS& geometry) { writeIndices(writer, geometry.indices, geometry.info); writeVertices(writer, geometry.vertices, geometry.info); }