public void ButtonPressed(LightMode mode) { m_LightGizmo_Shadow.Visible = false; m_LightGizmo_NoShadow.Visible = false; m_PreviewSphereParent.gameObject.SetActive(false); // Create the popup with callback. SketchControlsScript.GlobalCommands command = (mode == LightMode.Shadow || mode == LightMode.NoShadow) ? SketchControlsScript.GlobalCommands.LightingHdr : SketchControlsScript.GlobalCommands.LightingLdr; CreatePopUp(command, -1, -1, LightModeToString(mode), MakeOnPopUpClose(mode)); // Init popup according to current light mode. var popup = (m_ActivePopUp as ColorPickerPopUpWindow); popup.transform.localPosition += new Vector3(0, m_ColorPickerPopUpHeightOffset, 0); ColorPickerUtils.SetLogVRangeForMode(mode); popup.ColorPicker.ColorPicked += OnColorPicked(mode); popup.ColorPicker.ColorPicked += delegate(Color c) { m_LightButtons[(int)mode + 1].SetDescriptionText(LightModeToString(mode), ColorTable.m_Instance.NearestColorTo(c)); SetLightColor(mode, c); }; // Init must be called after all popup.ColorPicked actions have been assigned. popup.ColorPicker.Controller.CurrentColor = GetLightColor(mode); popup.ColorPicker.ColorFinalized += MakeLightColorFinalized(mode); popup.CustomColorPalette.ColorPicked += MakeLightColorPickedAsFinal(mode); m_EatInput = true; }
/// <summary> Determines the mode of the light according to a code given by the light. </summary> internal static LightMode DetermineMode(string patternCode) { LightMode mode = LightMode.Unknown; if (patternCode == "61" || patternCode == "62" || patternCode == "41") { mode = LightMode.Color; } if (patternCode == "60") { mode = LightMode.Custom; } for (int i = 25; i <= 38; i++) { if (patternCode == i.ToString()) { Console.WriteLine(i.ToString()); mode = LightMode.Preset; break; } } if (patternCode == "2a" || patternCode == "2b" || patternCode == "2c" || patternCode == "2d" || patternCode == "2e" || patternCode == "2f") { mode = LightMode.Preset; } return(mode); }
public void ToggleMode() { SegmentGeometry geometry = SegmentGeometry.Get(SegmentId); if (geometry == null) { Log.Error($"CustomSegmentLight.ToggleMode: No geometry information available for segment {SegmentId}"); return; } bool startNode = lights.StartNode; var hasLeftSegment = geometry.HasOutgoingLeftSegment(startNode); var hasForwardSegment = geometry.HasOutgoingStraightSegment(startNode); var hasRightSegment = geometry.HasOutgoingRightSegment(startNode); #if DEBUG Log._Debug($"ChangeMode. segment {SegmentId} @ node {NodeId}, hasOutgoingLeft={hasLeftSegment}, hasOutgoingStraight={hasForwardSegment}, hasOutgoingRight={hasRightSegment}"); #endif LightMode newMode = LightMode.Simple; if (CurrentMode == LightMode.Simple) { if (!hasLeftSegment) { newMode = LightMode.SingleRight; } else { newMode = LightMode.SingleLeft; } } else if (CurrentMode == LightMode.SingleLeft) { if (!hasForwardSegment || !hasRightSegment) { newMode = LightMode.Simple; } else { newMode = LightMode.SingleRight; } } else if (CurrentMode == LightMode.SingleRight) { if (!hasLeftSegment) { newMode = LightMode.Simple; } else { newMode = LightMode.All; } } else { newMode = LightMode.Simple; } CurrentMode = newMode; }
void SetLight(LightMode mode) { switch (mode) { case LightMode.Stop: redLight.SetColor("_EmissiveColor", RedData.updatedLight); yellowLight.SetColor("_EmissiveColor", YellowData.defaultLight); greenLight.SetColor("_EmissiveColor", GreenData.defaultLight); break; case LightMode.Move: redLight.SetColor("_EmissiveColor", RedData.defaultLight); yellowLight.SetColor("_EmissiveColor", YellowData.defaultLight); greenLight.SetColor("_EmissiveColor", GreenData.updatedLight); break; case LightMode.Ready: redLight.SetColor("_EmissiveColor", RedData.defaultLight); yellowLight.SetColor("_EmissiveColor", YellowData.updatedLight); greenLight.SetColor("_EmissiveColor", GreenData.defaultLight); break; case LightMode.Stop_Ready: redLight.SetColor("_EmissiveColor", RedData.updatedLight); yellowLight.SetColor("_EmissiveColor", YellowData.updatedLight); greenLight.SetColor("_EmissiveColor", GreenData.defaultLight); break; default: redLight.SetColor("_EmissiveColor", RedData.defaultLight); yellowLight.SetColor("_EmissiveColor", YellowData.defaultLight); greenLight.SetColor("_EmissiveColor", GreenData.defaultLight); break; } }
public void Update() { UI.WindowBegin("Direction", ref windowPose, new Vec2(20 * Units.cm2m, 0)); UI.Label("Mode"); if (UI.Radio("Lights", mode == LightMode.Lights)) { mode = LightMode.Lights; } UI.SameLine(); if (UI.Radio("Image", mode == LightMode.Image)) { mode = LightMode.Image; } if (mode == LightMode.Lights) { UI.Label("Lights"); if (UI.Button("Add")) { lights.Add(new Light { pose = new Pose(Vec3.Up * Units.cm2m * 25, Quat.LookDir(-Vec3.Forward)), color = Vec3.One }); UpdateLights(); } UI.SameLine(); if (UI.Button("Remove") && lights.Count > 1) { lights.RemoveAt(lights.Count - 1); UpdateLights(); } } if (mode == LightMode.Image) { UI.Label("Image"); if (!FilePicker.Active && UI.Button("Open")) { ShowPicker(); } } UI.WindowEnd(); lightMesh.Draw(lightProbeMat, Matrix.TS(Vec3.Zero, 0.04f)); if (mode == LightMode.Lights) { bool needsUpdate = false; for (int i = 0; i < lights.Count; i++) { needsUpdate = LightHandle(i) || needsUpdate; } if (needsUpdate) { UpdateLights(); } } }
public Unit ChangeLightMode(LightMode mode) { switch (mode) { case LightMode.None: _form.flatRadioButton.Checked = true; break; case LightMode.Simple: _form.simpleRadioButton.Checked = true; break; case LightMode.Gouraud: _form.gouraudRadioButton.Checked = true; break; case LightMode.Phong: _form.phongRadioButton.Checked = true; break; case LightMode.NormalMapping: _form.normalMappingRadioButton.Checked = true; break; } return(Unit.Value); }
public void SetLightMode(ushort segmentId, bool startNode, ExtVehicleType vehicleType, LightMode mode) { ICustomSegmentLights liveLights = GetSegmentLights(segmentId, startNode); if (liveLights == null) { Log.Warning( $"CustomSegmentLightsManager.SetLightMode({segmentId}, {startNode}, " + $"{vehicleType}, {mode}): Could not retrieve segment lights."); return; } ICustomSegmentLight liveLight = liveLights.GetCustomLight(vehicleType); if (liveLight == null) { Log.Error( $"CustomSegmentLightsManager.SetLightMode: Cannot change light mode on seg. " + $"{segmentId} @ {startNode} for vehicle type {vehicleType} to {mode}: Vehicle light not found"); return; } liveLight.CurrentMode = mode; }
private void SetLight() { switch (lightMode) { case LightMode.None: break; case LightMode.Green: //当前绿灯,变黄 lightMode = LightMode.Yellow; break; case LightMode.Yellow: //当前黄灯,变红 lightMode = LightMode.Red; break; case LightMode.Red: //当前红灯,变绿 lightMode = LightMode.Green; break; default: break; } foreach (GameObject light in Lights) { light.SetActive(false); } if (lightMode != LightMode.None) { Lights[(int)lightMode - 1].SetActive(true); } }
IEnumerator LoopLightCycle() { LightMode mode = LightMode.Stop; while (true) { if (mode == LightMode.Stop) { SetLight(LightMode.Stop); mode += 1; yield return(new WaitForSeconds(5)); } else if (mode == LightMode.Move) { SetLight(LightMode.Move); mode += 1; yield return(new WaitForSeconds(5)); } else if (mode == LightMode.Ready) { SetLight(LightMode.Ready); mode += 1; yield return(new WaitForSeconds(4)); } else //LightMode.Stop_Ready { SetLight(LightMode.Stop_Ready); mode = 0; yield return(new WaitForSeconds(1)); } } }
/// <summary> /// Returns a transparent SolidColorBrush if the LightMode is set to None. Otherwise returns /// a red SolidColorBrush. /// </summary> /// <param name="value">The LightMode to be converted.</param> /// <param name="targetType">Unused.</param> /// <param name="parameter">Unused.</param> /// <param name="language">Unused.</param> /// <returns>SolidColorBrush</returns> public object Convert(object value, Type targetType, object parameter, string language) { LightMode lightMode = (LightMode)value; Color color = lightMode == LightMode.None ? Colors.Transparent : Colors.Red; return(new SolidColorBrush(color)); }
public void SetLight(LightMode mode) { lightMode = mode; foreach (GameObject light in Lights) { light.SetActive(false); } if (lightMode != LightMode.None) { Lights[(int)lightMode - 1].SetActive(true); } //if (image == null) //{ // Debug.Log(transform.name); // return; //} //switch (lightMode) //{ // case LightMode.None: // image.color = Color.white; // break; // case LightMode.Green: // image.color = Color.green; // break; // case LightMode.Yellow: // image.color = Color.yellow; // break; // case LightMode.Red: // image.color = Color.red; // break; // default: // break; //} }
private void SetLightMode(LightMode mode) { lightMode = mode; switch (lightMode) { case LightMode.ONE: directionalLight.gameObject.SetActive(true); directionalLight.intensity = 1f; pointLight.gameObject.SetActive(true); torch.SetActive(false); break; case LightMode.TWO: directionalLight.gameObject.SetActive(true); directionalLight.intensity = 3f; pointLight.gameObject.SetActive(false); torch.SetActive(false); break; case LightMode.THREE: directionalLight.gameObject.SetActive(false); directionalLight.intensity = 0.5f; pointLight.gameObject.SetActive(true); torch.SetActive(false); break; case LightMode.FOUR: directionalLight.gameObject.SetActive(false); directionalLight.intensity = 0.5f; pointLight.gameObject.SetActive(false); torch.SetActive(true); break; } }
/// <summary> /// Returns Visibility.Visible if the value matches the parameter. Returns Visibility.Collapsed /// otherwise. /// </summary> /// <param name="value">The LightMode to convert.</param> /// <param name="targetType">Unused.</param> /// <param name="parameter">The string value of the LightMode value checked against.</param> /// <param name="language">Unused.</param> /// <returns>Visibility</returns> public object Convert(object value, Type targetType, object parameter, string language) { LightMode lightMode = (LightMode)value; String refMode = parameter.ToString().Trim(); bool match = refMode.Equals(lightMode.ToString()); return(match ? Visibility.Visible : Visibility.Collapsed); }
public Light(Vector2f scale, Color color, LightMode mode) { light = new Sprite(ResourceManager.GetTexture("light.png")); light.Texture.Smooth = true; Scale = scale; Color = color; Position = new Vector2f(); Mode = mode; }
public MainPage() { this.InitializeComponent(); ranOnLaunchInternetTasks = false; currentNetworkConnectivityLevel = NetworkInformation.GetInternetConnectionProfile().GetNetworkConnectivityLevel(); Window.Current.Activated += Current_Activated; NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; string deviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily; if (deviceFamily.Contains("Mobile")) { device = Device.Mobile; } else if (deviceFamily.Contains("Desktop")) { device = Device.Desktop; } else { device = Device.Other; } mediaPlayer = new MediaPlayer(); mediaPlayer.MediaEnded += MediaPlayer_MediaEnded; mediaPlayer.MediaFailed += MediaPlayer_MediaFailed; mediaPlayerElement.SetMediaPlayer(mediaPlayer); ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen; httpClient = new HttpClient(); appleMovieDownloader = new AppleMovieDownloader(httpClient); sunrise = DateTime.MinValue; sunset = DateTime.MinValue; lastPositions = new Queue <TimeSpan>(); SpotifyHelper = new SpotifyHelper(); HueHelper = new HueHelper(); AirQualityHelper = new AirQualityHelper(); CalendarHelper = new CalendarHelper(); rotationBuffer = 0; lightMode = LightMode.Brightness; if (device == Device.Desktop) { dial = RadialController.CreateForCurrentView(); dial.RotationResolutionInDegrees = 5; dial.UseAutomaticHapticFeedback = false; dialConfig = RadialControllerConfiguration.GetForCurrentView(); menuItems = new List <RadialControllerMenuItem>(); isWindowFocused = true; dial.ButtonClicked += Dial_ButtonClicked; dial.RotationChanged += Dial_RotationChanged; dial.ControlAcquired += Dial_ControlAcquired; dial.ControlLost += Dial_ControlLost; } }
public void MakeLightBlink() { // guard clause to prevent the coroutine from being created multiple times if (lightMode != LightMode.Blinking) { lightMode = LightMode.Blinking; StartCoroutine(blinkCoroutine); } }
public readonly byte R, G, B; // RGB only public Light(LightMode mode, byte color = 0, byte flashColor = 0) { Mode = mode; Color = color; FlashColor = flashColor; R = 0; G = 0; B = 0; }
DefaultSampler(int FirstHitSamples, int MaxBounces, bool DirectLighting, bool SoftShadows, LightMode LM, SpecularMode SM) { this.FirstHitSamples = FirstHitSamples; this.MaxBounces = MaxBounces; this.DirectLighting = DirectLighting; this.SoftShadows = SoftShadows; LightMode = LM; SpecularMode = SM; }
public Light(LightMode mode, byte red, byte green, byte blue = 0, byte flashColor = 0) { Mode = mode; Color = 0; FlashColor = flashColor; R = red; G = green; B = blue; }
/// <summary> /// Initializes a new instance of the <see cref="UFLT.Utils.IntermediateMaterial"/> class. /// </summary> /// <param name='bank'>Material bank, used for finding materials.</param> /// <param name='mp'>Material palette or null.</param> /// <param name='main'>Main texture or null.</param> /// <param name='detail'>Detail texture or null.</param> /// <param name='transparancy'>Transparancy</param> /// <param name='lm'>Light mode.</param> public IntermediateMaterial(MaterialBank bank, MaterialPalette mp, TexturePalette main, TexturePalette detail, ushort transparancy, LightMode lm) { MaterialBank = bank; Palette = mp; MainTexture = main; DetailTexture = detail; Transparency = transparancy; LightMode = lm; }
private void ToggleMode(ref ExtSegmentEnd segEnd, ref NetNode node) { IExtSegmentManager extSegMan = Constants.ManagerFactory.ExtSegmentManager; IExtSegmentEndManager extSegEndMan = Constants.ManagerFactory.ExtSegmentEndManager; bool startNode = lights.StartNode; bool hasLeftSegment; bool hasForwardSegment; bool hasRightSegment; extSegEndMan.CalculateOutgoingLeftStraightRightSegments(ref segEnd, ref node, out hasLeftSegment, out hasForwardSegment, out hasRightSegment); #if DEBUG Log._Debug($"ChangeMode. segment {SegmentId} @ node {NodeId}, hasLeftSegment={hasLeftSegment}, hasForwardSegment={hasForwardSegment}, hasRightSegment={hasRightSegment}"); #endif LightMode newMode = LightMode.Simple; if (CurrentMode == LightMode.Simple) { if (!hasLeftSegment) { newMode = LightMode.SingleRight; } else { newMode = LightMode.SingleLeft; } } else if (CurrentMode == LightMode.SingleLeft) { if (!hasForwardSegment || !hasRightSegment) { newMode = LightMode.Simple; } else { newMode = LightMode.SingleRight; } } else if (CurrentMode == LightMode.SingleRight) { if (!hasLeftSegment) { newMode = LightMode.Simple; } else { newMode = LightMode.All; } } else { newMode = LightMode.Simple; } CurrentMode = newMode; }
public void MakeLightStayOn() { if (lightMode != LightMode.StayOn) { StopCoroutine(blinkCoroutine); lightMode = LightMode.StayOn; lightMesh.material = emissiveMaterial; } }
Action MakeLightColorFinalized(LightMode mode) { return(delegate { SketchMemoryScript.m_Instance.PerformAndRecordCommand(mode == LightMode.Ambient ? new ModifyLightCommand(mode, RenderSettings.ambientLight, Quaternion.identity, final: true) : new ModifyLightCommand(mode, App.Scene.GetLight((int)mode).color, App.Scene.GetLight((int)mode).transform.localRotation, final: true)); }); }
public void TurnLightOff() { if (lightMode != LightMode.Off) { StopCoroutine(blinkCoroutine); lightMesh.material = nonEmissiveMaterial; lightMode = LightMode.Off; } }
private uint _showTrisCount; //测试数据 public SoftRendererDemo() { //初始化窗体 InitializeComponent(); try { //载入贴图 Image img = Image.FromFile("../../Texture/texture.jpg"); //转换成位图 _texture = new Bitmap(img, 256, 256); } catch (Exception) { _texture = new Bitmap(256, 256); initTexture(); } //设置渲染模式 _currentMode = RenderMode.Textured; //设置灯光开闭 _lightMode = LightMode.OFF; //设置采样方式 _textureFilterMode = TextureFilterMode.Point; //初始化帧缓冲 _frameBuff = new Bitmap(this.MaximumSize.Width, this.MaximumSize.Height); _frameG1 = Graphics.FromImage(_frameBuff); _zBuff = new float[this.MaximumSize.Height, this.MaximumSize.Width]; //环境光颜色 _ambientColor = new RenderData.Color(1, 1, 1); //加载数据 _mesh = new Mesh(CubeTestData.pointList, CubeTestData.indexs, CubeTestData.uvs, CubeTestData.vertColors, CubeTestData.norlmas, CubeTestData.mat); //光源 Vector3D lightPos = new Vector3D(50, 0, 0); RenderData.Color lightColor = new RenderData.Color(1, 1, 1); _light = new Light(lightPos, lightColor); //相机 Vector3D cameraPos = new Vector3D(0, 0, 0, 1); Vector3D cameraLookAt = new Vector3D(0, 0, 1, 1); Vector3D cameraUp = new Vector3D(0, 1, 0, 0); float cameraFov = (float)System.Math.PI / 4; float cameraAspect = MaximumSize.Width / (float)MaximumSize.Height; float cameraZn = 1f; float cameraZf = 500f; _camera = new Camera(cameraPos, cameraLookAt, cameraUp, cameraFov, cameraAspect, cameraZn, cameraZf); //定时刷新任务 System.Timers.Timer mainTimer = new System.Timers.Timer(1000 / 60f); mainTimer.Elapsed += new ElapsedEventHandler(Tick); mainTimer.AutoReset = true; mainTimer.Enabled = true; mainTimer.Start(); }
Action <Color> OnColorPicked(LightMode mode) { return(delegate(Color c) { SetLightColor(mode, c); if (mode == LightMode.Shadow || mode == LightMode.NoShadow) { SceneSettings.m_Instance.UpdateReflectionIntensity(); } }); }
/// <summary> /// Initialize a NXT Light Sensor /// </summary> /// <param name="port">Sensor port</param> /// <param name="mode">Light mode</param> /// <param name="timeout">Period in millisecond to check sensor value changes</param> public NXTLightSensor(BrickPortSensor port, LightMode mode, int timeout) { brick = new Brick(); Port = port; lightMode = mode; CutOff = 512; brick.BrickPi.Sensor[(int)Port].Type = (BrickSensorType)mode; periodRefresh = timeout; timer = new Timer(UpdateSensor, this, TimeSpan.FromMilliseconds(timeout), TimeSpan.FromMilliseconds(timeout)); }
/// <summary> /// Initialize a NXT Light Sensor /// </summary> /// <param name="brick"></param> /// <param name="port">Sensor port</param> /// <param name="mode">Light mode</param> /// <param name="timeout">Period in millisecond to check sensor value changes</param> public NXTLightSensor(Brick brick, SensorPort port, LightMode mode, int timeout) { _brick = brick; Port = port; _lightMode = mode; CutOff = 512; brick.SetSensorType((byte)Port, (SensorType)mode); _periodRefresh = timeout; _timer = new Timer(UpdateSensor, this, TimeSpan.FromMilliseconds(timeout), TimeSpan.FromMilliseconds(timeout)); }
// Use this for initialization void Start() { gameStateDataScriptRef = GameObject.Find("GameState").GetComponent <GameStateScript>(); lightMode = LightMode.NEAR; defaultLightCylinderScale = lightCylinder.transform.localScale.z; input = PlayerInput.instance; playerCylAngleOffset = Vector3.Angle(transform.forward, lightCylinder.transform.forward); }
public static string ModeToString(LightMode mode) { return(mode switch { LightMode.None => "", LightMode.Color => "colour", LightMode.White => "white", LightMode.Music => "music", LightMode.Scene => "scene", _ => "" });
private float[,] _zBuff; //z缓冲,用来做深度测试 #endregion Fields #region Constructors public SoftRendererDemo() { //VectorMatrixTestCase.Test(); InitializeComponent(); try { System.Drawing.Image img = System.Drawing.Image.FromFile("../../Texture/texture.jpg"); _texture = new Bitmap(img, 256, 256); } catch(Exception) { _texture = new Bitmap(256, 256); initTexture(); } // _currentMode = RenderMode.Textured; _lightMode = LightMode.On; _textureFilterMode = TextureFilterMode.Bilinear; // _frameBuff = new Bitmap(this.MaximumSize.Width, this.MaximumSize.Height); _frameG = Graphics.FromImage(_frameBuff); _zBuff = new float[this.MaximumSize.Height, this.MaximumSize.Width]; _ambientColor = new RenderData.Color(1f, 1f, 1f); _mesh = new Mesh(CubeTestData.pointList, CubeTestData.indexs, CubeTestData.uvs, CubeTestData.vertColors, CubeTestData.norlmas, QuadTestData.mat); //_mesh = new Mesh(QuadTestData.pointList, QuadTestData.indexs, QuadTestData.uvs, QuadTestData.vertColors, QuadTestData.norlmas, QuadTestData.mat); //打开注释可以切换mesh //定义光照 _light = new Light(new Vector3D(50, 0, 0), new RenderData.Color(1, 1, 1)); //定义相机 _camera = new Camera(new Vector3D(0, 0, 0, 1), new Vector3D(0, 0, 1, 1), new Vector3D(0, 1, 0, 0), (float)System.Math.PI / 4, this.MaximumSize.Width / (float)this.MaximumSize.Height, 1f, 500f); System.Timers.Timer mainTimer = new System.Timers.Timer(1000 / 60f); mainTimer.Elapsed += new ElapsedEventHandler(Tick); mainTimer.AutoReset = true; mainTimer.Enabled = true; mainTimer.Start(); // }
/// <summary> /// Initializes a new instance of the <see cref="MonoBrick.NXT.NXTLightSensor"/> class. /// </summary> /// <param name='lightMode'> /// Light sensor mode /// </param> /// <param name='sensorMode'> /// Sensor mode. Raw, bool, percent... /// </param> public NXTLightSensor(LightMode lightMode, SensorMode sensorMode) : base ((SensorType)lightMode, sensorMode){ }
/// <summary> /// Initializes a new instance of the <see cref="MonoBrick.EV3.LightSensor"/> class. /// </summary> /// <param name="mode">Mode.</param> public LightSensor (LightMode mode) : base((SensorMode)mode) { }
/// <summary> /// Initialize a NXT Light Sensor /// </summary> /// <param name="port">Sensor port</param> /// <param name="mode">Light mode</param> public NXTLightSensor(BrickPortSensor port, LightMode mode) : this(port, mode, 1000) { }
public Light(Vector2f position, Vector2f scale, LightMode mode) : this(position, scale, Color.White, mode) { }
public Light(Vector2f scale, LightMode mode) : this(scale, Color.White, mode) { }
public Light(Vector2f position, Vector2f scale, Color color, LightMode mode) : this(scale, color, mode) { Position = position; }
/// <summary> /// Initializes a new instance of the <see cref="MonoBrick.EV3.LightSensor"/> class. /// </summary> /// <param name="mode">Mode.</param> public NXTLightSensor(SensorPort port, LightMode mode) : base(port) { Mode = mode; }
private void FixedUpdate() { CurrentLightMode = lightMode; }
/// <summary> /// Initializes a new instance of the <see cref="MonoBrick.NXT.NXTLightSensor"/> class. /// </summary> /// <param name='lightMode'> /// Light sensor mode /// </param> public NXTLightSensor(LightMode lightMode) : base ((SensorType)lightMode, SensorMode.Percent){ }
public override void SelectPreviousMode() { Mode = Mode.Next(); return; }
//----------------------------------------------------- void Start() { guiMenuConfiguration = GameObject.Find("MainScene").GetComponent<GUIMenuConfiguration>(); guiMenuInteraction = GameObject.Find("MainScene").GetComponent<GUIMenuInteraction>(); if(skin == null) skin = (GUISkin)Resources.Load("skins/mode2D"); // -- Initialisation variables membres -- mLoopLightMode = false; mLightMode = LightMode.off; mCurColorH = 0f; mCurLightCol = new Color(); mLightSystemRoot = null; mWaterSpec = null; mLEDmat = null; mMainSpotlight = null; mOldSpaScale = new Vector3(); // -- Variables transitions animées -- mAnimOnOff = false; mAnimOnOffProg = 0f; mSpotlightsStartI = 0f; mSpotlightsEndI = 0f; mGlowColorStart = Color.black; mGlowColorEnd = Color.black; mMatLEDcolStart = Color.black; mMatLEDcolEnd = Color.black; mWaterSelfiColStart = Color.black; mWaterSelfiColEnd = Color.black; mAnimMainSpotOnOff = false; mAnimMainSpotOnOffProg = 0f; mMainSpotIstart = 0f; mMainSpotIend = 0f; // -- Récupérations des objets de la scène dont on a besoin -- mSpa = transform; Transform child, child2; for(int i=0; i<mSpa.GetChildCount(); i++) { child = mSpa.GetChild(i); if(child.name == sLightSystemRootName) mLightSystemRoot = child; // Nœud parent du système de lumières else if(child.name == sWaterParentName) { for(int j=0; j<child.GetChildCount(); j++) { child2 = child.GetChild(j); if(child2.name.Equals(sWaterSpecName)) mWaterSpec = child2.gameObject; // Eau (celle avec le shader DispNormRimSpec-like) } } else if(child.name == sLEDmeshName) { for(int j=0; j<child.GetComponent<Renderer>().materials.Length; j++) { if(child.GetComponent<Renderer>().materials[j].name.Contains(sLEDmaterialName)) mLEDmat = child.GetComponent<Renderer>().materials[j]; // Matériau du mesh du verre des LEDs } } } // -- Si un objet est absent, afficher une erreur et désactiver le script -- if(mLightSystemRoot == null) { DeactivateWithLogError(sLightSystemRootName); return; } if(mWaterSpec == null) { DeactivateWithLogError(sWaterSpecName); return; } if(mLEDmat == null) { DeactivateWithLogError(sLEDmaterialName); return; } // -- Récupération des spotlights et des matériaux des glows des LEDs -- mLEDglows = new List<GameObject>(); mLEDspots = new List<Light>(); for(int i=0; i<mLightSystemRoot.GetChildCount(); i++) { child = mLightSystemRoot.GetChild(i); if(child.name == sMainSpotlightName) mMainSpotlight = child.GetComponent<Light>(); else { for(int j=0; j<child.GetChildCount(); j++) { child2 = child.GetChild(j); if(child2.name == sLEDglowObjectName) mLEDglows.Add(child2.gameObject); else if(child2.name == sLEDspotObjectName) mLEDspots.Add(child2.GetComponent<Light>()); } // foreach child of child } // if not main spotlight } // For each child if(mMainSpotlight == null) { DeactivateWithLogError(sMainSpotlightName); return; } // -- Couleur moyenne de la coque (correspond normalement à "lumières éteintes") -- if (mWaterSpec.GetComponent<Renderer>().material.HasProperty("_MainColor")) mLinerColor = mWaterSpec.GetComponent<Renderer>().material.GetColor("_MainColor"); // -- Couleur du matériau du verre des LED (correspond normalement à "lumières éteintes") -- mLEDmatColor = mLEDmat.GetColor("_Color"); // -- Echelle du spa (et range des spotlights) -- mOldSpaScale = Vector3.one; // Note : Pas mOldSpaScale = mSpa.LocalScale sinon la range des proj n'est pas mise à jour au swap. mMainSpotlightBaseRange = mMainSpotlight.range; mLEDSpotBaseRanges = new float[mLEDspots.Count]; for(int i=0; i<mLEDspots.Count; i++) mLEDSpotBaseRanges[i] = mLEDspots[i].range; // Note : mSpotsLitI est MÀJ par spaConfigWater, qui appelle updateSpotsIntensity à son 1er Update() }
//----------------------------------------------------- private void LoopSpaLight() { if(mAnimOnOff) return; mLightMode = (LightMode) (((int)mLightMode+1) % (Enum.GetNames(typeof(LightMode)).Length)); if(mLightMode == LightMode.off) SwitchLightsOff(); else if(mLightMode == LightMode.manual) SwitchLightsOn (); // LitSpa(mLightMode != LightMode.off); }
public override void SelectNextMode() { Mode = Mode.Next(); return; }
private void DrawLights(RenderTarget target, Scene scene, Vector2f cameraOffset, LightMode mode) { foreach (var obj in scene) { Transform transf = Transform.Identity; transf.Translate(obj.Body.Incircle.Center - cameraOffset); RenderStates state = new RenderStates(transf); state.BlendMode = BlendMode.Add; foreach (var light in obj.Lighting.Where(x => x.Mode == mode)) target.Draw(light, state); } foreach (var light in scene.Lights.Where(x => x.Mode == mode)) { Transform transf = Transform.Identity; transf.Translate(-cameraOffset); RenderStates state = new RenderStates(transf); state.BlendMode = BlendMode.Add; target.Draw(light, state); } }