//! Reads attributes of the scene node. void CLightSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) { LightData.AmbientColor = in->getAttributeAsColorf("AmbientColor"); LightData.DiffuseColor = in->getAttributeAsColorf("DiffuseColor"); LightData.SpecularColor = in->getAttributeAsColorf("SpecularColor"); //TODO: clearify Radius and Linear Attenuation #if 0 setRadius ( in->getAttributeAsFloat("Radius") ); #else LightData.Radius = in->getAttributeAsFloat("Radius"); #endif if (in->existsAttribute("Attenuation")) // might not exist in older files LightData.Attenuation = in->getAttributeAsVector3d("Attenuation"); if (in->existsAttribute("OuterCone")) // might not exist in older files LightData.OuterCone = in->getAttributeAsFloat("OuterCone"); if (in->existsAttribute("InnerCone")) // might not exist in older files LightData.InnerCone = in->getAttributeAsFloat("InnerCone"); if (in->existsAttribute("Falloff")) // might not exist in older files LightData.Falloff = in->getAttributeAsFloat("Falloff"); LightData.CastShadows = in->getAttributeAsBool("CastShadows"); LightData.Type = (video::E_LIGHT_TYPE)in->getAttributeAsEnumeration("LightType", video::LightTypeNames); doLightRecalc (); ILightSceneNode::deserializeAttributes(in, options); }
/** Outside this radius the light won't lighten geometry and cast no shadows. Setting the radius will also influence the attenuation, setting it to (0,1/radius,0). If you want to override this behavior, set the attenuation after the radius. \param radius The new radius. */ void CLightSceneNode::setRadius(f32 radius) { //__android_log_print(ANDROID_LOG_INFO,"Enron","CLightSceneNode:setRadius()"); LightData.Radius=radius; LightData.Attenuation.set(0.f, 1.f/radius, 0.f); doLightRecalc(); }
//! pre render event void CLightSceneNode::OnRegisterSceneNode() { doLightRecalc(); if (IsVisible) SceneManager->registerNodeForRendering(this, ESNRP_LIGHT); ISceneNode::OnRegisterSceneNode(); }
//! constructor CLightSceneNode::CLightSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, const core::vector3df& position, video::SColorf color, f32 radius) : ILightSceneNode(parent, mgr, id, position) { #ifdef _DEBUG setDebugName("CLightSceneNode"); #endif LightData.DiffuseColor = color; // set some useful specular color LightData.SpecularColor = color.getInterpolated(video::SColor(255,255,255,255),0.7f); setRadius(radius); doLightRecalc(); }
/** Outside this radius the light won't lighten geometry and cast no shadows. Setting the radius will also influence the attenuation, setting it to (0,1/radius,0). If you want to override this behavior, set the attenuation after the radius. \param radius The new radius. */ void CLightSceneNode::setRadius(f32 radius) { LightData.Radius=radius; LightData.Attenuation.set(0.f, 1.f/radius, 0.f); doLightRecalc(); }