public void Vect3_add_returnsVal() { IVector3 v1 = new Vector3(1, 1, 1); IVector3 v2 = new Vector3(2, 3, 1); IVector3 v3 = v1.Plus(v2); Assert.AreEqual(3d, v3.X); Assert.AreEqual(4d, v3.Y); }
public void RunInLogic(DateTime runtime) { if (curSpeed != 0 && curVector3 != null) { Vector3 delta = Vector3.Multiply(curVector3, curSpeed); position.Plus(delta); } SwitchToNewStatePreFrame(); SynState(runtime); }
public void Plus2() { var v1 = new Vector3(1, 2, 3); var v2 = new Vector3(7, 0, 6); var vr = v2.Plus(v1); Assert.AreEqual(8, vr.X); Assert.AreEqual(2, vr.Y); Assert.AreEqual(9, vr.Z); }
public void Run(DateTime runtime) { long detalTime = runtime == null ? 1 : runtime.Millisecond - lastRuntime.Millisecond; exeCmd(); if (dir == null || speed == 0) { return; } Vector3 deltalPostion = Vector3.Multiply(Vector3.Multiply(dir, speed), detalTime); position.Plus(deltalPostion); owner.OnPositionChange(position); }
private void mod_Start() { //NEW CODE HERE var exampleCheckbox = this.ComponentsInDescendants<UIOptionsTag>(true).Single( opt => opt.Checkbox && opt.BoolSuboption == GameOption.BoolOption.SCREEN_EDGE_SCROLLING) .transform; Prefabs.QuickCheckbox = exampleCheckbox.Component<UIOptionsTag>(); Prefabs.QuickDropdown = ResolutionDropdown.transform.parent.gameObject; Prefabs.QuickButton = UIOptionsManager.Instance.PageButtonPrefab.gameObject; Prefabs.QuickPage = Pages[5]; var pageParent = Pages[5].transform.parent; var ieModOptions = new QuickPage(pageParent, "IEModOptions_Settings_Page"); var ieModDisposition = new QuickPage(pageParent, "IEModOptions_Disposition_Page"); Pages = Pages.Concat(new[] { ieModOptions.GameObject, ieModDisposition.GameObject }).ToArray(); //ORIGINAL CODE this.SetMenuLayout(OptionsMenuLayout.InGame); this.QuitButton.onClick = (UIEventListener.VoidDelegate) Delegate.Combine(this.QuitButton.onClick, new UIEventListener.VoidDelegate(this.OnQuitClicked)); this.SaveButton.onClick = (UIEventListener.VoidDelegate) Delegate.Combine(this.SaveButton.onClick, new UIEventListener.VoidDelegate(this.OnSaveClicked)); this.LoadButton.onClick = (UIEventListener.VoidDelegate) Delegate.Combine(this.LoadButton.onClick, new UIEventListener.VoidDelegate(this.OnLoadClicked)); this.m_Options = this.ComponentsInDescendants<UIOptionsTag>(true); //NEW CODE var quickFactory = new QuickFactory() { CurrentParent = Pages[7].transform }; //File.WriteAllText("ComboboxDump.txt", UnityObjectDumper.PrintUnityGameObject(exampleDropdown.gameObject, null, x => false)); quickFactory.CurrentParent = Pages[7].transform; var column1Top = new Vector3(-210, 330, 0); //The following are the controls that appear in the GUI of the mod. _oneTooltip = quickFactory.Checkbox(() => IEModOptions.OneTooltip); _oneTooltip.Transform.localPosition = column1Top; _disableEngagement = quickFactory.Checkbox(() => IEModOptions.DisableEngagement); _disableEngagement.LocalPosition = column1Top.Plus(y:-30); _blueCircles = quickFactory.Checkbox(() => IEModOptions.BlueCircles); _blueCircles.Transform.localPosition = column1Top.Plus(y:-60); _blueCirclesBg = quickFactory.Checkbox(() => IEModOptions.BlueCirclesBG); _blueCirclesBg.Transform.localPosition = column1Top.Plus(x:+30, y:-90); _blueCircles.IsChecked.HasChanged += x => { if (x.Value) { _blueCirclesBg.OptionsTagComponent.Enable(); } else { _blueCirclesBg.IsChecked.Value = false; _blueCirclesBg.OptionsTagComponent.Disable(); } }; _blueCircles.IsChecked.NotifyChange(); _alwaysShowCircles = quickFactory.Checkbox(() => IEModOptions.AlwaysShowCircles); _alwaysShowCircles.Transform.localPosition = column1Top.Plus(y:-120); _unlockCombatInv = quickFactory.Checkbox(() => IEModOptions.UnlockCombatInv); _unlockCombatInv.Transform.localPosition = column1Top.Plus(y:-150); _npcDispositionFix = quickFactory.Checkbox(() => IEModOptions.NPCDispositionFix); _npcDispositionFix.Transform.localPosition = column1Top.Plus(y:-180); _removeMovingRecovery = quickFactory.Checkbox(() => IEModOptions.RemoveMovingRecovery); _removeMovingRecovery.Transform.localPosition = column1Top.Plus(y:-210); //_fastSneak = quickFactory.Checkbox(() => IEModOptions.FastSneak); //_fastSneak.Transform.localPosition = column1Top.Plus(y:-240); /* * * TJH 8/28/2015. Improved AI Excluded from v2.0 _improvedAi = quickFactory.Checkbox(() => IEModOptions.ImprovedAI); _improvedAi.Transform.localPosition = column1Top.Plus(y: -270); * * */ _disableFriendlyFire = quickFactory.Checkbox(() => IEModOptions.DisableFriendlyFire); /* * * TJH 8/28/2015. Moved up since Improved AI and Fast Sneak are no longer present here * * */ _disableFriendlyFire.Transform.localPosition = column1Top.Plus(y: -240); var column2Top = column1Top.Plus(x: +420); _lootShuffler = quickFactory.Checkbox(() => IEModOptions.LootShuffler); _lootShuffler.Transform.localPosition = column2Top; _gameSpeed = quickFactory.Checkbox(() => IEModOptions.GameSpeedMod); _gameSpeed.Transform.localPosition = column2Top.Plus(y:-30); _combatOnly = quickFactory.Checkbox(() => IEModOptions.CombatOnlyMod); _combatOnly.Transform.localPosition = column2Top.Plus(y:-60); _bonusSpellsPerDay = quickFactory.Checkbox(() => IEModOptions.BonusSpellsPerDay); _bonusSpellsPerDay.Transform.localPosition = column2Top.Plus(y:-90); _targetTurnedEnemies = quickFactory.Checkbox(() => IEModOptions.TargetTurnedEnemies); _targetTurnedEnemies.Transform.localPosition = column2Top.Plus(y:-120); _fixBackerNames = quickFactory.Checkbox(() => IEModOptions.FixBackerNames); _fixBackerNames.Transform.localPosition = column2Top.Plus(y:-150); _disableBackerDialog = quickFactory.Checkbox(() => IEModOptions.DisableBackerDialogs); _disableBackerDialog.Transform.localPosition = column2Top.Plus(x:+30,y:-180); _fixBackerNames.IsChecked.OnChange(v => { if (v.Value) { _disableBackerDialog.OptionsTagComponent.Enable(); } else { _disableBackerDialog.IsChecked.Value = false; _disableBackerDialog.OptionsTagComponent.Disable(); } }); _fixBackerNames.IsChecked.NotifyChange(); _enableCustomUI = quickFactory.Checkbox(() => IEModOptions.EnableCustomUi); _enableCustomUI.LocalPosition = column2Top.Plus(y: -210); _hideAntiClassSpells = quickFactory.Checkbox(() => IEModOptions.HideAnticlassSpells); _hideAntiClassSpells.LocalPosition = column2Top.Plus(y: -240); _hideWeaponEffects = quickFactory.Checkbox(() => IEModOptions.HideWeaponEffects); _hideWeaponEffects.LocalPosition = column2Top.Plus(y: -270); _autoLoadCustomStats = quickFactory.Checkbox(() => IEModOptions.AutoLoadCustomStats); _autoLoadCustomStats.LocalPosition = column1Top.Plus(y: -270); var centerCmbTop = new Vector3(-80, -40, 0); const int cmbLabelWidth = 300; const int cmbWidth = 515; _nerfedXpCmb = quickFactory.EnumDropdown(() => IEModOptions.NerfedXPTableSetting); _nerfedXpCmb.Width = cmbWidth; _nerfedXpCmb.LabelWidth = cmbLabelWidth; _nerfedXpCmb.LocalPosition = centerCmbTop; _perEncounterSpellsCmb = quickFactory.EnumDropdown(() => IEModOptions.PerEncounterSpellsSetting); _perEncounterSpellsCmb.LabelWidth = cmbLabelWidth; _perEncounterSpellsCmb.Width = cmbWidth; _perEncounterSpellsCmb.LocalPosition = centerCmbTop.Plus(y:-30); _extraGrimoireSpellsCmb = quickFactory.EnumDropdown(() => IEModOptions.ExtraWizardSpells); _extraGrimoireSpellsCmb.Width = cmbWidth; _extraGrimoireSpellsCmb.LabelWidth = cmbLabelWidth; _extraGrimoireSpellsCmb.Transform.localPosition = centerCmbTop.Plus(y:-60); _cipherStartingFocusCmb = quickFactory.EnumDropdown(() => IEModOptions.CipherStartingFocusSetting); _cipherStartingFocusCmb.LabelWidth = cmbLabelWidth; _cipherStartingFocusCmb.Width = cmbWidth; _cipherStartingFocusCmb.LocalPosition = centerCmbTop.Plus(y: -90); _autosaveCmb = quickFactory.EnumDropdown(() => IEModOptions.AutosaveSetting); _autosaveCmb.Width = cmbWidth; _autosaveCmb.LabelWidth = cmbLabelWidth; _autosaveCmb.Transform.localPosition = centerCmbTop.Plus(y:-120); _fastSneak = quickFactory.EnumDropdown(() => IEModOptions.FastSneak); _fastSneak.Width = cmbWidth; _fastSneak.LabelWidth = cmbLabelWidth; _fastSneak.Transform.localPosition = centerCmbTop.Plus(y: -150); _maxAdventurersCmb = quickFactory.EnumDropdown(() => IEModOptions.MaxAdventurersCount); _maxAdventurersCmb.Width = cmbWidth; _maxAdventurersCmb.LabelWidth = cmbLabelWidth; _maxAdventurersCmb.Transform.localPosition = centerCmbTop.Plus(y: -180); // Pallegina dispositions mod page quickFactory.CurrentParent = ieModDisposition.Transform; var favoredDisposition1 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaFavored1); favoredDisposition1.Width = 150; favoredDisposition1.LabelWidth = cmbLabelWidth; favoredDisposition1.LocalPosition = new Vector3(-60, cmbLabelWidth, 0); var favoredDisposition2 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaFavored2); favoredDisposition2.LabelWidth = 0; favoredDisposition2.Width = 150; favoredDisposition2.LocalPosition = new Vector3(100, cmbLabelWidth, 0); var disDisposition1 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaDisfavored1); disDisposition1.Width = 150; disDisposition1.LabelWidth = cmbLabelWidth; disDisposition1.LocalPosition = new Vector3(-60, 250, 0); var disDisposition2 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaDisfavored2); disDisposition2.LocalPosition = new Vector3(100, 250, 0); disDisposition2.LabelWidth = 0; disDisposition2.Width = 150; //REPLACES ORIGINAL CODE WITH SOME TWEAKED LINES (mostly due to changed number of tabs) this.PageButtonGroup.OnRadioSelectionChangedEvent += new UIRadioButtonGroup.RadioSelectionChanged(this.OnChangePage); // changed to Event this.m_PageButtonGrid = this.PageButtonGroup.GetComponent<UIGrid>(); this.m_PageButtons = new UIMultiSpriteImageButton[9]; this.m_PageButtons[0] = this.PageButtonPrefab; for (int i = 0; i < 9; i++) { if (i > 0) { this.m_PageButtons[i] = NGUITools.AddChild(this.PageButtonPrefab.transform.parent.gameObject, this.PageButtonPrefab.gameObject).GetComponent<UIMultiSpriteImageButton>(); } if (i < this.PageTitleStringIds.Length) { GUIStringLabel.Get(this.m_PageButtons[i].Label).SetString(this.PageTitleStringIds[i]); } else if(i == this.PageTitleStringIds.Length) // added this line { GUIStringLabel.Get (this.m_PageButtons [i].Label).FormatString = "IE Mod"; // added this line //Debug.LogWarning("Not enough strings provided for every options tab in OptionsManager."); } else if (i == this.PageTitleStringIds.Length + 1) { GUIStringLabel.Get(this.m_PageButtons[i].Label).FormatString = "Dispositions"; // added this line //Debug.LogWarning("Not enough strings provided for every options tab in OptionsManager."); } this.m_PageButtons[i].name = this.PageOrder[i] + "." + this.m_PageButtons[i].name; } //PURE ORIGINAL CODE NOW this.m_PageButtonGrid.Reposition(); UIOptionsTag[] mOptions = this.m_Options; for (int j = 0; j < (int)mOptions.Length; j++) { UIOptionsTag uIOptionsTag = mOptions[j]; if (uIOptionsTag.Checkbox) { uIOptionsTag.Checkbox.onStateChange += new UICheckbox.OnStateChange(this.OnCheckChanged); } } this.CombatTimerSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.CombatTimerSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnCombatTimerChanged)); this.AutoslowThresholdSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.AutoslowThresholdSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnAutoslowThresholdChanged)); this.TooltipDelay.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.TooltipDelay.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnTooltipDelayChanged)); this.FontSize.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.FontSize.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnFontSizeChanged)); this.GammaSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.GammaSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnGammaSliderChanged)); this.AreaLootRangeSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.AreaLootRangeSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnAreaLootSliderChanged)); this.VoiceFrequency.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.VoiceFrequency.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnVoiceFrequencyChanged)); this.ScrollSpeed.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.ScrollSpeed.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnScrollSpeedChanged)); this.LanguageDropdown.OnDropdownOptionChangedEvent += new UIDropdownMenu.DropdownOptionChanged(this.OnLanguageChanged); // changed to Event this.ResolutionDropdown.OnDropdownOptionChangedEvent += new UIDropdownMenu.DropdownOptionChanged(this.OnResolutionChanged); // changed to Event this.QualitySlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.QualitySlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnQualityChanged)); this.FrameRateMaxSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged) Delegate.Combine(this.FrameRateMaxSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnMaxFPSChanged)); this.m_VolumeSliders = new UIOptionsSliderGroup[4]; UIOptionsVolumeSlider[] componentsInChildren = base.GetComponentsInChildren<UIOptionsVolumeSlider>(true); for (int k = 0; k < (int)componentsInChildren.Length; k++) { UIOptionsVolumeSlider uIOptionsVolumeSlider = componentsInChildren[k]; if (this.m_VolumeSliders[(int)uIOptionsVolumeSlider.Category] == null) { UIOptionsSliderGroup component = uIOptionsVolumeSlider.GetComponent<UIOptionsSliderGroup>(); this.m_VolumeSliders[(int)uIOptionsVolumeSlider.Category] = component; component.Slider.OnChanged += new UIOptionsSlider.OnSettingChanged(this.OnVolumeChanged); } } this.AcceptButton.onClick = (UIEventListener.VoidDelegate) Delegate.Combine(this.AcceptButton.onClick, new UIEventListener.VoidDelegate(this.OnAcceptClick)); this.DefControlsButton.onClick = (UIEventListener.VoidDelegate) Delegate.Combine(this.DefControlsButton.onClick, new UIEventListener.VoidDelegate(this.OnRestoreDefaultControls)); this.ApplyResolutionButton.onClick = (UIEventListener.VoidDelegate) Delegate.Combine(this.ApplyResolutionButton.onClick, new UIEventListener.VoidDelegate(this.OnApplyResolution)); }
private void mod_Start() { //NEW CODE HERE var exampleCheckbox = this.ComponentsInDescendants <UIOptionsTag>(true).Single( opt => opt.Checkbox && opt.BoolSuboption == GameOption.BoolOption.SCREEN_EDGE_SCROLLING) .transform; Prefabs.QuickCheckbox = exampleCheckbox.Component <UIOptionsTag>(); Prefabs.QuickDropdown = ResolutionDropdown.transform.parent.gameObject; Prefabs.QuickButton = UIOptionsManager.Instance.PageButtonPrefab.gameObject; Prefabs.QuickPage = Pages[5]; var pageParent = Pages[5].transform.parent; var ieModOptions = new QuickPage(pageParent, "IEModOptions_Settings_Page"); var ieModDisposition = new QuickPage(pageParent, "IEModOptions_Disposition_Page"); Pages = Pages.Concat(new[] { ieModOptions.GameObject, ieModDisposition.GameObject }).ToArray(); //ORIGINAL CODE this.SetMenuLayout(OptionsMenuLayout.InGame); this.QuitButton.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(this.QuitButton.onClick, new UIEventListener.VoidDelegate(this.OnQuitClicked)); this.SaveButton.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(this.SaveButton.onClick, new UIEventListener.VoidDelegate(this.OnSaveClicked)); this.LoadButton.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(this.LoadButton.onClick, new UIEventListener.VoidDelegate(this.OnLoadClicked)); this.m_Options = this.ComponentsInDescendants <UIOptionsTag>(true); //NEW CODE var quickFactory = new QuickFactory() { CurrentParent = Pages[7].transform }; //File.WriteAllText("ComboboxDump.txt", UnityObjectDumper.PrintUnityGameObject(exampleDropdown.gameObject, null, x => false)); quickFactory.CurrentParent = Pages[7].transform; var column1Top = new Vector3(-210, 330, 0); //The following are the controls that appear in the GUI of the mod. _oneTooltip = quickFactory.Checkbox(() => IEModOptions.OneTooltip); _oneTooltip.Transform.localPosition = column1Top; _disableEngagement = quickFactory.Checkbox(() => IEModOptions.DisableEngagement); _disableEngagement.LocalPosition = column1Top.Plus(y: -30); _blueCircles = quickFactory.Checkbox(() => IEModOptions.BlueCircles); _blueCircles.Transform.localPosition = column1Top.Plus(y: -60); _blueCirclesBg = quickFactory.Checkbox(() => IEModOptions.BlueCirclesBG); _blueCirclesBg.Transform.localPosition = column1Top.Plus(x: +30, y: -90); _blueCircles.IsChecked.HasChanged += x => { if (x.Value) { _blueCirclesBg.OptionsTagComponent.Enable(); } else { _blueCirclesBg.IsChecked.Value = false; _blueCirclesBg.OptionsTagComponent.Disable(); } }; _blueCircles.IsChecked.NotifyChange(); _alwaysShowCircles = quickFactory.Checkbox(() => IEModOptions.AlwaysShowCircles); _alwaysShowCircles.Transform.localPosition = column1Top.Plus(y: -120); _unlockCombatInv = quickFactory.Checkbox(() => IEModOptions.UnlockCombatInv); _unlockCombatInv.Transform.localPosition = column1Top.Plus(y: -150); _npcDispositionFix = quickFactory.Checkbox(() => IEModOptions.NPCDispositionFix); _npcDispositionFix.Transform.localPosition = column1Top.Plus(y: -180); _removeMovingRecovery = quickFactory.Checkbox(() => IEModOptions.RemoveMovingRecovery); _removeMovingRecovery.Transform.localPosition = column1Top.Plus(y: -210); //_fastSneak = quickFactory.Checkbox(() => IEModOptions.FastSneak); //_fastSneak.Transform.localPosition = column1Top.Plus(y:-240); /* * * TJH 8/28/2015. Improved AI Excluded from v2.0 * _improvedAi = quickFactory.Checkbox(() => IEModOptions.ImprovedAI); * _improvedAi.Transform.localPosition = column1Top.Plus(y: -270); * * */ _disableFriendlyFire = quickFactory.Checkbox(() => IEModOptions.DisableFriendlyFire); /* * * TJH 8/28/2015. Moved up since Improved AI and Fast Sneak are no longer present here * * */ _disableFriendlyFire.Transform.localPosition = column1Top.Plus(y: -240); var column2Top = column1Top.Plus(x: +420); _lootShuffler = quickFactory.Checkbox(() => IEModOptions.LootShuffler); _lootShuffler.Transform.localPosition = column2Top; _gameSpeed = quickFactory.Checkbox(() => IEModOptions.GameSpeedMod); _gameSpeed.Transform.localPosition = column2Top.Plus(y: -30); _combatOnly = quickFactory.Checkbox(() => IEModOptions.CombatOnlyMod); _combatOnly.Transform.localPosition = column2Top.Plus(y: -60); _bonusSpellsPerDay = quickFactory.Checkbox(() => IEModOptions.BonusSpellsPerDay); _bonusSpellsPerDay.Transform.localPosition = column2Top.Plus(y: -90); _targetTurnedEnemies = quickFactory.Checkbox(() => IEModOptions.TargetTurnedEnemies); _targetTurnedEnemies.Transform.localPosition = column2Top.Plus(y: -120); _fixBackerNames = quickFactory.Checkbox(() => IEModOptions.FixBackerNames); _fixBackerNames.Transform.localPosition = column2Top.Plus(y: -150); _disableBackerDialog = quickFactory.Checkbox(() => IEModOptions.DisableBackerDialogs); _disableBackerDialog.Transform.localPosition = column2Top.Plus(x: +30, y: -180); _fixBackerNames.IsChecked.OnChange(v => { if (v.Value) { _disableBackerDialog.OptionsTagComponent.Enable(); } else { _disableBackerDialog.IsChecked.Value = false; _disableBackerDialog.OptionsTagComponent.Disable(); } }); _fixBackerNames.IsChecked.NotifyChange(); _enableCustomUI = quickFactory.Checkbox(() => IEModOptions.EnableCustomUi); _enableCustomUI.LocalPosition = column2Top.Plus(y: -210); _hideAntiClassSpells = quickFactory.Checkbox(() => IEModOptions.HideAnticlassSpells); _hideAntiClassSpells.LocalPosition = column2Top.Plus(y: -240); _hideWeaponEffects = quickFactory.Checkbox(() => IEModOptions.HideWeaponEffects); _hideWeaponEffects.LocalPosition = column2Top.Plus(y: -270); _autoLoadCustomStats = quickFactory.Checkbox(() => IEModOptions.AutoLoadCustomStats); _autoLoadCustomStats.LocalPosition = column1Top.Plus(y: -270); _enableCheatKeys = quickFactory.Checkbox(() => IEModOptions.EnableCheatKeys); _enableCheatKeys.LocalPosition = column1Top.Plus(y: -300); _chanterPhraseCount = quickFactory.Checkbox(() => IEModOptions.ChanterPhraseCount); _chanterPhraseCount.LocalPosition = column2Top.Plus(y: -300); var centerCmbTop = new Vector3(-80, -40, 0); const int cmbLabelWidth = 300; const int cmbWidth = 515; _nerfedXpCmb = quickFactory.EnumDropdown(() => IEModOptions.NerfedXPTableSetting); _nerfedXpCmb.Width = cmbWidth; _nerfedXpCmb.LabelWidth = cmbLabelWidth; _nerfedXpCmb.LocalPosition = centerCmbTop; _perEncounterSpellsCmb = quickFactory.EnumDropdown(() => IEModOptions.PerEncounterSpellsSetting); _perEncounterSpellsCmb.LabelWidth = cmbLabelWidth; _perEncounterSpellsCmb.Width = cmbWidth; _perEncounterSpellsCmb.LocalPosition = centerCmbTop.Plus(y: -30); _extraGrimoireSpellsCmb = quickFactory.EnumDropdown(() => IEModOptions.ExtraWizardSpells); _extraGrimoireSpellsCmb.Width = cmbWidth; _extraGrimoireSpellsCmb.LabelWidth = cmbLabelWidth; _extraGrimoireSpellsCmb.Transform.localPosition = centerCmbTop.Plus(y: -60); _cipherStartingFocusCmb = quickFactory.EnumDropdown(() => IEModOptions.CipherStartingFocusSetting); _cipherStartingFocusCmb.LabelWidth = cmbLabelWidth; _cipherStartingFocusCmb.Width = cmbWidth; _cipherStartingFocusCmb.LocalPosition = centerCmbTop.Plus(y: -90); _autosaveCmb = quickFactory.EnumDropdown(() => IEModOptions.AutosaveSetting); _autosaveCmb.Width = cmbWidth; _autosaveCmb.LabelWidth = cmbLabelWidth; _autosaveCmb.Transform.localPosition = centerCmbTop.Plus(y: -120); _fastSneak = quickFactory.EnumDropdown(() => IEModOptions.FastSneak); _fastSneak.Width = cmbWidth; _fastSneak.LabelWidth = cmbLabelWidth; _fastSneak.Transform.localPosition = centerCmbTop.Plus(y: -150); _maxAdventurersCmb = quickFactory.EnumDropdown(() => IEModOptions.MaxAdventurersCount); _maxAdventurersCmb.Width = cmbWidth; _maxAdventurersCmb.LabelWidth = cmbLabelWidth; _maxAdventurersCmb.Transform.localPosition = centerCmbTop.Plus(y: -180); _capesHidden = quickFactory.Checkbox(() => IEModOptions.CapesHidden); _capesHidden.LocalPosition = column1Top.Plus(y: -327); _allInventorySlots = quickFactory.Checkbox(() => IEModOptions.AllInventorySlots); _allInventorySlots.LocalPosition = column2Top.Plus(y: -327); // Pallegina dispositions mod page quickFactory.CurrentParent = ieModDisposition.Transform; var favoredDisposition1 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaFavored1); favoredDisposition1.Width = 150; favoredDisposition1.LabelWidth = cmbLabelWidth; favoredDisposition1.LocalPosition = new Vector3(-60, cmbLabelWidth, 0); var favoredDisposition2 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaFavored2); favoredDisposition2.LabelWidth = 0; favoredDisposition2.Width = 150; favoredDisposition2.LocalPosition = new Vector3(100, cmbLabelWidth, 0); var disDisposition1 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaDisfavored1); disDisposition1.Width = 150; disDisposition1.LabelWidth = cmbLabelWidth; disDisposition1.LocalPosition = new Vector3(-60, 250, 0); var disDisposition2 = quickFactory.EnumDropdown(() => IEModOptions.PalleginaDisfavored2); disDisposition2.LocalPosition = new Vector3(100, 250, 0); disDisposition2.LabelWidth = 0; disDisposition2.Width = 150; //REPLACES ORIGINAL CODE WITH SOME TWEAKED LINES (mostly due to changed number of tabs) this.PageButtonGroup.OnRadioSelectionChangedEvent += new UIRadioButtonGroup.RadioSelectionChanged(this.OnChangePage); // changed to Event this.m_PageButtonGrid = this.PageButtonGroup.GetComponent <UIGrid>(); this.m_PageButtons = new UIMultiSpriteImageButton[9]; this.m_PageButtons[0] = this.PageButtonPrefab; for (int i = 0; i < 9; i++) { if (i > 0) { this.m_PageButtons[i] = NGUITools.AddChild(this.PageButtonPrefab.transform.parent.gameObject, this.PageButtonPrefab.gameObject).GetComponent <UIMultiSpriteImageButton>(); } if (i < this.PageTitleStringIds.Length) { GUIStringLabel.Get(this.m_PageButtons[i].Label).SetString(this.PageTitleStringIds[i]); } else if (i == this.PageTitleStringIds.Length) // added this line { GUIStringLabel.Get(this.m_PageButtons [i].Label).FormatString = "IE Mod"; // added this line //Debug.LogWarning("Not enough strings provided for every options tab in OptionsManager."); } else if (i == this.PageTitleStringIds.Length + 1) { GUIStringLabel.Get(this.m_PageButtons[i].Label).FormatString = "Dispositions"; // added this line //Debug.LogWarning("Not enough strings provided for every options tab in OptionsManager."); } this.m_PageButtons[i].name = this.PageOrder[i] + "." + this.m_PageButtons[i].name; } //PURE ORIGINAL CODE NOW this.m_PageButtonGrid.Reposition(); UIOptionsTag[] mOptions = this.m_Options; for (int j = 0; j < (int)mOptions.Length; j++) { UIOptionsTag uIOptionsTag = mOptions[j]; if (uIOptionsTag.Checkbox) { uIOptionsTag.Checkbox.onStateChange += new UICheckbox.OnStateChange(this.OnCheckChanged); } } this.CombatTimerSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.CombatTimerSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnCombatTimerChanged)); this.AutoslowThresholdSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.AutoslowThresholdSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnAutoslowThresholdChanged)); this.TooltipDelay.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.TooltipDelay.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnTooltipDelayChanged)); this.FontSize.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.FontSize.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnFontSizeChanged)); this.GammaSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.GammaSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnGammaSliderChanged)); this.AreaLootRangeSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.AreaLootRangeSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnAreaLootSliderChanged)); this.VoiceFrequency.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.VoiceFrequency.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnVoiceFrequencyChanged)); this.ScrollSpeed.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.ScrollSpeed.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnScrollSpeedChanged)); this.LanguageDropdown.OnDropdownOptionChangedEvent += new UIDropdownMenu.DropdownOptionChanged(this.OnLanguageChanged); // changed to Event this.ResolutionDropdown.OnDropdownOptionChangedEvent += new UIDropdownMenu.DropdownOptionChanged(this.OnResolutionChanged); // changed to Event this.QualitySlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.QualitySlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnQualityChanged)); this.FrameRateMaxSlider.Slider.OnChanged = (UIOptionsSlider.OnSettingChanged)Delegate.Combine(this.FrameRateMaxSlider.Slider.OnChanged, new UIOptionsSlider.OnSettingChanged(this.OnMaxFPSChanged)); this.m_VolumeSliders = new UIOptionsSliderGroup[4]; UIOptionsVolumeSlider[] componentsInChildren = base.GetComponentsInChildren <UIOptionsVolumeSlider>(true); for (int k = 0; k < (int)componentsInChildren.Length; k++) { UIOptionsVolumeSlider uIOptionsVolumeSlider = componentsInChildren[k]; if (this.m_VolumeSliders[(int)uIOptionsVolumeSlider.Category] == null) { UIOptionsSliderGroup component = uIOptionsVolumeSlider.GetComponent <UIOptionsSliderGroup>(); this.m_VolumeSliders[(int)uIOptionsVolumeSlider.Category] = component; component.Slider.OnChanged += new UIOptionsSlider.OnSettingChanged(this.OnVolumeChanged); } } this.AcceptButton.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(this.AcceptButton.onClick, new UIEventListener.VoidDelegate(this.OnAcceptClick)); this.DefControlsButton.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(this.DefControlsButton.onClick, new UIEventListener.VoidDelegate(this.OnRestoreDefaultControls)); this.ApplyResolutionButton.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(this.ApplyResolutionButton.onClick, new UIEventListener.VoidDelegate(this.OnApplyResolution)); }
private static void CreateInterface() { var quickFactory = new QuickFactory(UIPartyPortraitBar.Instance.transform.parent); Action<QuickButton, GameObject> addDragObject = (o, target) => { var collider = o.Collider; collider.AddComponent<UIDragObject>().target = target.transform; }; var initialPos = new Vector3(905, 487, -6); DragPartyBar = quickFactory.Button("Drag Party Bar", localPos: initialPos); addDragObject(DragPartyBar, UIPartyPortraitBar.Instance.gameObject); addDragObject(DragPartyBar, PartySolidHud); var choices = Directory.GetFiles(@"PillarsOfEternity_Data\Managed\iemod\frames", string.Format("*{0}x{1}.png", Screen.width, Screen.height)).Select( path => new DropdownChoice<string>(GetFrameNameFromPath(path), path)).ToList(); choices.Insert(0, new DropdownChoice<string>("(none)","")); var controlFactory = quickFactory; var layer = 14; FrameDropdown = new QuickDropdown<string>(quickFactory.CurrentParent) { Layer = layer, LocalPosition = new Vector3(392.6f, 622.7f, -6.0f), LabelText = "Custom Frame:", LabelWidth = 150, Width = 300, Options = choices }; FrameDropdown.SelectedValue.Bind(SelectedFrame); BlockClicking.Apply(FrameDropdown); DragHugBgr = controlFactory.Button("Drag Hud Bgr", localPos: initialPos.Plus(y: 50f)); DragHugBgr.LocalPosition = initialPos.Plus(y: 50f); DragHugBgr.Layer = layer; addDragObject(DragHugBgr, ActionBarTrimB); DragLog = controlFactory.Button("Drag Log", localPos: initialPos.Plus(y: 100f)); DragLog.Layer = layer; addDragObject(DragLog, ConsoleWindow); DragAbilitiesBar = controlFactory.Button("Drag Abilities", localPos: initialPos.Plus(y: -50f)); DragAbilitiesBar.Layer = layer; addDragObject(DragAbilitiesBar, AbilitiesBar); ToggleLogButtons = controlFactory.Button("T. Log Buttons Side", localPos: initialPos.Plus(x:400f, y:-50f)); ToggleLogButtons.Layer = layer; ToggleLogButtons.Click += x => SetLogButtonsAlignment(RadioGroup.Component<UIAnchor>().side != UIAnchor.Side.TopLeft); ToggleHudOrientation = controlFactory.Button("T. Hud Horiz/Vert", localPos: initialPos.Plus(400f)); ToggleHudOrientation.Layer = layer; ToggleHudOrientation.Click += x => SetHudOrientation(ButtonsLeft.Component<UIGrid>().arrangement == UIGrid.Arrangement.Vertical); DragHudPanelLeft = controlFactory.Button("Drag Hud Panel 1", localPos: initialPos.Plus(y: -150f)); DragHudPanelLeft.Layer = layer; addDragObject(DragHudPanelLeft, ButtonsLeft); DragHudPanelRight = controlFactory.Button("Drag Hud Panel 2", localPos: initialPos.Plus(y: -200f)); DragHudPanelRight.Layer = layer; addDragObject(DragHudPanelRight, ButtonsRight); DragClock = controlFactory.Button("Drag Clock", localPos: initialPos.Plus(y: -100f)); DragClock.Layer = layer; addDragObject(DragClock, TimeWidget); ToggleHudBgr = controlFactory.Button("T. Hud Background", localPos: initialPos.Plus(400f, 50f)); ToggleHudBgr.Layer = layer; ToggleHudBgr.Click += x => ActionBarTrimB.SetActive(!ActionBarTrimB.gameObject.activeSelf); TooltipOffsetCheckbox = new QuickCheckbox("TooltipOffsetChbox", controlFactory.CurrentParent) { Label = "Tooltip Offset", Layer = layer, LocalPosition = FrameDropdown.LocalPosition.Plus(x:-110, y:-50) }; //UnityPrinter.HierarchyPrinter.Print(TooltipOffsetCheckbox.GameObject); TooltipOffsetCheckbox.IsChecked.Bind(TooltipOffset); TogglePartyOrientation = controlFactory.Button("T. Party Horiz/Vert", localPos: initialPos.Plus(400f, 100f)); TogglePartyOrientation.Layer = layer; TogglePartyOrientation.Click += _ => mod_UIPartyPortrait.IsVertical = !mod_UIPartyPortrait.IsVertical; ToggleBuffsSide = controlFactory.Button("Toggle Buffs Side", localPos: initialPos.Plus(400f, 150f)); ToggleBuffsSide.Layer = layer; ToggleBuffsSide.Click += x => SetBuffSide(); DragFormationBar = controlFactory.Button("Drag Formation Bar", localPos: initialPos.Plus(y: -250f)); DragFormationBar.Layer = layer; addDragObject(DragFormationBar, FormationButtonSet); ToggleButtonsBgr = controlFactory.Button("T. Buttons Background", localPos: initialPos.Plus(400f, -100f)); ToggleButtonsBgr.Click += x => SetButtonsBackgroundActive(); ToggleButtonsBgr.Layer = layer; TogglePortraitHighlights = controlFactory.Button("T. Portrait Highlight", localPos: initialPos.Plus(400f, -150f)); TogglePortraitHighlights.Click += x => SetPortraitHighlight(); TogglePortraitHighlights.Layer = layer; ToggleCustomTextures = controlFactory.Button("T. Custom Textures", localPos: initialPos.Plus(400f, -200f)); ToggleCustomTextures.Click += x => SetCustomTexturesActive(); ToggleCustomTextures.Layer = layer; SaveBtn = controlFactory.Button("Save & Close", localPos: initialPos.Plus(-140f, 250f)); SaveBtn.Layer = layer; SaveBtn.Click += x => { SaveLayout(IEModOptions.Layout); ShowInterface(false); }; CancelBtn = controlFactory.Button("Reset to Prev", localPos: initialPos.Plus(140f, 250f)); CancelBtn.Layer = layer; CancelBtn.Click += x => { LoadLayout(IEModOptions.Layout); }; UseDefaultUIBtn = controlFactory.Button("Reset to Default", localPos: initialPos.Plus(400f, 350f)); UseDefaultUIBtn.Layer = layer; UseDefaultUIBtn.Click += x => { LoadLayout(DefaultLayout); }; }
private static void CreateInterface() { var quickFactory = new QuickFactory(UIPartyPortraitBar.Instance.transform.parent); Action <QuickButton, GameObject> addDragObject = (o, target) => { var collider = o.Collider; collider.AddComponent <UIDragObject>().target = target.transform; }; var initialPos = new Vector3(905, 487, -6); DragPartyBar = quickFactory.Button("Drag Party Bar", localPos: initialPos); addDragObject(DragPartyBar, UIPartyPortraitBar.Instance.gameObject); addDragObject(DragPartyBar, PartySolidHud); var choices = Directory.GetFiles(@"PillarsOfEternity_Data\Managed\iemod\frames", string.Format("*{0}x{1}.png", Screen.width, Screen.height)).Select( path => new DropdownChoice <string>(GetFrameNameFromPath(path), path)).ToList(); choices.Insert(0, new DropdownChoice <string>("(none)", "")); var controlFactory = quickFactory; var layer = 14; FrameDropdown = new QuickDropdown <string>(quickFactory.CurrentParent) { Layer = layer, LocalPosition = new Vector3(392.6f, 622.7f, -6.0f), LabelText = "Custom Frame:", LabelWidth = 150, Width = 300, Options = choices }; FrameDropdown.SelectedValue.Bind(SelectedFrame); BlockClicking.Apply(FrameDropdown); DragHugBgr = controlFactory.Button("Drag Hud Bgr", localPos: initialPos.Plus(y: 50f)); DragHugBgr.LocalPosition = initialPos.Plus(y: 50f); DragHugBgr.Layer = layer; addDragObject(DragHugBgr, ActionBarTrimB); DragLog = controlFactory.Button("Drag Log", localPos: initialPos.Plus(y: 100f)); DragLog.Layer = layer; addDragObject(DragLog, ConsoleWindow); DragAbilitiesBar = controlFactory.Button("Drag Abilities", localPos: initialPos.Plus(y: -50f)); DragAbilitiesBar.Layer = layer; addDragObject(DragAbilitiesBar, AbilitiesBar); ToggleLogButtons = controlFactory.Button("T. Log Buttons Side", localPos: initialPos.Plus(x: 400f, y: -50f)); ToggleLogButtons.Layer = layer; ToggleLogButtons.Click += x => SetLogButtonsAlignment(RadioGroup.Component <UIAnchor>().side != UIAnchor.Side.TopLeft); ToggleHudOrientation = controlFactory.Button("T. Hud Horiz/Vert", localPos: initialPos.Plus(400f)); ToggleHudOrientation.Layer = layer; ToggleHudOrientation.Click += x => SetHudOrientation(ButtonsLeft.Component <UIGrid>().arrangement == UIGrid.Arrangement.Vertical); DragHudPanelLeft = controlFactory.Button("Drag Hud Panel 1", localPos: initialPos.Plus(y: -150f)); DragHudPanelLeft.Layer = layer; addDragObject(DragHudPanelLeft, ButtonsLeft); DragHudPanelRight = controlFactory.Button("Drag Hud Panel 2", localPos: initialPos.Plus(y: -200f)); DragHudPanelRight.Layer = layer; addDragObject(DragHudPanelRight, ButtonsRight); DragClock = controlFactory.Button("Drag Clock", localPos: initialPos.Plus(y: -100f)); DragClock.Layer = layer; addDragObject(DragClock, TimeWidget); ToggleHudBgr = controlFactory.Button("T. Hud Background", localPos: initialPos.Plus(400f, 50f)); ToggleHudBgr.Layer = layer; ToggleHudBgr.Click += x => ActionBarTrimB.SetActive(!ActionBarTrimB.gameObject.activeSelf); TooltipOffsetCheckbox = new QuickCheckbox("TooltipOffsetChbox", controlFactory.CurrentParent) { Label = "Tooltip Offset", Layer = layer, LocalPosition = FrameDropdown.LocalPosition.Plus(x: -110, y: -50) }; //UnityPrinter.HierarchyPrinter.Print(TooltipOffsetCheckbox.GameObject); TooltipOffsetCheckbox.IsChecked.Bind(TooltipOffset); TogglePartyOrientation = controlFactory.Button("T. Party Horiz/Vert", localPos: initialPos.Plus(400f, 100f)); TogglePartyOrientation.Layer = layer; TogglePartyOrientation.Click += _ => mod_UIPartyPortrait.IsVertical = !mod_UIPartyPortrait.IsVertical; ToggleBuffsSide = controlFactory.Button("Toggle Buffs Side", localPos: initialPos.Plus(400f, 150f)); ToggleBuffsSide.Layer = layer; ToggleBuffsSide.Click += x => SetBuffSide(); DragFormationBar = controlFactory.Button("Drag Formation Bar", localPos: initialPos.Plus(y: -250f)); DragFormationBar.Layer = layer; addDragObject(DragFormationBar, FormationButtonSet); ToggleButtonsBgr = controlFactory.Button("T. Buttons Background", localPos: initialPos.Plus(400f, -100f)); ToggleButtonsBgr.Click += x => SetButtonsBackgroundActive(); ToggleButtonsBgr.Layer = layer; TogglePortraitHighlights = controlFactory.Button("T. Portrait Highlight", localPos: initialPos.Plus(400f, -150f)); TogglePortraitHighlights.Click += x => SetPortraitHighlight(); TogglePortraitHighlights.Layer = layer; ToggleCustomTextures = controlFactory.Button("T. Custom Textures", localPos: initialPos.Plus(400f, -200f)); ToggleCustomTextures.Click += x => SetCustomTexturesActive(); ToggleCustomTextures.Layer = layer; SaveBtn = controlFactory.Button("Save & Close", localPos: initialPos.Plus(-140f, 250f)); SaveBtn.Layer = layer; SaveBtn.Click += x => { SaveLayout(IEModOptions.Layout); ShowInterface(false); }; CancelBtn = controlFactory.Button("Reset to Prev", localPos: initialPos.Plus(140f, 250f)); CancelBtn.Layer = layer; CancelBtn.Click += x => { LoadLayout(IEModOptions.Layout); }; UseDefaultUIBtn = controlFactory.Button("Reset to Default", localPos: initialPos.Plus(400f, 350f)); UseDefaultUIBtn.Layer = layer; UseDefaultUIBtn.Click += x => { LoadLayout(DefaultLayout); }; }
public static void renderKernel(GThread thread, uint[,] image, float[] pX, float[] pY, float[] pZ, float[] colorPosition, float[] currentTimeArray) { int x = (thread.blockIdx.x * thread.blockDim.x) + thread.threadIdx.x; int y = (thread.blockIdx.y * thread.blockDim.y) + thread.threadIdx.y; float currentTime = currentTimeArray[0]; Vector3 camera = new Vector3(-5, 8, -18); // was -1,8,18 Vector3 frameTopLeft = new Vector3(-3, 3, 0); float frameWidth = 6.0f; float frameHeight = 6.0f; float radius = 0.04f; Vector3 rayThrough = new Vector3(frameTopLeft.X + frameWidth / width * x, frameTopLeft.Y - frameHeight / height * y, 0.0f); Vector3 initialRay = rayThrough.Minus(camera).Normalized(); Vector3 lightPosition = new Vector3(-5.0f, -5.0f, -5.0f); bool hitBoundingSphere = false; float bestT = 100.0f; // far viewing plane int bestI = -1; for (int i = 0; i < pX.Length; i++) { Vector3 centerOfSphere = new Vector3(pX[i], pY[i], pZ[i]); float t = SolveForSphere(camera, initialRay, centerOfSphere, radius); if (!float.IsNaN(t)) { if (t < bestT) { bestT = t; bestI = i; hitBoundingSphere = true; } } } float knifeT = SolveForParabaloidKnife(camera, initialRay, currentTime); bool hitKnife = false; if (!float.IsNaN(knifeT) && knifeT < bestT) { bestT = knifeT; hitKnife = true; hitBoundingSphere = false; } if (hitBoundingSphere || hitKnife) { Vector3 startOfInching = camera.Plus(initialRay.Multiply(bestT)); float inchDelta = 0.001f; float totalInching = 0.0f; float maxInching = 0.5f; float threshold = 0.08f; bool hit = true; // false; Vector3 normal = new Vector3(0, 0, 0); Vector3 hitPosition = new Vector3(0, 0, 0); Vector3 contributingColor = new Vector3(0, 0, 0); if (hitBoundingSphere) { Vector3 contributingSphere = new Vector3(pX[bestI], pY[bestI], pZ[bestI]); Vector3 color1 = new Vector3(color1R, color1G, color1B); Vector3 color2 = new Vector3(color2R, color2G, color2B); float colorT = GMath.Min(GMath.Max(colorPosition[bestI], 0.0f), 1.0f); Vector3 fromSphere = startOfInching.Minus(contributingSphere); normal = fromSphere.Normalized(); // new Vector3(0, 0, 0); hitPosition = startOfInching; contributingColor = color1.ColorBlend(color2, colorT); } else if (hitKnife) { hitPosition = startOfInching; normal = new Vector3(hitPosition.X, 2.0f * knifeRenderWidthSquared * (hitPosition.Y + GMath.Cos(currentTime)), 2.0f * knifeRenderWidthSquared * (hitPosition.Z + GMath.Sin(currentTime))).Normalized(); contributingColor = new Vector3(0.8f, 0.7f, 0.7f); } //Vector3 currentPosition = new Vector3(0, 0, 0); // iso sphere's not today //while (totalInching < maxInching) //{ // currentPosition = startOfInching.Plus(initialRay.Multiply(totalInching)); // totalInching += inchDelta; // // the contributions from each sphere // float sumContributions = 0.0f; // Vector3 contributedNormals = new Vector3(0, 0, 0); // for (int i = 0; i < pX.Length; i++) // { // Vector3 contributingSphere = new Vector3(pX[i], pY[i], pZ[i]); // Vector3 fromSphere = currentPosition.Minus(contributingSphere); // float distanceToContributor = fromSphere.Magnitude(); // if (distanceToContributor < 0.03535f) // { // float functionX = distanceToContributor * 20.0f; // float contribution = ((functionX * functionX * functionX * functionX) - // (functionX * functionX) + 0.25f); // //float contribution = 1.0f / (distanceToContributor * distanceToContributor); // sumContributions += contribution; // contributedNormals = contributedNormals.Plus(fromSphere.Normalized().Multiply(contribution)); // } // } // if (sumContributions >= threshold) // { // hit = true; // normal = contributedNormals.Normalized(); // break; // } //} if (hit) { float specularHighlightHardness = 10.0f; // normalized vector from hit position to light position Vector3 hitToLight = lightPosition.Minus(hitPosition).Normalized(); // normalized vector from hit position to eye/camera Vector3 hitToEye = camera.Minus(hitPosition).Normalized(); // H in specular component Vector3 eyeHalfVector = hitToEye.Plus(hitToLight).Normalized(); // diffuse factor float diffuseFactor = GMath.Max(hitToLight.Dot(normal), 0.0f); float specularFactor = GMath.Pow(GMath.Max(eyeHalfVector.Dot(normal), 0.0f), specularHighlightHardness); // light coefficients float kspecular = 0.4f; float kdiffuse = 0.5f; float kambient = 0.1f; // color Vector3 color = contributingColor; // final color Vector3 ambient = color.Multiply(kambient); Vector3 diffuse = color.Multiply(diffuseFactor * kdiffuse); Vector3 specular = color.Multiply(specularFactor * kspecular); Vector3 finalColor = ambient.Plus(diffuse).Plus(specular); uint shiftr = (uint)(finalColor.X * 255.0f); uint shiftg = (uint)(finalColor.Y * 255.0f); uint shiftb = (uint)(finalColor.Z * 255.0f); image[x, y] = (shiftr << 16) | (shiftg << 8) | (shiftb << 0); } else { image[x, y] = 0x00FFFF00; } } else { image[x, y] = 0x00FFFF00; } }
public static void particleKernel(GThread thread, float[] pX, float[] pY, float[] pZ, float[] pXnew, float[] pYnew, float[] pZnew, float[] vX, float[] vY, float[] vZ, float[] density, float[] restDensityArray, float[] colorPosition, float[] colorVelocity, float[] newColorPosition, float[] newColorVelocity, float[] currentTimeArray) { int particleIndex = thread.blockIdx.x + thread.blockIdx.y * 10 + thread.threadIdx.x * 10 * 10 + thread.threadIdx.y * 10 * 10 * 10; Vector3 currentParticlePosition = new Vector3(pX[particleIndex], pY[particleIndex], pZ[particleIndex]); Vector3 currentParticleVelocity = new Vector3(vX[particleIndex], vY[particleIndex], vZ[particleIndex]); // the current time float currentTime = currentTimeArray[0]; // the rest density float restDensity = restDensityArray[0]; // force of pressure setup float idealGasConstantForThisFluid = 1.8615f; //0.4615f; // <- the actual value of water float pressureKernelH = 0.5f; Vector3 particleForceOfPressure = new Vector3(0.0f, 0.0f, 0.0f); float particlePressure = idealGasConstantForThisFluid * (density[particleIndex] - restDensity); // force of viscosity setup float fluidViscosity = 0.4f; float viscosityKernelH = 0.5f; Vector3 particleForceOfViscosity = new Vector3(0.0f, 0.0f, 0.0f); // force of surface tension setup float fluidSurfaceTension = 0.1f; // 0.4f; Vector3 smoothedColorField = new Vector3(0.0f, 0.0f, 0.0f); float divergenceOfSmoothedColorField = 0.0f; float surfaceTensionKernelH = 0.5f; Vector3 particleForceOfSurfaceTension = new Vector3(0.0f, 0.0f, 0.0f); // color setup float colorAccelerationCoefficient = 0.1f; float colorSumReductionCoefficient = 0.001f; float forceOfColor = 0.0f; float currentParticleColor = colorPosition[particleIndex]; float colorKernelH = 0.1f; for (int i = 0; i < pX.Length; i++) { if (i != particleIndex) // don't compare to yourself { Vector3 otherParticle = new Vector3(pX[i], pY[i], pZ[i]); Vector3 otherParticleVelocity = new Vector3(vX[i], vY[i], vZ[i]); Vector3 deltaR = currentParticlePosition.Minus(otherParticle); float deltaRMagnitude = deltaR.Magnitude(); Vector3 deltaRNormalized = deltaR.Normalized(); if (deltaR.Magnitude() > 0.00000000000001f && density[i] > 0.00000000000001f) { // do pressure float otherParticlePressure = idealGasConstantForThisFluid * (density[i] - restDensity); float massPressureTerm = particleMass * ((otherParticlePressure + particlePressure) / (density[i] * 2.0f)); float magnitudeOfForceOfPressure = massPressureTerm * KernelGradientSpiky(deltaRMagnitude, pressureKernelH); particleForceOfPressure = particleForceOfPressure.Minus(deltaRNormalized.Multiply(magnitudeOfForceOfPressure)); // do viscosity Vector3 massVelocityTerm = currentParticleVelocity.Minus(otherParticleVelocity).Divide(density[i]).Multiply(particleMass); float kernelTerm = KernelDoubleGradientViscosity(deltaRMagnitude, viscosityKernelH); particleForceOfViscosity = particleForceOfViscosity.Minus(massVelocityTerm.Multiply(kernelTerm)); // do surface tension float smoothedColorScalar = particleMass * (1.0f / density[i]) * KernelGradientPolynomial(deltaRMagnitude, surfaceTensionKernelH); smoothedColorField = smoothedColorField.Minus(deltaRNormalized.Multiply(smoothedColorScalar)); float divergenceOfSmoothedColorScalar = particleMass * (1.0f / density[i]) * KernelDoubleGradientPolynomial(deltaRMagnitude, surfaceTensionKernelH); divergenceOfSmoothedColorField -= divergenceOfSmoothedColorField; // do color float otherColor = colorPosition[i]; float rangedOurColor = currentParticleColor - 0.5f; float rangedOtherColor = otherColor - 0.5f; float colorTerm = (rangedOtherColor * rangedOtherColor * rangedOtherColor - rangedOurColor * rangedOurColor * rangedOurColor); forceOfColor += colorTerm * KernelPolynomial(deltaRMagnitude, colorKernelH); } } } // final viscosity math particleForceOfViscosity = particleForceOfViscosity.Multiply(fluidViscosity); // final surface tension math float smoothedColorFieldMagnitude = smoothedColorField.Magnitude(); if (smoothedColorFieldMagnitude > 0.00000000000001f) { particleForceOfSurfaceTension = smoothedColorField.Multiply(divergenceOfSmoothedColorField) .Divide(smoothedColorFieldMagnitude).Multiply(-fluidSurfaceTension); } // final gravity math Vector3 particleForceOfGravity = new Vector3(1.0f, 0.0f, 0.0f).Multiply(density[particleIndex] * accelerationDueToGravity); // final color math float colorAcceleration = (forceOfColor / density[particleIndex]) * colorAccelerationCoefficient; newColorPosition[particleIndex] = currentParticleColor + colorVelocity[particleIndex] * deltaTimePerParticleCycle + 0.5f * colorAcceleration * deltaTimePerParticleCycle * deltaTimePerParticleCycle; newColorVelocity[particleIndex] = colorVelocity[particleIndex] + colorAcceleration * deltaTimePerParticleCycle; if (newColorPosition[particleIndex] < 0.0f) { newColorPosition[particleIndex] = 0.0f; } else if (newColorPosition[particleIndex] > 1.0f) { newColorPosition[particleIndex] = 1.0f; } if (newColorVelocity[particleIndex] < 0.0f) { newColorVelocity[particleIndex] = 0.0f; } else if (newColorVelocity[particleIndex] > 1.0f) { newColorVelocity[particleIndex] = 1.0f; } // sum all forces on particle Vector3 sumOfForces = particleForceOfPressure.Plus(particleForceOfGravity).Plus(particleForceOfViscosity) .Plus(particleForceOfSurfaceTension); Vector3 sumOfAcceleration = new Vector3(0, 0, 0); if (density[particleIndex] > 0.00000000000001f) { sumOfAcceleration = sumOfForces.Divide(density[particleIndex]); } Vector3 positionDelta = currentParticleVelocity.Multiply(deltaTimePerParticleCycle).Plus( sumOfAcceleration.Multiply(deltaTimePerParticleCycle * deltaTimePerParticleCycle * 0.5f)); Vector3 velocityDelta = sumOfAcceleration.Multiply(deltaTimePerParticleCycle); Vector3 newPosition = currentParticlePosition.Plus(positionDelta); Vector3 newVelocity = currentParticleVelocity.Plus(velocityDelta); // reflect off bowl float bowlZComponent = -((newPosition.Z * 0.4f) * (newPosition.Z * 0.4f)); float bowlYComponent = -((newPosition.Y * 0.4f) * (newPosition.Y * 0.4f)); float bowlX = bowlZComponent + bowlYComponent + 2.0f; // we're out side the bottom of the bowl, reflect float bowlReflectionCoeff = 0.5f; if (newPosition.X > bowlX) { Vector3 normal = new Vector3(newPosition.X, -0.32f * newPosition.Y, -0.32f * newPosition.Z).Normalized(); newVelocity = newVelocity.Multiply(-1.0f); newVelocity = newVelocity.Minus(normal.Multiply((1.0f + bowlReflectionCoeff) * newVelocity.Dot(normal))); newPosition.X = bowlX; } // now the knife float knifeZComponent = -(((newPosition.Z + GMath.Sin(currentTime)) * 4.4f) * ((newPosition.Z + GMath.Sin(currentTime)) * 4.4f)); float knifeYComponent = -(((newPosition.Y + GMath.Cos(currentTime)) * 4.4f) * ((newPosition.Y + GMath.Cos(currentTime)) * 4.4f)); float knifeX = knifeZComponent + knifeYComponent + KnifeXOffsetAtTime(currentTime); // we're inside the knife, reflect float knifeReflectionCoeff = 1.0f; if (newPosition.X < knifeX) { Vector3 normal = new Vector3(newPosition.X, 38.72f * (newPosition.Y + GMath.Cos(currentTime)), 38.72f * (newPosition.Z + GMath.Sin(currentTime))).Normalized(); //newVelocity = newVelocity.Multiply(-1.0f); //newVelocity = newVelocity.Plus(normal.Multiply((1.0f + knifeReflectionCoeff) * newVelocity.Dot(normal))); Vector3 knifeDelta = new Vector3( KnifeXOffsetAtTime(currentTime) - KnifeXOffsetAtTime(currentTime - deltaTimePerParticleCycle), GMath.Cos(currentTime) - GMath.Cos(currentTime - deltaTimePerParticleCycle), GMath.Sin(currentTime) - GMath.Sin(currentTime - deltaTimePerParticleCycle)); Vector3 knifeVelocity = knifeDelta.Divide(deltaTimePerParticleCycle); knifeVelocity.X = 0.0f; knifeVelocity = knifeVelocity.Multiply(0.25f); //.PiecewiseMultiply(normal); newVelocity = newVelocity.Minus(knifeVelocity); //knifeDelta.X = 0.0f; newPosition = newPosition.Minus(knifeDelta); //newPosition.X = knifeX; // moves down to tip } pXnew[particleIndex] = newPosition.X; pYnew[particleIndex] = newPosition.Y; pZnew[particleIndex] = newPosition.Z; vX[particleIndex] = newVelocity.X; vY[particleIndex] = newVelocity.Y; vZ[particleIndex] = newVelocity.Z; }
private void OnDrawGizmos() { if (_showSurfaceBlocks_) { Gizmos.color = Color.green; Vector3 center = Coord.ToChunkOrigin(); for (int x = 0; x < ChunkSize.Width; x++) { for (int z = 0; z < ChunkSize.Width; z++) { bool hadBlock = _blocks[z, 0, x] > 0; for (int y = 0; y < ChunkSize.Height; y++) { bool render = false; int renderY = 0; bool hasBlock = _blocks[z, y, x] > 0; if (hadBlock != hasBlock) { renderY = y - (hadBlock ? 1 : 0); render = true; } else if (hasBlock && _blocks[z, y, x] < 255) { renderY = y; render = true; } if (render) { Vector3 offset = (new Vector3(x, renderY, z) + center); float size = (_blocks[z, renderY, x] / 255f); Vector3 up = offset.Plus(0, size, 0); Vector3 forward = offset.Plus(0, 0, size); Vector3 right = offset.Plus(size, 0, 0); Vector3 down = offset.Plus(0, -size, 0); Vector3 backward = offset.Plus(0, 0, -size); Vector3 left = offset.Plus(-size, 0, 0); Gizmos.DrawLine(up, right); Gizmos.DrawLine(right, down); Gizmos.DrawLine(down, left); Gizmos.DrawLine(left, up); Gizmos.DrawLine(up, forward); Gizmos.DrawLine(forward, down); Gizmos.DrawLine(down, backward); Gizmos.DrawLine(backward, up); size = .1f; Gizmos.DrawWireCube(offset, Vector3.one * size); hadBlock = hasBlock; } } } } } if (IsWaitingMesh) { Gizmos.color = Color.red; Gizmos.DrawWireCube(Coord.ToChunkOrigin() + Vector3.one * (ChunkSize.Width) / 2f, Vector3.one * ChunkSize.Width * 1.1f); } }