bool ACAMTLoader::LoadFromFile( const CHAR* path, AMT_MODEL* outModel) { // open the file mpFile = fopen( path, "rb" ); if( !mpFile ) return false; ReadHeader(outModel); ReadVertices(outModel); ReadFaces(outModel); ReadMesh(outModel); ReadMaterials(outModel); ReadJoints(outModel); ReadAnimations(outModel); return CloseFile( true ); };
bool triebWerk::COBJParser::LoadOBJ(const char * a_pPath) { std::cout << a_pPath << std::endl; m_Vertices = new CMesh::SVertex[m_MAX_VERTICES]; m_VertexPoint = new DirectX::XMFLOAT3[m_MAX_VERTICES]; m_UV = new DirectX::XMFLOAT2[m_MAX_VERTICES]; m_Normal = new DirectX::XMFLOAT3[m_MAX_VERTICES]; //Let the FileReader preload the data bool success = ReadData(a_pPath); if (!success) return false; //Reserve memory for the string char* line; do { //Get Line to read line = GetLine(); if (line[0] == '#' || line[0] == '\r') continue; if (BeginLineWith(line, "v ")) { AddVertexPoint(line); } else if(BeginLineWith(line, "vt ")) { AddUV(line); } else if(BeginLineWith(line, "vn ")) { AddNormal(line); } else if(BeginLineWith(line, "f ")) { ReadFaces(line); } } while (ReachedEndOfFile() != true); if (m_VertexCount > 0 ) { m_pVertices = m_Vertices; //m_pIndices = &m_Indices[0]; } else { return false; } m_IndexCount = m_VertexCount; delete[] m_UV; delete[] m_Normal; delete[] m_VertexPoint; return true; }