public override bool Equals(object obj) { if (!(obj is LightProperties)) { return(false); } LightProperties other = (LightProperties)obj; return (other.enabled == enabled && other.type == type && other.bounceIntensity == bounceIntensity && other.color == color && other.colorTemperature == colorTemperature && other.cookie == cookie && other.cookieSize == cookieSize && other.cullingMask == cullingMask && other.intensity == intensity && other.range == range && other.shadowBias == shadowBias && other.shadowCustomResolution == shadowCustomResolution && other.shadowNearPlane == shadowNearPlane && other.shadowNormalBias == shadowNormalBias && other.shadows == shadows && other.spotAngle == spotAngle); }
public override void RecreateFromXml(LayerEditor parentLayer, XElement xml) { base.RecreateFromXml(parentLayer, xml); ParentLayer = parentLayer; _properties = xml.CertainElement(@"LightProperties").DeserializedAs <LightProperties>( ); }
/// <summary> /// Search which is the nearby light for the current object. /// </summary> /// <returns>The nearby light.</returns> private LightProperties SearchForNearbyLight() { LightProperties nearbyLight = null; float maxIntensity = 0; Vector3 objectPosition = this.Matrices.World.Translation; if (this.renderManager != null) { foreach (var light in this.renderManager.Lights) { if (light.IsLightEnabled && light.Intensity > 0) { float intensity = 0; if (light is DirectionalLightProperties) { intensity = light.Intensity; } else { Vector3 lightPosition = Vector3.Zero; float lightRange = 0; if (light is PointLightProperties) { PointLightProperties pointLight = light as PointLightProperties; lightPosition = pointLight.Position; lightRange = pointLight.LightRange; } else if (light is SpotLightProperties) { SpotLightProperties spotLight = light as SpotLightProperties; lightPosition = spotLight.Position; lightRange = spotLight.LightRange; } float distance = (lightPosition - objectPosition).Length(); if (distance < lightRange) { intensity = light.Intensity * (1 - (distance / lightRange)); } } intensity *= light.Color.Luminance; if (intensity > maxIntensity) { maxIntensity = intensity; nearbyLight = light; } } } } return(nearbyLight); }
public void onObjectLightChange(Color color) { GameObject obj = Camera.main.GetComponent <Inspector>().selectedItem; obj.transform.GetChild(0).GetComponent <Renderer>().material.color = color; LightProperties cp = obj.GetComponent <LightProperties>(); cp.objectColor = color; }
private void CreateLightProperties(object light, bool externallySet) { if (propertyGrid.InvokeRequired) { var d = new ThreadSafePropertyGrid(CreateLightProperties); propertyGrid.Invoke(d, new object[] { light }); } else { LightProperties lightProperties = new LightProperties(); var lightNode = ((Node)light).GetComponent <Light>(); if (light != null) { lightProperties.Node = lightNode; lightProperties.Name = lightNode.Node.Name; lightProperties.Enabled = lightNode.Enabled; lightProperties.Position = lightNode.Node.Position; lightProperties.Rotation = lightNode.Node.Rotation; lightProperties.Scale = lightNode.Node.Scale; lightProperties.PulsarApplication = _mainApplication; lightProperties.Scene = _scene; lightProperties.AspectRatio = lightNode.AspectRatio; lightProperties.Brightness = lightNode.Brightness; lightProperties.Colour = System.Drawing.Color.FromArgb((int)lightNode.Color.A, (int)lightNode.Color.R, (int)lightNode.Color.G, (int)lightNode.Color.B); lightProperties.ColourFromTemperature = System.Drawing.Color.FromArgb((int)lightNode.ColorFromTemperature.A, (int)lightNode.ColorFromTemperature.R, (int)lightNode.ColorFromTemperature.G, (int)lightNode.ColorFromTemperature.B); lightProperties.EffectiveColour = System.Drawing.Color.FromArgb((int)lightNode.EffectiveColor.A, (int)lightNode.EffectiveColor.R, (int)lightNode.EffectiveColor.G, (int)lightNode.EffectiveColor.B); lightProperties.Temperature = lightNode.Temperature; lightProperties.UsePhysicalValues = lightNode.UsePhysicalValues; lightProperties.EffectiveSpecularIntensity = lightNode.EffectiveSpecularIntensity; lightProperties.SpecularIntensity = lightNode.SpecularIntensity; lightProperties.FadeDistance = lightNode.FadeDistance; lightProperties.FieldOfView = lightNode.Fov; lightProperties.Length = lightNode.Length; lightProperties.LightType = lightNode.LightType; lightProperties.PerVertex = lightNode.PerVertex; lightProperties.Radius = lightNode.Radius; lightProperties.Range = lightNode.Range; lightProperties.ShadowFadeDistance = lightNode.ShadowFadeDistance; lightProperties.ShadowIntensity = lightNode.ShadowIntensity; lightProperties.ShadowMaximumExtrusion = lightNode.ShadowMaxExtrusion; lightProperties.ShadowNearFarRatio = lightNode.ShadowNearFarRatio; lightProperties.ShadowResolution = lightNode.ShadowResolution; propertyGrid.SelectedObject = lightProperties; _currentPropertyNode = lightProperties; } } }
protected override ChangeType CalculateDeltaChanges() { ChangeType changeType = ChangeType.None; LightProperties newProperties = new LightProperties(this.lightBroadcaster); if (newProperties != previousProperties) { previousProperties = newProperties; changeType |= ChangeType.Properties; } return(changeType); }
public virtual void Duplicate(ObjectProperties objectProperties) { LightProperties prop = (LightProperties)objectProperties; this.intensity = prop.intensity; this.range = prop.range; this.nightOnly = prop.nightOnly; this.lightColor = prop.lightColor; this.objectColor = prop.objectColor; GetComponentInChildren <Light>().intensity = intensity; GetComponentInChildren <Light>().range = range; GetComponentInChildren <Light>().color = lightColor; transform.GetChild(0).GetComponent <Renderer>().material.color = objectColor; }
public void LightRefresh(string message) { LightProperties lp = JsonUtility.FromJson <LightProperties>(message); switch (lp.lightType) { case LightType.Spot: spotLightModel.SetActive(lp.isRendering); break; case LightType.Point: sunPointLightModel.SetActive(lp.isRendering); break; } }
public void mirror() { //if (mirrorLight) { //lightProp = GetComponent<LightProperties>(); //if (!(this is LightProperties)) lightProp = GetComponent<LightProperties>(); lightProp = null; List<LightProperties> props = null; props = GetComponentsInChildren<LightProperties>().ToList(); if (props.Count > 0) { foreach (var lightProperties in props) { if (lightProperties != this && lightProperties.mirrorLight == false) { lightProp = lightProperties; break; } } } if (lightProp == null) props = transform.parent.GetComponentsInChildren<LightProperties>().ToList(); if (props.Count > 0) { foreach (var lightProperties in props) { if (lightProperties != this && lightProperties.mirrorLight == false) { lightProp = lightProperties; break; } } } //if (lightProp == null) props = GetComponentsInParent<LightProperties>().ToList(); //if (props.Count > 0) { // foreach (var lightProperties in props) { // if (lightProperties != this && lightProperties.mirrorLight == false) { // lightProp = lightProperties; // break; // } // } //} if (lightProp == null) { //mirrorLight = false; Debug.Log("failed to mirrorLight, no Light found", this); } else { lightProp.AddToFollowers(this); //_color = lightProp._color; //randomDelay = lightProp._randomDelayRange; } //} }
public override void CreateInDesignMode(LayerEditor parentLayer, IEntityCreationProperties creationProperties) { ParentLayer = parentLayer; _properties = new LightProperties { Visible = true, IsOn = true, Range = 100f, Color = Color.White, FieldOfView = MathHelper.TwoPi, Intensity = 1, ShadowType = convertShadowType(ShadowType.Solid), Position = MouseStatus.WorldPosition, TextureSize = 128 }; }
private static LightProperties GetLightProperties(int index) { for (var i = cachedLightProperties.Count; i <= index; i++) { var properties = new LightProperties(); var prefix = "_Light" + (i + 1); properties.Direction = Shader.PropertyToID(prefix + "Direction"); properties.Position = Shader.PropertyToID(prefix + "Position"); properties.Color = Shader.PropertyToID(prefix + "Color"); properties.Scatter = Shader.PropertyToID(prefix + "Scatter"); cachedLightProperties.Add(properties); } return(cachedLightProperties[index]); }
void OnGUI() { //set window title this.titleContent = new GUIContent("Rim Light Profile"); profileName = EditorGUILayout.TextField(profileName); if (GUILayout.Button("Save Profile")) { GameObject rimLight = GameObject.Find("Rim Light"); float rimIntensity = rimLight.GetComponent <Light>().intensity; Vector3 rimAngle = new Vector3(rimLight.transform.localEulerAngles.x, rimLight.transform.localEulerAngles.y, rimLight.transform.localEulerAngles.z); Color Colour = rimLight.GetComponent <Light>().color; LightProperties rim = new LightProperties(); rim.Intensity = rimIntensity; rim.Angle = rimAngle; rim.Colour = Colour; string json = JsonUtility.ToJson(rim, true); string path = "Assets/Resources/Profiles/rimlight/" + profileName + ".json"; //Write some text to the test.txt file StreamWriter writer = new StreamWriter(path, false); writer.Write(json); writer.Close(); } GUILayout.Space(60); string[] rimProfileNames = new String[options.Length]; for (int runs = 0; runs < options.Length; runs++) { string[] profileSplit = options[runs].Split('\\'); string nameSplit = profileSplit[profileSplit.Length - 1].Split('.')[0]; rimProfileNames[runs] = nameSplit; } index = EditorGUILayout.Popup(index, rimProfileNames); if (GUILayout.Button("Load Profile")) { GameObject cam = GameObject.Find("CAM"); Debug.Log("Profiles/rimlight" + rimProfileNames[index]); RimLight.createRimLight(cam, "Profiles/rimlight/" + rimProfileNames[index]); } }
public object SetExtendedProperties() { LightProperties lightProperties = new LightProperties { PulsarComponentClass = ComponentClass.Properties, PulsarComponentType = ComponentType.LightProperties, Node = _light, BaseEntity = _baseEntity, AspectRatio = _light.AspectRatio, Brightness = _light.Brightness, Colour = _light.Color, EffectiveSpecularIntensity = _light.EffectiveSpecularIntensity, FadeDistance = _light.FadeDistance, FieldOfView = _light.Fov, Length = _light.Length, LightType = _light.LightType, PerVertex = _light.PerVertex, Radius = _light.Radius, Range = _light.Range, ShadowFadeDistance = _light.ShadowFadeDistance, ShadowIntensity = _light.ShadowIntensity, ShadowMaximumExtrusion = _light.ShadowMaxExtrusion, ShadowNearFarRatio = _light.ShadowNearFarRatio, ShadowResolution = _light.ShadowResolution, SpecularIntensity = _light.SpecularIntensity, Temperature = _light.Temperature, UsePhysicalValues = _light.UsePhysicalValues }; if (_baseEntity != null && _baseEntity.ComponentProperties != null) { _baseEntity.ComponentProperties.Add(lightProperties); } return(lightProperties); }
public Light(Vector3D position, LightProperties properties) : base(position) { _Properties = properties; }
internal void OnValidate() { // For editor use if (debugLogness) Debug.Log("Validate Object: " + hasSetup, this); if (hasSetup) { if (!mirrorLight) lightProp = null; if (mirrorLight && lightProp == null) mirror(); //Run(); if (timeOfDayManager != null) { if (lastSentTime != time && time != 0 ) { // TODO hack, we want manual alteration of the time slider to cause an update, but for exampple 'AgentProperties' causes an 'OnValidate' to be called as part of it's setup //Debug.Log("lastSentTime:"+lastSentTime+":"+time,this); timeOfDayManager.SetTime(time); lastSentTime = time; } timeOfDayManager.AmIadded(this); // This checks even if timeOfDayManager is not null, does it also have a reference to me, as its possible it got orphaned/forgotten by it Run(); } else { Debug.Log("timeOfDayManager null, new object, run Manager first, running all of them now", this); FindObjectsOfType<TimeOfDayManager>().ToList().ForEach(o => o.Setup()); } if (timeOfDayManager == null) Debug.LogWarning("no timeOfDayManager wants me!", this); } }
public Room(RoomProperties rp, LightProperties lp) { // If the first room if (rp.roomIndex == 0) { gameObj = Instantiate(rp.rObject, rp.offset, rp.orientation) as GameObject; } else // All other rooms { gameObj = Instantiate(rp.rObject, rp.parentTransform) as GameObject; gameObj.transform.localPosition = rp.offset; gameObj.transform.localRotation = rp.orientation; gameObj.transform.localScale = rp.scale; } // Give the gameObj the Room tag. gameObj.tag = rp.tag; if (gameObj.tag == "FIRST ROOM") { wayPoints = new GameObject[9]; // If the first room, add more waypoints. } else if (gameObj.tag == "ROOM")// for end rooms that only need 1 waypoint { wayPoints = new GameObject[3]; } else if (gameObj.tag == "END ROOM") { wayPoints = new GameObject[1]; } gameObj.AddComponent <MeshCollider>(); if (gameObj.tag == "END ROOM") // Check if this is the last level of rooms. { BoxCollider bC = gameObj.AddComponent <BoxCollider>(); bC.isTrigger = true; bC.center = new Vector3(0f, 0f, 150f); bC.size = new Vector3(300, 300, 50); wayPoints[0] = GameObject.CreatePrimitive(PrimitiveType.Sphere); wayPoints[0].transform.parent = gameObj.transform; wayPoints[0].name = "Final Waypoint"; wayPoints[0].tag = "WAYPOINT"; wayPoints[0].transform.localPosition = new Vector3(0f, 1f, 0f); wayPoints[0].transform.localScale = new Vector3(150f, 50, 150f); } else { for (int i = 0; i < wayPoints.Length; i++) { wayPoints[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere); wayPoints[i].transform.parent = gameObj.transform; wayPoints[i].name = "Waypoint" + i.ToString(); wayPoints[i].tag = "WAYPOINT"; } wayPoints[0].transform.localPosition = new Vector3(0f, 0.7f, 0f); wayPoints[0].transform.localScale = new Vector3(0.15f, 0.05f, 0.15f); wayPoints[1].transform.localPosition = new Vector3(0.33f, 1.2f, 0f); wayPoints[1].transform.localScale = new Vector3(0.15f, 0.05f, 0.15f); wayPoints[2].transform.localPosition = new Vector3(-0.33f, 1.2f, 0f); wayPoints[2].transform.localScale = new Vector3(0.15f, 0.05f, 0.15f); } // Adjust the extra waypoints positions for the first room. if (rp.roomIndex == 0) { // Right hand side tunnel waypoints. wayPoints[3].transform.localPosition = new Vector3(-1.145f, 1.665f, 0.08f); wayPoints[3].transform.localRotation = Quaternion.Euler(105f, -45f, -60f); wayPoints[4].transform.localPosition = new Vector3(-1.84f, 2.06f, 0.325f); wayPoints[4].transform.localRotation = Quaternion.Euler(105f, -45f, -60f); wayPoints[5].transform.localPosition = new Vector3(-2.05f, 2.18f, 0.352f); // Left hand side tunnel waypoints. wayPoints[6].transform.localPosition = new Vector3(0.75f, 1.43f, 0f); wayPoints[7].transform.localPosition = new Vector3(1.04f, 1.6f, -0.047f); wayPoints[7].transform.localRotation = Quaternion.Euler(103f, -115f, -130f); wayPoints[8].transform.localPosition = new Vector3(1.77f, 2.03f, -0.305f); wayPoints[8].transform.localRotation = Quaternion.Euler(103f, -115f, -130f); foreach (GameObject wayP in wayPoints) { wayP.transform.localScale = new Vector3(0.15f, 0.05f, 0.15f); } } leftSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); leftSphere.GetComponent <Renderer>().material = lp.lightMat; rightSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); rightSphere.GetComponent <Renderer>().material = lp.lightMat; // Setup transforms and coords leftSphere.transform.parent = gameObj.transform; leftSphere.transform.localPosition = lp.lightLeftOffset; lightLeft = leftSphere.AddComponent <Light>(); lightLeft.name = "Left Light"; rightSphere.transform.parent = gameObj.transform; rightSphere.transform.localPosition = lp.lightRightOffset; lightRight = rightSphere.AddComponent <Light>(); lightRight.name = "Right Light"; lightLeft.transform.parent = leftSphere.transform; lightRight.transform.parent = rightSphere.transform; lightLeft.color = new Color(lp.lightConfig.leftLightColour.x, lp.lightConfig.leftLightColour.y, lp.lightConfig.leftLightColour.z); lightLeft.intensity = lp.lightConfig.leftLightIntensity; lightRight.color = new Color(lp.lightConfig.rightLightColour.x, lp.lightConfig.rightLightColour.y, lp.lightConfig.rightLightColour.z); lightRight.intensity = lp.lightConfig.rightLightIntensity; }
public LightEditor( ) { _properties = new LightProperties( ); _drawing = ObjectFactory.GetInstance <IDrawing>( ); }
// ------------------------------------------------ // Конструкторы. // ------------------------------------------------ public Light(LightProperties properties) : this(DEFAULT_POSITION.X, DEFAULT_POSITION.Y, DEFAULT_POSITION.Z, properties) { }
// Start is called before the first frame update void Start() { light = GetComponentInChildren <Light>(); lightProp = GetComponent <LightProperties>(); worldData = Camera.main.GetComponent <WorldData>(); }
public Light(double x, double y, double z, LightProperties properties) : base(x, y, z) { _Properties = properties; }
public Light(Light light) : base(light) { _Properties = light._Properties; }
public LightProperties lightProp; // gets wiped each setup public void mirror() { //if (mirrorLight) { //lightProp = GetComponent<LightProperties>(); //if (!(this is LightProperties)) lightProp = GetComponent<LightProperties>(); lightProp = null; List <LightProperties> props = null; props = GetComponentsInChildren <LightProperties>().ToList(); if (props.Count > 0) { foreach (var lightProperties in props) { if (lightProperties != this && lightProperties.mirrorLight == false) { lightProp = lightProperties; break; } } } if (lightProp == null) { props = transform.parent.GetComponentsInChildren <LightProperties>().ToList(); } if (props.Count > 0) { foreach (var lightProperties in props) { if (lightProperties != this && lightProperties.mirrorLight == false) { lightProp = lightProperties; break; } } } //if (lightProp == null) props = GetComponentsInParent<LightProperties>().ToList(); //if (props.Count > 0) { // foreach (var lightProperties in props) { // if (lightProperties != this && lightProperties.mirrorLight == false) { // lightProp = lightProperties; // break; // } // } //} if (lightProp == null) { //mirrorLight = false; Debug.Log("failed to mirrorLight, no Light found", this); } else { lightProp.AddToFollowers(this); //_color = lightProp._color; //randomDelay = lightProp._randomDelayRange; } //} }