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

Method LoadObjectSection

code/AssetLib/AC/ACLoader.cpp:195–373  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Parse an object section in an AC file

Source from the content-addressed store, hash-verified

193// ------------------------------------------------------------------------------------------------
194// Parse an object section in an AC file
195bool AC3DImporter::LoadObjectSection(std::vector<Object> &objects) {
196 if (!TokenMatch(mBuffer.data, "OBJECT", 6)) {
197 return false;
198 }
199
200 SkipSpaces(&mBuffer.data, mBuffer.end);
201
202 ++mNumMeshes;
203
204 objects.emplace_back();
205 Object &obj = objects.back();
206
207 aiLight *light = nullptr;
208 if (!ASSIMP_strincmp(mBuffer.data, "light", 5)) {
209 // This is a light source. Add it to the list
210 mLights->push_back(light = new aiLight());
211
212 // Return a point light with no attenuation
213 light->mType = aiLightSource_POINT;
214 light->mColorDiffuse = light->mColorSpecular = aiColor3D(1.f, 1.f, 1.f);
215 light->mAttenuationConstant = 1.f;
216
217 // Generate a default name for both the light source and the node
218 light->mName.length = ::ai_snprintf(light->mName.data, AI_MAXLEN, "ACLight_%i", static_cast<unsigned int>(mLights->size()) - 1);
219 obj.name = std::string(light->mName.data);
220
221 ASSIMP_LOG_VERBOSE_DEBUG("AC3D: Light source encountered");
222 obj.type = Object::Light;
223 } else if (!ASSIMP_strincmp(mBuffer.data, "group", 5)) {
224 obj.type = Object::Group;
225 } else if (!ASSIMP_strincmp(mBuffer.data, "world", 5)) {
226 obj.type = Object::World;
227 } else {
228 obj.type = Object::Poly;
229 }
230
231 while (GetNextLine()) {
232 if (TokenMatch(mBuffer.data, "kids", 4)) {
233 SkipSpaces(&mBuffer.data, mBuffer.end);
234 unsigned int num = strtoul10(mBuffer.data, &mBuffer.data);
235 GetNextLine();
236 if (num) {
237 // load the children of this object recursively
238 obj.children.reserve(num);
239 for (unsigned int i = 0; i < num; ++i) {
240 if (!LoadObjectSection(obj.children)) {
241 ASSIMP_LOG_WARN("AC3D: wrong number of kids");
242 break;
243 }
244 }
245 }
246 return true;
247 } else if (TokenMatch(mBuffer.data, "name", 4)) {
248 SkipSpaces(&mBuffer.data, mBuffer.data);
249 mBuffer.data = AcGetString(mBuffer.data, mBuffer.end, obj.name);
250
251 // If this is a light source, we'll also need to store
252 // the name of the node in it.

Callers

nothing calls this directly

Calls 15

TokenMatchFunction · 0.85
ASSIMP_strincmpFunction · 0.85
ai_snprintfFunction · 0.85
GetNextLineFunction · 0.85
strtoul10Function · 0.85
AcGetStringFunction · 0.85
TAcCheckedLoadFloatArrayFunction · 0.85
aiVector2DClass · 0.85
fast_atofFunction · 0.85
DeadlyImportErrorFunction · 0.85
IsNumericFunction · 0.85
strtoul_cppstyleFunction · 0.85

Tested by

no test coverage detected