public LightSceneNode Load(Colorf _diffuse, Colorf _specular, Colorf _ambient) { Diffuse = _diffuse; Specular = _specular; Ambient = _ambient; return Load(); }
/// <summary> /// Adds a light scene node to the scene /// </summary> /// <returns>The light</returns> /// <param name="parent">Parent from the node</param> /// <param name="position">Initial position of the light</param> /// <param name="color">Floating color of the light</param> /// <param name="radius">Radius of the light</param> /// <param name="id">ID (-1 for automatic assignation)</param> public LightSceneNode AddLightSceneNode(SceneNode parent, Vector3D position, Colorf color, float radius, int id) { IntPtr par = IntPtr.Zero; if(parent != null) par = parent.Raw; return (LightSceneNode) NativeElement.GetObject(SceneManager_AddLightSceneNode(_raw, par, position.ToUnmanaged(), color.ToUnmanaged(), radius, id), typeof(LightSceneNode)); }
public void SetAmbientLight(Colorf color) { SceneManager_SetAmbientLight(_raw, color.ToUnmanaged()); }
public static Color ToColor(Colorf color) { return ToColor(color.A, color.R, color.G, color.B); }
public override void Update(uint frame) { if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.High) { worldTime = Reference.Viewer.WorldTime; julianDay = getJulianDay(); } updateOnce = false; // Clamp the direction... could probably use better interpolation if (sunLight != null) { float diff = 0.2f; // diffuse --> ambient. float amount = 0; int index = 0; if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.High) { amount = worldTime.Minute < 30 ? (float)worldTime.Minute / 30.0f : ((float)worldTime.Minute - 30) / 30.0f; index = worldTime.Minute < 30 ? worldTime.Hour * 2 : worldTime.Hour * 2 + 1; if (Reference.Viewer.IsTickOn) sunLight.UpdateDirection(); } else if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.Low) { // [YK:NEXT] index = 13 * 2; // Fix 13h. sunLight.Rotation = new Vector3D(0.50f, 3.14f, 0) * OpenMetaverse.Utils.RAD_TO_DEG; } Colorf cBefore = directionalColorTable[index]; Colorf cAfter = directionalColorTable[0]; if (0 < index && index < directionalColorTable.Length - 1) { cAfter = directionalColorTable[index + 1]; } Colorf cc = new Colorf(1, Util.Lerp(cBefore.R, cAfter.R, amount), Util.Lerp(cBefore.G, cAfter.G, amount), Util.Lerp(cBefore.B, cAfter.B, amount)); sunLight.Diffuse = cc; sunLight.Ambient = new Colorf(1, cc.R * diff, cc.G * diff, cc.B * diff); if (Reference.Viewer.IsFixDirectional) { sunLight.Rotation = Reference.Viewer.DirectionalRotation; sunLight.Diffuse = Reference.Viewer.DirectionalDiffuseColor; sunLight.Ambient = Reference.Viewer.DirectionalAmbientColor; } sunLight.Update(); } base.Update(frame); }
public void Update(double realtime) { currentTime = realtime; dTime = currentTime - startTime; Color sp; J = J + (((double)dayspeed / 86400) / 1000.0f) * dTime; if (time_int_step == 0.0f) {//calculate sun interpolation positions prep_interpolation(J, sun_interpolation_speed * J1minute); //JulianToDate(J); counter_time = 0.0f; }//1440 counter_time += J - J1;//1440 time_int_step = counter_time / (sun_interpolation_speed * J1minute);//(1.0f/(sun_interpolation_speed*(1.0f/1440.0f)))*dTime; Vector3D sun_place = getInterpolated3df(sun_pos_from, sun_pos_to, (float)time_int_step); J1 = J; CameraSceneNode cam = smgr.ActiveCamera; Vector3D cameraPos = cam.AbsolutePosition; Vector3D vt;//billboard position vt.X = sun_place.X + cameraPos.X; vt.Y = sun_place.Y + cameraPos.Y; vt.Z = sun_place.Z + cameraPos.Z; sun.Position = vt; if (sun.Position.Z < cam.AbsolutePosition.Z) { sun.Visible = false; } else { sun.Visible = true; } //---sun movement end double inv = 1.0f - time_int_step; uvX = (float)((sun_angle_from * inv + sun_angle_to * time_int_step) + 90.0f) / 180; if (time_int_step >= 1.0f || time_int_step <= -1.0f) { time_int_step = 0.0f; } sp = dangus.GetPixel((int)Math.Round(128 * uvX), 123); driver.AmbientLight = sp; AmbientLight = Colorf.From((float)sp.A / 255f, (float)sp.R / 255f, (float)sp.G / 255f, (float)sp.B / 255f); //driver->setAmbientLight(video::SColor(255,sp.getRed(),sp.getGreen(),sp.getBlue())); sky.UV = uvX; startTime = currentTime; }