MCPcopy Create free account
hub / github.com/assimp/assimp / InternReadFile

Method InternReadFile

code/AssetLib/NFF/NFFLoader.cpp:201–1154  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Imports the given file into the given scene structure.

Source from the content-addressed store, hash-verified

199// ------------------------------------------------------------------------------------------------
200// Imports the given file into the given scene structure.
201void NFFImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
202 std::unique_ptr<IOStream> stream(pIOHandler->Open(file, "rb"));
203 if (!stream) {
204 throw DeadlyImportError("Failed to open NFF file ", file, ".");
205 }
206
207 // allocate storage and copy the contents of the file to a memory buffer
208 // (terminate it with zero)
209 std::vector<char> mBuffer2;
210 TextFileToBuffer(stream.get(), mBuffer2);
211 const char *buffer = &mBuffer2[0];
212
213 // mesh arrays - separate here to make the handling of the pointers below easier.
214 std::vector<MeshInfo> meshes;
215 std::vector<MeshInfo> meshesWithNormals;
216 std::vector<MeshInfo> meshesWithUVCoords;
217 std::vector<MeshInfo> meshesLocked;
218
219 char line[4096];
220 const char *lineEnd = &line[4096];
221 const char *sz;
222
223
224 // camera parameters
225 aiVector3D camPos, camUp(0.f, 1.f, 0.f), camLookAt(0.f, 0.f, 1.f);
226 ai_real angle = 45.f;
227 aiVector2D resolution;
228
229 bool hasCam = false;
230
231 MeshInfo *currentMeshWithNormals = nullptr;
232 MeshInfo *currentMesh = nullptr;
233 MeshInfo *currentMeshWithUVCoords = nullptr;
234
235 ShadingInfo s; // current material info
236
237 // degree of tessellation
238 unsigned int iTesselation = 4;
239
240 // some temporary variables we need to parse the file
241 unsigned int sphere = 0,
242 cylinder = 0,
243 cone = 0,
244 numNamed = 0,
245 dodecahedron = 0,
246 octahedron = 0,
247 tetrahedron = 0,
248 hexahedron = 0;
249
250 // lights imported from the file
251 std::vector<Light> lights;
252
253 // check whether this is the NFF2 file format
254 if (TokenMatch(buffer, "nff", 3)) {
255 const ai_real qnan = get_qnan();
256 const aiColor4D cQNAN = aiColor4D(qnan, 0.f, 0.f, 1.f);
257 const aiVector3D vQNAN = aiVector3D(qnan, 0.f, 0.f);
258

Callers

nothing calls this directly

Calls 15

DeadlyImportErrorFunction · 0.85
TokenMatchFunction · 0.85
get_qnanFunction · 0.85
aiColor4DClass · 0.85
aiVector3DClass · 0.85
GetNextLineFunction · 0.85
IsSpaceOrNewLineFunction · 0.85
strtoul10Function · 0.85
IsLineEndFunction · 0.85
strtoul16Function · 0.85
ASSIMP_itoa10Function · 0.85
is_qnanFunction · 0.85

Tested by

no test coverage detected