----------------------------------------------------------------------------- Recurse through the collada scene to add s to the Torque scene
| 59 | //----------------------------------------------------------------------------- |
| 60 | // Recurse through the collada scene to add <light>s to the Torque scene |
| 61 | static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup* group) |
| 62 | { |
| 63 | const domNode* node = dynamic_cast<ColladaAppNode*>(appNode)->getDomNode(); |
| 64 | |
| 65 | for (S32 iLight = 0; iLight < node->getInstance_light_array().getCount(); iLight++) { |
| 66 | |
| 67 | domInstance_light* instLight = node->getInstance_light_array()[iLight]; |
| 68 | domLight* p_domLight = daeSafeCast<domLight>(instLight->getUrl().getElement()); |
| 69 | if (!p_domLight) { |
| 70 | Con::warnf("Failed to find light for URL \"%s\"", instLight->getUrl().getOriginalURI()); |
| 71 | continue; |
| 72 | } |
| 73 | |
| 74 | String lightName = Sim::getUniqueName(_GetNameOrId(node)); |
| 75 | const char* lightType = ""; |
| 76 | |
| 77 | domLight::domTechnique_common* technique = p_domLight->getTechnique_common(); |
| 78 | if (!technique) { |
| 79 | Con::warnf("No <technique_common> for light \"%s\"", lightName.c_str()); |
| 80 | continue; |
| 81 | } |
| 82 | |
| 83 | LightBase* pLight = 0; |
| 84 | LinearColorF color(LinearColorF::WHITE); |
| 85 | Point3F attenuation(0, 1, 1); |
| 86 | |
| 87 | if (technique->getAmbient()) { |
| 88 | domLight::domTechnique_common::domAmbient* ambient = technique->getAmbient(); |
| 89 | // No explicit support for ambient lights, so use a PointLight instead |
| 90 | lightType = "ambient"; |
| 91 | pLight = new PointLight; |
| 92 | resolveLightColor(ambient, color); |
| 93 | } |
| 94 | else if (technique->getDirectional()) { |
| 95 | domLight::domTechnique_common::domDirectional* directional = technique->getDirectional(); |
| 96 | // No explicit support for directional lights, so use a SpotLight instead |
| 97 | lightType = "directional"; |
| 98 | pLight = new SpotLight; |
| 99 | resolveLightColor(directional, color); |
| 100 | } |
| 101 | else if (technique->getPoint()) { |
| 102 | domLight::domTechnique_common::domPoint* point = technique->getPoint(); |
| 103 | lightType = "point"; |
| 104 | pLight = new PointLight; |
| 105 | resolveLightColor(point, color); |
| 106 | resolveLightAttenuation(point, attenuation); |
| 107 | } |
| 108 | else if (technique->getSpot()) { |
| 109 | domLight::domTechnique_common::domSpot* spot = technique->getSpot(); |
| 110 | lightType = "spot"; |
| 111 | pLight = new SpotLight; |
| 112 | resolveLightColor(spot, color); |
| 113 | resolveLightAttenuation(spot, attenuation); |
| 114 | } |
| 115 | else |
| 116 | continue; |
| 117 | |
| 118 | Con::printf("Adding <%s> light \"%s\" as a %s", lightType, lightName.c_str(), pLight->getClassName()); |
no test coverage detected