public LightBehaviour Register(OpenSpace.ROM.LightInfo light) { LightBehaviour l = lights.FirstOrDefault(li => li.liROM == light); if (l == null) { GameObject gao = new GameObject("LightInfo @ " + light.Offset); l = gao.AddComponent <LightBehaviour>(); l.Init(this, light); l.transform.parent = transform; lights.Add(l); } return(l); }
public void Init(LightManager lm, OpenSpace.ROM.LightInfo li) { this.liROM = li; this.lightManager = lm; name = "Light @ " + li.Offset + " | " + "Type: " + Type + " - Far: " + Far + " - Near: " + Near + //" - FogBlendNear: " + FogBlendNear + " - FogBlendFar: " + FogBlendFar + " - AlphaLF: " + AlphaLightFlag + " - PaintingLF: " + PaintingLightFlag + " - ObjectLF: " + li.objectLightedFlag; transform.SetParent(lm.transform); liROM.transform.Apply(gameObject); transform.localRotation = transform.localRotation * Quaternion.Euler(-90, 0, 0); pos = transform.localPosition; rot = transform.localRotation; scl = transform.localScale; //color = new Color(Mathf.Clamp01(r3l.color.x), Mathf.Clamp01(r3l.color.y), Mathf.Clamp01(r3l.color.z), Mathf.Clamp01(r3l.color.w)); intensity = Mathf.Max(li.color.x, li.color.y, li.color.z); if (intensity > 1) { Vector3 colorVector = new Vector3(li.color.x / intensity, li.color.y / intensity, li.color.z / intensity); color = new Color(Mathf.Clamp01(colorVector.x), Mathf.Clamp01(colorVector.y), Mathf.Clamp01(colorVector.z), Mathf.Clamp01(li.color.w)); } else if (intensity > 0) { color = new Color(Mathf.Clamp01(li.color.x), Mathf.Clamp01(li.color.y), Mathf.Clamp01(li.color.z), Mathf.Clamp01(li.color.w)); } else { // shadow, can't display it since colors are additive in Unity } backgroundColor = new Color(Mathf.Clamp01(li.backgroundColor.x), Mathf.Clamp01(li.backgroundColor.y), Mathf.Clamp01(li.backgroundColor.z), Mathf.Clamp01(li.backgroundColor.w)); /*if (li.alphaLightFlag != 0) { * color = new Color(color.r * li.color.w, color.g * li.color.w, color.b * li.color.w); * backgroundColor = new Color( * backgroundColor.r * li.background_color.w, * backgroundColor.g * li.background_color.w, * backgroundColor.b * li.background_color.w); * }*/ col = color; bckCol = backgroundColor; loaded = true; }