------------------------------------------------------------------------------------------------
| 358 | |
| 359 | // ------------------------------------------------------------------------------------------------ |
| 360 | void Discreet3DSImporter::ParseChunk(const char *name, unsigned int num) { |
| 361 | ASSIMP_3DS_BEGIN_CHUNK(); |
| 362 | |
| 363 | // IMPLEMENTATION NOTE; |
| 364 | // Cameras or lights define their transformation in their parent node and in the |
| 365 | // corresponding light or camera chunks. However, we read and process the latter |
| 366 | // to be able to return valid cameras/lights even if no scenegraph is given. |
| 367 | |
| 368 | // get chunk type |
| 369 | switch (chunk.Flag) { |
| 370 | case Discreet3DS::CHUNK_TRIMESH: { |
| 371 | // this starts a new triangle mesh |
| 372 | mScene->mMeshes.emplace_back(std::string(name, num)); |
| 373 | |
| 374 | // Read mesh chunks |
| 375 | ParseMeshChunk(); |
| 376 | } break; |
| 377 | |
| 378 | case Discreet3DS::CHUNK_LIGHT: { |
| 379 | // This starts a new light |
| 380 | auto *light = new aiLight(); |
| 381 | mScene->mLights.push_back(light); |
| 382 | |
| 383 | light->mName.Set(std::string(name, num)); |
| 384 | |
| 385 | // First read the position of the light |
| 386 | light->mPosition.x = mStream->GetF4(); |
| 387 | light->mPosition.y = mStream->GetF4(); |
| 388 | light->mPosition.z = mStream->GetF4(); |
| 389 | |
| 390 | light->mColorDiffuse = aiColor3D(1.f, 1.f, 1.f); |
| 391 | |
| 392 | // Now check for further subchunks |
| 393 | if (!bIsPrj) /* fixme */ |
| 394 | ParseLightChunk(); |
| 395 | |
| 396 | // The specular light color is identical the the diffuse light color. The ambient light color |
| 397 | // is equal to the ambient base color of the whole scene. |
| 398 | light->mColorSpecular = light->mColorDiffuse; |
| 399 | light->mColorAmbient = mClrAmbient; |
| 400 | |
| 401 | if (light->mType == aiLightSource_UNDEFINED) { |
| 402 | // It must be a point light |
| 403 | light->mType = aiLightSource_POINT; |
| 404 | } |
| 405 | } break; |
| 406 | |
| 407 | case Discreet3DS::CHUNK_CAMERA: { |
| 408 | // This starts a new camera |
| 409 | auto *camera = new aiCamera(); |
| 410 | mScene->mCameras.push_back(camera); |
| 411 | camera->mName.Set(std::string(name, num)); |
| 412 | |
| 413 | // First read the position of the camera |
| 414 | camera->mPosition.x = mStream->GetF4(); |
| 415 | camera->mPosition.y = mStream->GetF4(); |
| 416 | camera->mPosition.z = mStream->GetF4(); |
| 417 |
nothing calls this directly
no test coverage detected