| 2400 | } |
| 2401 | |
| 2402 | struct OptionalError<Object*> parseLight(Scene& scene, const Element& element, Allocator& allocator) |
| 2403 | { |
| 2404 | LightImpl* light = allocator.allocate<LightImpl>(scene, element); |
| 2405 | |
| 2406 | light->lightType = static_cast<Light::LightType>(resolveEnumProperty(*light, "LightType", (int)Light::LightType::POINT)); |
| 2407 | |
| 2408 | const Element* prop = findChild(element, "Properties70"); |
| 2409 | if (prop) prop = prop->child; |
| 2410 | |
| 2411 | while (prop) |
| 2412 | { |
| 2413 | if (prop->id == "P" && prop->first_property) |
| 2414 | { |
| 2415 | if (prop->first_property->value == "Color") |
| 2416 | { |
| 2417 | light->color.r = (float)prop->getProperty(4)->getValue().toDouble(); |
| 2418 | light->color.g = (float)prop->getProperty(5)->getValue().toDouble(); |
| 2419 | light->color.b = (float)prop->getProperty(6)->getValue().toDouble(); |
| 2420 | } |
| 2421 | if (prop->first_property->value == "ShadowColor") |
| 2422 | { |
| 2423 | light->shadowColor.r = (float)prop->getProperty(4)->getValue().toDouble(); |
| 2424 | light->shadowColor.g = (float)prop->getProperty(5)->getValue().toDouble(); |
| 2425 | light->shadowColor.b = (float)prop->getProperty(6)->getValue().toDouble(); |
| 2426 | } |
| 2427 | else if (prop->first_property->value == "CastShadows") |
| 2428 | { |
| 2429 | light->castShadows = prop->getProperty(4)->getValue().toBool(); |
| 2430 | } |
| 2431 | else if (prop->first_property->value == "InnerAngle") |
| 2432 | { |
| 2433 | light->innerAngle = (float)prop->getProperty(4)->getValue().toDouble(); |
| 2434 | } |
| 2435 | else if (prop->first_property->value == "OuterAngle") |
| 2436 | { |
| 2437 | light->outerAngle = (float)prop->getProperty(4)->getValue().toDouble(); |
| 2438 | } |
| 2439 | else if (prop->first_property->value == "Intensity") |
| 2440 | { |
| 2441 | light->intensity = (float)prop->getProperty(4)->getValue().toDouble(); |
| 2442 | } |
| 2443 | } |
| 2444 | prop = prop->sibling; |
| 2445 | } |
| 2446 | |
| 2447 | scene.m_lights.push_back(light); |
| 2448 | return light; |
| 2449 | } |
| 2450 | |
| 2451 | struct OptionalError<Object*> parseCamera(Scene& scene, const Element& element, Allocator& allocator) |
| 2452 | { |
no test coverage detected