├── .gitattributes ├── .gitignore ├── .vs └── GTAV_ScriptCamTool │ └── v14 │ └── .suo ├── GTAV_ScriptCamTool.opensdf ├── GTAV_ScriptCamTool.sln └── GTAV_ScriptCamTool ├── GTAV_ScriptCamTool.csproj ├── Input ├── AnalogStickChangedEventArgs.cs ├── ButtonPressedEventArgs.cs ├── GamepadHandler.cs ├── KeyboardHandler.cs ├── MouseTouchedEventArgs.cs └── TriggerChangedEventArgs.cs ├── Menu.cs ├── PositionSelector.cs ├── Properties └── AssemblyInfo.cs ├── SplineCamera.cs ├── Timer.cs └── Utils.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /.vs/GTAV_ScriptCamTool/v14/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CamxxCore/ScriptCamTool/2aab37424684a2d482156845c481761139054e24/.vs/GTAV_ScriptCamTool/v14/.suo -------------------------------------------------------------------------------- /GTAV_ScriptCamTool.opensdf: -------------------------------------------------------------------------------- 1 | CamCAM-PC -------------------------------------------------------------------------------- /GTAV_ScriptCamTool.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GTAV_ScriptCamTool", "GTAV_ScriptCamTool\GTAV_ScriptCamTool.csproj", "{756EDB52-9D98-4E05-A0AA-2045AE624C5B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Debug|x64.ActiveCfg = Debug|x64 19 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Debug|x64.Build.0 = Debug|x64 20 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Release|x64.ActiveCfg = Release|x64 23 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/GTAV_ScriptCamTool.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {756EDB52-9D98-4E05-A0AA-2045AE624C5B} 8 | Library 9 | Properties 10 | GTAV_ScriptCamTool 11 | GTAV_ScriptCamTool 12 | v4.5.2 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | x64 34 | bin\x64\Debug\ 35 | 36 | 37 | x64 38 | bin\x64\Release\ 39 | 40 | 41 | 42 | ..\..\..\..\..\Desktop\GTAV\scripts\NativeUI.dll 43 | 44 | 45 | ..\..\..\..\..\Desktop\GTAV\ScriptHookVDotNet.dll 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | copy "$(TargetPath)" "C:\Program Files\Rockstar Games\Grand Theft Auto V\scripts\$(ProjectName).dll" 73 | 74 | 81 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Input/AnalogStickChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GTAV_ScriptCamTool.Input 4 | { 5 | public class AnalogStickChangedEventArgs : EventArgs 6 | { 7 | private int _x, _y; 8 | 9 | public AnalogStickChangedEventArgs(int x, int y) 10 | { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | /// 16 | /// The amount of force applied on the X axis, from 0 - 254. Neutral position is 127. 17 | /// 18 | public int X { get { return _x; } } 19 | 20 | /// 21 | /// The amount of force applied on the Y axis, from 0 - 254. Neutral position is 127. 22 | /// 23 | public int Y { get { return _y; } } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Input/ButtonPressedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GTAV_ScriptCamTool.Input 4 | { 5 | public class ButtonPressedEventArgs : EventArgs 6 | { 7 | private int _value; 8 | 9 | public ButtonPressedEventArgs(int value) 10 | { 11 | _value = value; 12 | } 13 | 14 | /// 15 | /// The amount of force applied to the button, from 0 - 254. 16 | /// 17 | public int Value { get { return _value; } } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Input/GamepadHandler.cs: -------------------------------------------------------------------------------- 1 | using GTA.Native; 2 | 3 | namespace GTAV_ScriptCamTool.Input 4 | { 5 | public delegate void ButtonPressedEventHandler(object sender, ButtonPressedEventArgs e); 6 | 7 | public delegate void TriggerChangedEventHandler(object sender, TriggerChangedEventArgs e); 8 | 9 | public delegate void AnalogStickChangedEventHandler(object sender, AnalogStickChangedEventArgs e); 10 | 11 | public class GamepadHandler 12 | { 13 | #region Declare Events 14 | /// 15 | /// Called when the user presses the A button. 16 | /// 17 | public event ButtonPressedEventHandler AButtonPressed; 18 | 19 | /// 20 | /// Called when the user presses the B button. 21 | /// 22 | public event ButtonPressedEventHandler BButtonPressed; 23 | 24 | /// 25 | /// Called when the user presses the X button. 26 | /// 27 | public event ButtonPressedEventHandler XButtonPressed; 28 | 29 | /// 30 | /// Called when the user presses the Y button. 31 | /// 32 | public event ButtonPressedEventHandler YButtonPressed; 33 | 34 | /// 35 | /// Called when the user presses the right trigger. 36 | /// 37 | public event TriggerChangedEventHandler RightTriggerChanged; 38 | 39 | /// 40 | /// Called when the user presses the left trigger. 41 | /// 42 | public event TriggerChangedEventHandler LeftTriggerChanged; 43 | 44 | /// 45 | /// Called when the user presses the right bumper. 46 | /// 47 | public event ButtonPressedEventHandler RightBumperPressed; 48 | 49 | /// 50 | /// Called when the user presses the left bumper. 51 | /// 52 | public event ButtonPressedEventHandler LeftBumperPressed; 53 | 54 | /// 55 | /// Called when the user presses left on the Dpad. 56 | /// 57 | public event ButtonPressedEventHandler DpadLeftPressed; 58 | 59 | /// 60 | /// Called when the user presses down on the DPad. 61 | /// 62 | public event ButtonPressedEventHandler DpadDownPressed; 63 | 64 | /// 65 | /// Called when the user presses right on the Dpad. 66 | /// 67 | public event ButtonPressedEventHandler DpadRightPressed; 68 | 69 | /// 70 | /// Called when the user presses up on the Dpad. 71 | /// 72 | public event ButtonPressedEventHandler DpadUpPressed; 73 | 74 | /// 75 | /// Called when the user uses the analog stick. 76 | /// 77 | public event AnalogStickChangedEventHandler LeftStickChanged; 78 | 79 | /// 80 | /// Called when the user uses the analog stick. 81 | /// 82 | public event AnalogStickChangedEventHandler RightStickChanged; 83 | 84 | /// 85 | /// Called when the user uses the analog stick. 86 | /// 87 | public event ButtonPressedEventHandler LeftStickPressed; 88 | 89 | /// 90 | /// Called when the user uses the analog stick. 91 | /// 92 | public event ButtonPressedEventHandler RightStickPressed; 93 | 94 | 95 | #endregion 96 | 97 | public GamepadHandler() 98 | { 99 | } 100 | 101 | public void Update() 102 | { 103 | if (GetControlValue(220) != 127 || GetControlValue(221) != 127) 104 | OnRightStickChanged(new AnalogStickChangedEventArgs(GetControlValue(220), GetControlValue(221))); 105 | if (GetControlValue(218) != 127 || GetControlValue(219) != 127) 106 | OnLeftStickChanged(new AnalogStickChangedEventArgs(GetControlValue(218), GetControlValue(219))); 107 | 108 | if (GetControlInput(230)) 109 | OnLeftStickPressed(new ButtonPressedEventArgs(GetControlValue(230))); 110 | if (GetControlInput(231)) 111 | OnRightStickPressed(new ButtonPressedEventArgs(GetControlValue(231))); 112 | 113 | if (GetControlValue(229) > 127) 114 | OnRightTriggerChanged(new TriggerChangedEventArgs(GetControlValue(229))); 115 | if (GetControlValue(228) > 127) 116 | OnLeftTriggerChanged(new TriggerChangedEventArgs(GetControlValue(228))); 117 | 118 | if (GetControlInput(222)) 119 | OnYPressed(new ButtonPressedEventArgs(GetControlValue(222))); 120 | if (GetControlInput(223)) 121 | OnAPressed(new ButtonPressedEventArgs(GetControlValue(223))); 122 | if (GetControlInput(224)) 123 | OnXPressed(new ButtonPressedEventArgs(GetControlValue(224))); 124 | if (GetControlInput(225)) 125 | OnBPressed(new ButtonPressedEventArgs(GetControlValue(225))); 126 | if (GetControlInput(226)) 127 | OnLBPressed(new ButtonPressedEventArgs(GetControlValue(226))); 128 | if (GetControlInput(227)) 129 | OnRBPressed(new ButtonPressedEventArgs(GetControlValue(227))); 130 | } 131 | 132 | #region Event Handlers 133 | 134 | protected virtual void OnAPressed(ButtonPressedEventArgs e) 135 | { 136 | AButtonPressed?.Invoke(this, e); 137 | } 138 | 139 | protected virtual void OnBPressed(ButtonPressedEventArgs e) 140 | { 141 | BButtonPressed?.Invoke(this, e); 142 | } 143 | 144 | protected virtual void OnXPressed(ButtonPressedEventArgs e) 145 | { 146 | XButtonPressed?.Invoke(this, e); 147 | } 148 | 149 | protected virtual void OnYPressed(ButtonPressedEventArgs e) 150 | { 151 | YButtonPressed?.Invoke(this, e); 152 | } 153 | 154 | protected virtual void OnLBPressed(ButtonPressedEventArgs e) 155 | { 156 | LeftBumperPressed?.Invoke(this, e); 157 | } 158 | 159 | protected virtual void OnRBPressed(ButtonPressedEventArgs e) 160 | { 161 | RightBumperPressed?.Invoke(this, e); 162 | } 163 | 164 | protected virtual void OnLeftTriggerChanged(TriggerChangedEventArgs e) 165 | { 166 | LeftTriggerChanged?.Invoke(this, e); 167 | } 168 | 169 | protected virtual void OnRightTriggerChanged(TriggerChangedEventArgs e) 170 | { 171 | RightTriggerChanged?.Invoke(this, e); 172 | } 173 | 174 | protected virtual void OnLeftStickChanged(AnalogStickChangedEventArgs e) 175 | { 176 | LeftStickChanged?.Invoke(this, e); 177 | } 178 | 179 | protected virtual void OnRightStickChanged(AnalogStickChangedEventArgs e) 180 | { 181 | RightStickChanged?.Invoke(this, e); 182 | } 183 | 184 | protected virtual void OnLeftStickPressed(ButtonPressedEventArgs e) 185 | { 186 | LeftStickPressed?.Invoke(this, e); 187 | } 188 | 189 | protected virtual void OnRightStickPressed(ButtonPressedEventArgs e) 190 | { 191 | RightStickPressed?.Invoke(this, e); 192 | } 193 | 194 | #endregion 195 | 196 | private bool GetControlInput(int control) 197 | { 198 | return Function.Call(Hash.IS_CONTROL_JUST_PRESSED, 0, control); 199 | } 200 | 201 | private int GetControlValue(int control) 202 | { 203 | return Function.Call(Hash.GET_CONTROL_VALUE, 0, control); 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Input/KeyboardHandler.cs: -------------------------------------------------------------------------------- 1 | #define DEBUG 2 | using System.Windows.Forms; 3 | using GTA.Native; 4 | using GTA; 5 | 6 | 7 | 8 | namespace GTAV_GamepadHandler 9 | { 10 | public delegate void KeyPressedEventHandler(); 11 | 12 | public sealed class KeyboardHandler : Script 13 | { 14 | #region Events 15 | /// 16 | /// Called when the user presses the W key. 17 | /// 18 | public event ButtonPressedEventHandler WKeyPressed; 19 | 20 | /// 21 | /// Called when the user presses the A key. 22 | /// 23 | public event ButtonPressedEventHandler AKeyPressed; 24 | 25 | /// 26 | /// Called when the user presses the S key. 27 | /// 28 | public event ButtonPressedEventHandler SKeyPressed; 29 | 30 | /// 31 | /// Called when the user presses the D key. 32 | /// 33 | public event ButtonPressedEventHandler DKeyPressed; 34 | 35 | /// 36 | /// Called when the user presses the T key. 37 | /// 38 | /// 39 | #if DEBUG 40 | public event ButtonPressedEventHandler TKeyPressed; 41 | #endif 42 | 43 | #endregion 44 | 45 | public KeyboardHandler() 46 | { 47 | this.KeyDown += KeyIsDown; 48 | } 49 | 50 | private void KeyIsDown(object sender, KeyEventArgs e) 51 | { 52 | if (WKeyPressed != null && e.KeyCode == Keys.W) 53 | WKeyPressed(); 54 | if (AKeyPressed != null && e.KeyCode == Keys.A) 55 | AKeyPressed(); 56 | if (SKeyPressed != null && e.KeyCode == Keys.S) 57 | SKeyPressed(); 58 | if (DKeyPressed != null && e.KeyCode == Keys.D) 59 | DKeyPressed(); 60 | if (TKeyPressed != null && e.KeyCode == Keys.T) 61 | TKeyPressed(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Input/MouseTouchedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GTAV_ScriptCamTool.Input_Handlers 4 | { 5 | public class MouseTouchedEventArgs : EventArgs 6 | { 7 | private float _x, _y; 8 | 9 | public MouseTouchedEventArgs(float x, float y) 10 | { 11 | this._x = x; 12 | this._y = y; 13 | } 14 | 15 | /// 16 | /// The amount of force applied on the X axis, from 0 - 254. Neutral position is 127. 17 | /// 18 | public float X { get { return _x; } } 19 | 20 | /// 21 | /// The amount of force applied on the Y axis, from 0 - 254. Neutral position is 127. 22 | /// 23 | public float Y { get { return _y; } } 24 | } 25 | } -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Input/TriggerChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace GTAV_ScriptCamTool.Input 4 | { 5 | public class TriggerChangedEventArgs : EventArgs 6 | { 7 | private int _value; 8 | 9 | public TriggerChangedEventArgs(int value) 10 | { 11 | _value = value; 12 | } 13 | 14 | /// 15 | /// The amount of force applied to the trigger, from 127 - 254. 16 | /// 17 | public int Value { get { return _value; } } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Menu.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using System.Drawing; 4 | using System.Collections.Generic; 5 | using GTA; 6 | using GTA.Math; 7 | using GTA.Native; 8 | using NativeUI; 9 | using System.Linq; 10 | 11 | namespace GTAV_ScriptCamTool 12 | { 13 | public class Menu : Script 14 | { 15 | UIContainer msgBox = new UIContainer(); 16 | string msgText; 17 | float msgScale; 18 | Timer msgTimer = new Timer(1000); 19 | bool fadingMsg = false; 20 | 21 | int nodeDuration = 5000; 22 | private SplineCamera splineCam; 23 | private MenuPool activePool; 24 | private UIMenu mainMenu, cameraOptionsMenu; 25 | private PositionSelector selector; 26 | 27 | 28 | public Menu() 29 | { 30 | Tick += OnTick; 31 | KeyUp += KeyIsUp; 32 | cameraOptionsMenu = new UIMenu("Camera Options", string.Empty); 33 | var menuItem = new UIMenuListItem("Speed", Enumerable.Range(0, 100).Cast().ToList(), 1); 34 | cameraOptionsMenu.AddItem(menuItem); 35 | menuItem = new UIMenuListItem("Field Of View", Enumerable.Range(0, 100).Cast().ToList(), 50); 36 | cameraOptionsMenu.AddItem(menuItem); 37 | var menuItemB = new UIMenuCheckboxItem("Use Player View", false, "(May create smoother terrain rendering when enabled but restricts player movement and is prone to bugs.)"); 38 | cameraOptionsMenu.AddItem(menuItemB); 39 | menuItemB = new UIMenuCheckboxItem("End At Player", false, "(Camera tracks to player view at end of the scene)"); 40 | cameraOptionsMenu.AddItem(menuItemB); 41 | cameraOptionsMenu.OnListChange += OnListChanged; 42 | cameraOptionsMenu.OnCheckboxChange += OnCheckboxChanged; 43 | mainMenu = new UIMenu("Script Cam Tool", string.Empty); 44 | var menuItemA = new UIMenuItem("~g~Start Rendering"); 45 | menuItemA.Activated += (sender, item) => StartInterpolatingCam(); 46 | mainMenu.AddItem(menuItemA); 47 | menuItemA = new UIMenuItem("~r~Stop Rendering"); 48 | menuItemA.Activated += (sender, item) => StopInterpolatingCam(); 49 | mainMenu.AddItem(menuItemA); 50 | menuItemA = new UIMenuItem("Setup Nodes"); 51 | menuItemA.Activated += (sender, item) => EnterPointSelector(); 52 | mainMenu.AddItem(menuItemA); 53 | menuItemA = new UIMenuItem("Camera Options"); 54 | mainMenu.BindMenuToItem(cameraOptionsMenu, menuItemA); 55 | mainMenu.AddItem(menuItemA); 56 | menuItemA = new UIMenuItem("Reset All Cams"); 57 | menuItemA.Activated += (sender, item) => ResetAllCameras(); 58 | mainMenu.AddItem(menuItemA); 59 | menuItemA = new UIMenuItem("Close"); 60 | menuItemA.Activated += (sender, item) => activePool.CloseAllMenus(); 61 | mainMenu.AddItem(menuItemA); 62 | activePool = new MenuPool(); 63 | activePool.Add(mainMenu); 64 | activePool.Add(cameraOptionsMenu); 65 | ResetAllCameras(); 66 | } 67 | 68 | private void OnTick(object sender, EventArgs e) 69 | { 70 | if (fadingMsg) 71 | { 72 | if (msgBox.Color.A > 10 || msgBox.Items[0].Color.A > 10) 73 | { 74 | msgBox.Draw(); 75 | msgBox.Items[0].Draw(); 76 | msgBox.Color = Color.FromArgb(msgBox.Color.A - 5, msgBox.Color.R, msgBox.Color.G, msgBox.Color.B); 77 | msgBox.Items[0].Color = Color.FromArgb(msgBox.Color.A - 5, msgBox.Color.R, msgBox.Color.G, msgBox.Color.B); 78 | } 79 | else 80 | { 81 | msgBox = null; 82 | fadingMsg = false; 83 | } 84 | } 85 | 86 | else if (msgTimer.Enabled) 87 | { 88 | if (Game.GameTime > msgTimer.Waiter) 89 | { 90 | msgTimer.Enabled = false; 91 | fadingMsg = true; 92 | } 93 | 94 | else 95 | { 96 | msgBox = new UIContainer(new Point(1100, 0), new Size(150, 34), Color.FromArgb(140, 0, 0, 0)); 97 | msgBox.Items.Add(new UIText(msgText, new Point(1121, 2), msgScale, Color.White)); 98 | msgBox.Draw(); 99 | msgBox.Items[0].Draw(); 100 | } 101 | } 102 | 103 | splineCam.Update(); 104 | selector.Update(); 105 | 106 | if (!activePool.IsAnyMenuOpen()) 107 | { 108 | if (selector.MainCamera.IsActive) 109 | { 110 | if (Game.IsControlJustPressed(0, GTA.Control.SelectNextWeapon)) 111 | { 112 | nodeDuration -= 100; 113 | msgText = string.Format("Duration: {0}", nodeDuration); 114 | msgScale = 0.4f; 115 | msgTimer.Start(); 116 | } 117 | 118 | else if (Game.IsControlJustPressed(0, GTA.Control.SelectPrevWeapon)) 119 | { 120 | nodeDuration += 100; 121 | msgText = string.Format("Duration: {0}", nodeDuration); 122 | msgScale = 0.4f; 123 | msgTimer.Start(); 124 | } 125 | 126 | else if (Game.IsControlJustPressed(0, GTA.Control.ScriptRDown)) 127 | { 128 | splineCam.AddNode(selector.MainCamera.Position, selector.MainCamera.Rotation, nodeDuration); 129 | msgText = string.Format("~e~New node: {0}", selector.MainCamera.Position); 130 | msgScale = 0.3f; 131 | msgTimer.Start(); 132 | } 133 | 134 | else if (Game.IsControlJustPressed(0, GTA.Control.ScriptRRight)) 135 | { 136 | ExitPointSelector(); 137 | } 138 | } 139 | } 140 | activePool.ProcessMenus(); 141 | } 142 | 143 | private void KeyIsUp(object sender, KeyEventArgs e) 144 | { 145 | if (e.KeyCode == Keys.T) 146 | ToggleMenu(); 147 | } 148 | 149 | private void ToggleMenu() 150 | { 151 | var menus = new List { mainMenu }; 152 | if (menus.Find(item => item.Visible) != null) 153 | menus.ForEach(item => { if (item.Visible) item.Visible = false; }); 154 | else 155 | mainMenu.Visible = !mainMenu.Visible; 156 | } 157 | 158 | private void OnListChanged(UIMenu sender, UIMenuListItem selectedItem, int index) 159 | { 160 | if (sender != cameraOptionsMenu) return; 161 | 162 | if (selectedItem == sender.MenuItems[0]) 163 | { 164 | //avoid dividing by zero 165 | var speed = selectedItem.Index; 166 | speed = speed > 0 ? speed : 1; 167 | splineCam.Speed = speed; 168 | } 169 | else if (selectedItem == sender.MenuItems[1]) 170 | { 171 | //avoid dividing by zero 172 | var fov = selectedItem.Index; 173 | fov = fov > 0 ? fov : 1; 174 | splineCam.MainCamera.FieldOfView = fov; 175 | } 176 | } 177 | 178 | private void OnCheckboxChanged(UIMenu sender, UIMenuCheckboxItem selectedItem, bool isChecked) 179 | { 180 | if (sender != cameraOptionsMenu) return; 181 | if (selectedItem == sender.MenuItems[2]) 182 | splineCam.UsePlayerView = isChecked; 183 | else if (selectedItem == sender.MenuItems[3]) 184 | splineCam.InterpToPlayer = isChecked; 185 | } 186 | 187 | private void EnterPointSelector() 188 | { 189 | if (selector.MainCamera.IsActive || splineCam.MainCamera.IsActive) 190 | { 191 | UI.ShowSubtitle("Camera is Active."); 192 | return; 193 | } 194 | 195 | Game.Player.Character.FreezePosition = true; 196 | selector.EnterCameraView(Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0, 0, 10f))); 197 | ToggleMenu(); 198 | } 199 | 200 | private void ExitPointSelector() 201 | { 202 | selector.ExitCameraView(); 203 | Game.Player.Character.FreezePosition = false; 204 | } 205 | 206 | private void StartInterpolatingCam() 207 | { 208 | if (splineCam.Nodes.Count < 2) 209 | { 210 | UI.ShowSubtitle("Setup camera nodes first!"); 211 | return; 212 | } 213 | 214 | splineCam.EnterCameraView(Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0, 0, 10f))); 215 | } 216 | 217 | private void StopInterpolatingCam() 218 | { 219 | if (splineCam.MainCamera.IsActive) 220 | { 221 | 222 | splineCam.ExitCameraView(); 223 | } 224 | 225 | else 226 | UI.ShowSubtitle("Camera not active."); 227 | } 228 | 229 | private void ResetAllCameras() 230 | { 231 | if (splineCam != null) 232 | { 233 | if (splineCam.MainCamera.IsActive) 234 | splineCam.ExitCameraView(); 235 | if (splineCam.Nodes.Count > 0) 236 | splineCam.Nodes.Clear(); 237 | } 238 | if (selector != null && selector.MainCamera.IsActive) 239 | selector.ExitCameraView(); 240 | 241 | World.RenderingCamera = null; 242 | Function.Call(Hash.DESTROY_ALL_CAMS, false); 243 | splineCam = new SplineCamera(); 244 | selector = new PositionSelector(Vector3.Zero, Vector3.Zero); 245 | } 246 | 247 | protected override void Dispose(bool A_0) 248 | { 249 | if (splineCam != null && splineCam.UsePlayerView) 250 | { 251 | Game.Player.Character.IsInvincible = false; 252 | Game.Player.Character.IsVisible = true; 253 | } 254 | 255 | World.RenderingCamera = null; 256 | Function.Call(Hash.CLEAR_FOCUS); 257 | 258 | base.Dispose(A_0); 259 | } 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/PositionSelector.cs: -------------------------------------------------------------------------------- 1 | using GTA; 2 | using GTA.Math; 3 | using GTA.Native; 4 | using System.Drawing; 5 | using GTAV_ScriptCamTool.Input; 6 | 7 | namespace GTAV_ScriptCamTool 8 | { 9 | public class PositionSelector 10 | { 11 | private Timer _renderSceneTimer; 12 | private float _currentLerpTime; 13 | private Scaleform _instructionalButtons; 14 | private Vector3 _previousPos; 15 | private Camera _mainCamera; 16 | 17 | private readonly float LerpTime = 0.5f; 18 | private readonly float RotationSpeed = 0.7f; 19 | 20 | public readonly GamepadHandler GamepadHandler; 21 | 22 | public Camera MainCamera { get { return _mainCamera; } } 23 | 24 | public PositionSelector(Vector3 position, Vector3 rotation) 25 | { 26 | this.GamepadHandler = new GamepadHandler(); 27 | this.GamepadHandler.LeftStickChanged += LeftStickChanged; 28 | this.GamepadHandler.RightStickChanged += RightStickChanged; 29 | this.GamepadHandler.LeftStickPressed += LeftStickPressed; 30 | this._instructionalButtons = new Scaleform(Function.Call(Hash.REQUEST_SCALEFORM_MOVIE, "instructional_buttons")); 31 | this._mainCamera = World.CreateCamera(position, rotation, 50f); 32 | this._mainCamera.IsActive = false; 33 | this._renderSceneTimer = new Timer(5000); 34 | this._renderSceneTimer.Start(); 35 | } 36 | 37 | private void LeftStickChanged(object sender, AnalogStickChangedEventArgs e) 38 | { 39 | if (e.X > sbyte.MaxValue) 40 | _previousPos -= Utils.RotationToDirection(MainCamera.Rotation).RightVector(new Vector3(0, 0, 1f)) * 41 | (Function.Call(Hash.GET_CONTROL_NORMAL, 2, 218) * -3f); 42 | if (e.X < sbyte.MaxValue) 43 | _previousPos += Utils.RotationToDirection(MainCamera.Rotation).LeftVector(new Vector3(0, 0, 1f)) * 44 | (Function.Call(Hash.GET_CONTROL_NORMAL, 2, 218) * -3f); 45 | if (e.Y != sbyte.MaxValue) 46 | _previousPos += Utils.RotationToDirection(MainCamera.Rotation) * 47 | (Function.Call(Hash.GET_CONTROL_NORMAL, 0, 8) * -5f); 48 | 49 | _currentLerpTime += 0.02f; 50 | 51 | if (_currentLerpTime > LerpTime) 52 | _currentLerpTime = LerpTime; 53 | 54 | float amount = _currentLerpTime / LerpTime; 55 | 56 | _mainCamera.Position = Vector3.Lerp(MainCamera.Position, _previousPos, amount); 57 | } 58 | 59 | private void RightStickChanged(object sender, AnalogStickChangedEventArgs e) 60 | { 61 | MainCamera.Rotation += new Vector3(Function.Call(Hash.GET_CONTROL_NORMAL, 2, 221) * -4f, 0, 62 | Function.Call(Hash.GET_CONTROL_NORMAL, 2, 220) * -5f) * RotationSpeed; 63 | } 64 | 65 | private void LeftStickPressed(object sender, ButtonPressedEventArgs e) 66 | { 67 | _previousPos += Utils.RotationToDirection(MainCamera.Rotation) * 68 | (Function.Call(Hash.GET_CONTROL_NORMAL, 2, 230) * -5f); 69 | } 70 | 71 | public void EnterCameraView(Vector3 position) 72 | { 73 | Function.Call(Hash.DO_SCREEN_FADE_OUT, 1200); 74 | Script.Wait(1100); 75 | MainCamera.Position = position; 76 | MainCamera.IsActive = true; 77 | World.RenderingCamera = MainCamera; 78 | Script.Wait(100); 79 | Function.Call(Hash.DO_SCREEN_FADE_IN, 800); 80 | } 81 | 82 | public void ExitCameraView() 83 | { 84 | Function.Call(Hash.DO_SCREEN_FADE_OUT, 1200); 85 | Script.Wait(1100); 86 | MainCamera.IsActive = false; 87 | World.RenderingCamera = null; 88 | Script.Wait(100); 89 | Function.Call(Hash.CLEAR_FOCUS); 90 | Function.Call(Hash.DO_SCREEN_FADE_IN, 800); 91 | } 92 | 93 | public void Update() 94 | { 95 | if (MainCamera.IsActive) 96 | { 97 | if (_renderSceneTimer.Enabled && Game.GameTime > _renderSceneTimer.Waiter) 98 | { 99 | Function.Call(Hash._0x0923DBF87DFF735E, _mainCamera.Position.X, _mainCamera.Position.Y, _mainCamera.Position.Z); 100 | _renderSceneTimer.Reset(); 101 | } 102 | 103 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.VehicleCinCam, true); 104 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MultiplayerInfo, true); 105 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MeleeAttackLight, true); 106 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MeleeAttackAlternate, true); 107 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MeleeAttack2, true); 108 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.Phone, true); 109 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.VehicleLookBehind, true); 110 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.FrontendRs, true); 111 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.FrontendLs, true); 112 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.FrontendX, true); 113 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ReplayShowhotkey, true); 114 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ReplayTools, true); 115 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ScriptPadDown, true); 116 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.FrontendDown, true); 117 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.PhoneDown, true); 118 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.HUDSpecial, true); 119 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.SniperZoomOutSecondary, true); 120 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.CharacterWheel, true); 121 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ReplayNewmarker, true); 122 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ReplayStartStopRecording, true); 123 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ReplayStartStopRecordingSecondary, true); 124 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.ReplayPause, true); 125 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MoveUpDown, true); 126 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MoveLeftRight, true); 127 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MoveLeftOnly, true); 128 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MoveRightOnly, true); 129 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MoveUpOnly, true); 130 | Function.Call(Hash.DISABLE_CONTROL_ACTION, 2, (int)Control.MoveDownOnly, true); 131 | 132 | Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME); 133 | Function.Call(Hash.HIDE_HUD_COMPONENT_THIS_FRAME, 18); 134 | 135 | //render local scene 136 | 137 | var lastPos = Vector3.Subtract(_mainCamera.Position, _previousPos); 138 | Function.Call(Hash._SET_FOCUS_AREA, _mainCamera.Position.X, _mainCamera.Position.Y, _mainCamera.Position.Z, lastPos.X, lastPos.Y, lastPos.Z); 139 | 140 | _previousPos = _mainCamera.Position; 141 | 142 | RenderEntityPosition(); 143 | 144 | GamepadHandler.Update(); 145 | RenderIntructionalButtons(); 146 | 147 | if (_currentLerpTime > 0) _currentLerpTime -= 0.01f; 148 | } 149 | } 150 | 151 | private void RenderEntityPosition() 152 | { 153 | var pos = Game.Player.Character.Position + Game.Player.Character.UpVector * 1.8f; 154 | var dir = Vector3.WorldDown; 155 | var rot = new Vector3(90f, 0f, 0f); 156 | var scale3D = new Vector3(2.0f,2.0f, 2.0f); 157 | var color = Color.Yellow; 158 | DrawMarker(20, pos, dir, rot, scale3D, color, true, false, false); 159 | } 160 | 161 | private void DrawMarker(int type, Vector3 position, Vector3 direction, Vector3 rotation, Vector3 scale3D, Color color, bool animate = false, bool faceCam = false, bool rotate = false) 162 | { 163 | Function.Call(Hash.DRAW_MARKER, type, position.X, position.Y, position.Z, direction.X, direction.Y, direction.Z, rotation.X, rotation.Y, rotation.Z, scale3D.X, scale3D.Y, scale3D.Z, color.R, color.G, color.B, color.A, animate, faceCam, 2, rotate, 0, 0, 0); 164 | } 165 | 166 | private void RenderIntructionalButtons() 167 | { 168 | _instructionalButtons.CallFunction("CLEAR_ALL"); 169 | _instructionalButtons.CallFunction("TOGGLE_MOUSE_BUTTONS", false); 170 | string str = Function.Call(Hash._0x0499D7B09FC9B407, 2, 24, 0); 171 | _instructionalButtons.CallFunction("SET_DATA_SLOT", 4, str, "Select Position"); 172 | str = Function.Call(Hash._0x0499D7B09FC9B407, 3, 17, 0); 173 | _instructionalButtons.CallFunction("SET_DATA_SLOT", 3, str, "Increase Duration"); 174 | str = Function.Call(Hash._0x0499D7B09FC9B407, 1, 16, 0); 175 | _instructionalButtons.CallFunction("SET_DATA_SLOT", 2, str, "Decrease Duration"); 176 | str = Function.Call(Hash._0x0499D7B09FC9B407, 2, 25, 0); 177 | _instructionalButtons.CallFunction("SET_DATA_SLOT", 1, str, "Exit"); 178 | string[] args = new string[] { 179 | Function.Call(Hash._0x0499D7B09FC9B407, 2, 32, 0), 180 | Function.Call(Hash._0x0499D7B09FC9B407, 2, 34, 0), 181 | Function.Call(Hash._0x0499D7B09FC9B407, 2, 33, 0), 182 | Function.Call(Hash._0x0499D7B09FC9B407, 2, 35, 0) 183 | }; 184 | _instructionalButtons.CallFunction("SET_DATA_SLOT", 0, args[3], args[2], args[1], args[0], "Move"); 185 | _instructionalButtons.CallFunction("SET_BACKGROUND_COLOUR", 0, 0, 0, 80); 186 | _instructionalButtons.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", 0); 187 | _instructionalButtons.Render2D(); 188 | } 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GTAV_ScriptCamTool")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GTAV_ScriptCamTool")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("756edb52-9d98-4e05-a0aa-2045ae624c5b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.2.2.0")] 36 | [assembly: AssemblyFileVersion("1.2.2.0")] 37 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/SplineCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using GTA; 4 | using GTA.Math; 5 | using GTA.Native; 6 | 7 | namespace GTAV_ScriptCamTool 8 | { 9 | public class SplineCamera 10 | { 11 | private bool _usePlayerView; 12 | private Timer _renderSceneTimer; 13 | private Camera _mainCamera; 14 | private List> _nodes; 15 | private Timer _replayTimer; 16 | private Vector3 _startPos, _previousPos; 17 | public Camera MainCamera { get { return _mainCamera; } } 18 | 19 | public bool InterpToPlayer { get; set; } 20 | 21 | public bool UsePlayerView 22 | { 23 | get 24 | { 25 | return _usePlayerView; 26 | } 27 | set 28 | { 29 | if (value) 30 | { 31 | _startPos = Game.Player.Character.Position; 32 | Game.Player.Character.IsInvincible = true; 33 | Game.Player.Character.IsVisible = false; 34 | } 35 | 36 | else 37 | { 38 | if (_startPos != null) 39 | Game.Player.Character.Position = _startPos; 40 | Game.Player.Character.IsInvincible = false; 41 | Game.Player.Character.IsVisible = true; 42 | } 43 | 44 | this._usePlayerView = value; 45 | } 46 | } 47 | 48 | public int Speed { set { Function.Call(Hash.SET_CAM_SPLINE_DURATION, _mainCamera.Handle, 100 / value * 1000 ); } } 49 | 50 | public List> Nodes { get { return _nodes; } } 51 | 52 | public SplineCamera() 53 | { 54 | this._mainCamera = new Camera(Function.Call(Hash.CREATE_CAM, "DEFAULT_SPLINE_CAMERA", 0)); 55 | this._nodes = new List>(); 56 | this._replayTimer = new Timer(1100); 57 | this._renderSceneTimer = new Timer(5000); 58 | this._renderSceneTimer.Start(); 59 | } 60 | 61 | public void AddNode(Vector3 position, Vector3 rotation, int duration) 62 | { 63 | _nodes.Add(new Tuple(position, rotation)); 64 | Function.Call(Hash.ADD_CAM_SPLINE_NODE, _mainCamera.Handle, position.X, position.Y, position.Z, rotation.X, rotation.Y, rotation.Z, duration, 3, 2); 65 | } 66 | 67 | public void EnterCameraView(Vector3 position) 68 | { 69 | Function.Call(Hash.DO_SCREEN_FADE_OUT, 1200); 70 | Script.Wait(1100); 71 | MainCamera.Position = position; 72 | MainCamera.IsActive = true; 73 | World.RenderingCamera = MainCamera; 74 | Script.Wait(100); 75 | Function.Call(Hash.DO_SCREEN_FADE_IN, 800); 76 | } 77 | 78 | public void ExitCameraView() 79 | { 80 | Function.Call(Hash.DO_SCREEN_FADE_OUT, 1200); 81 | Script.Wait(1100); 82 | MainCamera.IsActive = false; 83 | if (UsePlayerView) 84 | UsePlayerView = false; 85 | World.RenderingCamera = null; 86 | Script.Wait(100); 87 | Function.Call(Hash.CLEAR_FOCUS); 88 | Function.Call(Hash.DO_SCREEN_FADE_IN, 800); 89 | } 90 | 91 | public void Update() 92 | { 93 | if (MainCamera.IsActive) 94 | { 95 | if (_renderSceneTimer.Enabled && Game.GameTime > _renderSceneTimer.Waiter) 96 | { 97 | Function.Call(Hash._0x0923DBF87DFF735E, _mainCamera.Position.X, _mainCamera.Position.Y, _mainCamera.Position.Z); 98 | _renderSceneTimer.Reset(); 99 | } 100 | 101 | Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME); 102 | Function.Call(Hash.HIDE_HUD_COMPONENT_THIS_FRAME, 18); 103 | 104 | _previousPos = _mainCamera.Position; 105 | 106 | if (_replayTimer.Enabled && Game.GameTime > _replayTimer.Waiter) 107 | { 108 | Function.Call(Hash.SET_CAM_SPLINE_PHASE, _mainCamera.Handle, 0f); 109 | _replayTimer.Enabled = false; 110 | } 111 | 112 | if (!_mainCamera.IsInterpolating) 113 | { 114 | if (Function.Call(Hash.GET_CAM_SPLINE_PHASE, _mainCamera.Handle) > 0.001f) 115 | { 116 | if (InterpToPlayer) 117 | { 118 | Function.Call(Hash.RENDER_SCRIPT_CAMS, 0, 1, 3000, 1, 1, 1); 119 | 120 | Function.Call(Hash.CLEAR_FOCUS); 121 | MainCamera.IsActive = false; 122 | } 123 | } 124 | 125 | if (!_replayTimer.Enabled) 126 | _replayTimer.Start(); 127 | } 128 | 129 | else 130 | { 131 | if (UsePlayerView) 132 | Game.Player.Character.Position = MainCamera.Position; 133 | 134 | else 135 | { 136 | //render local scene 137 | var lastPos = Vector3.Subtract(_mainCamera.Position, _previousPos); 138 | Function.Call(Hash._SET_FOCUS_AREA, _mainCamera.Position.X, _mainCamera.Position.Y, _mainCamera.Position.Z, lastPos.X, lastPos.Y, lastPos.Z); 139 | } 140 | } 141 | } 142 | } 143 | } 144 | } 145 | 146 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Timer.cs: -------------------------------------------------------------------------------- 1 | using GTA; 2 | 3 | public class Timer 4 | { 5 | #region Public Variables 6 | private bool enabled; 7 | public bool Enabled 8 | { 9 | get { return enabled; } 10 | set { enabled = value; } 11 | } 12 | 13 | private int interval; 14 | public int Interval 15 | { 16 | get { return interval; } 17 | set { this.interval = value; } 18 | } 19 | #endregion 20 | 21 | private int waiter; 22 | public int Waiter 23 | { 24 | get { return waiter; } 25 | set { this.waiter = value; } 26 | } 27 | 28 | public Timer(int interval) 29 | { 30 | this.interval = interval; 31 | this.waiter = 0; 32 | this.enabled = false; 33 | } 34 | 35 | public Timer() 36 | { 37 | this.interval = 0; 38 | this.waiter = 0; 39 | this.enabled = false; 40 | } 41 | 42 | public void Start() 43 | { 44 | this.waiter = Game.GameTime + interval; 45 | this.enabled = true; 46 | } 47 | 48 | public void Reset() 49 | { 50 | this.waiter = Game.GameTime + interval; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /GTAV_ScriptCamTool/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using GTA; 3 | using GTA.Math; 4 | using System.Drawing; 5 | namespace GTAV_ScriptCamTool 6 | { 7 | public static class Utils 8 | { 9 | public static double ToRadians(this float val) 10 | { 11 | return (Math.PI / 180) * val; 12 | } 13 | 14 | public static Quaternion GetLookRotation(Vector3 lookPosition, Vector3 up) 15 | { 16 | OrthoNormalize(ref lookPosition, ref up); 17 | Vector3 right = Vector3.Cross(up, lookPosition); 18 | var w = Math.Sqrt(1.0f + right.X + up.Y + lookPosition.Z) * 0.5f; 19 | var val = 1.0f / (4.0f * w); 20 | var x = (up.Z - lookPosition.Y) * val; 21 | var y = (lookPosition.X - right.Z) * val; 22 | var z = (right.Y - up.X) * val; 23 | return new Quaternion((float)x, (float)y, (float)z, (float)w); 24 | } 25 | 26 | public static Vector3 RotationToDirection(Vector3 rotation) 27 | { 28 | double retZ = rotation.Z * 0.01745329f; 29 | double retX = rotation.X * 0.01745329f; 30 | double absX = Math.Abs(Math.Cos(retX)); 31 | return new Vector3((float)-(Math.Sin(retZ) * absX), (float)(Math.Cos(retZ) * absX), (float)Math.Sin(retX)); 32 | } 33 | 34 | public static Vector3 RightVector(this Vector3 position, Vector3 up) 35 | { 36 | position.Normalize(); 37 | up.Normalize(); 38 | return Vector3.Cross(position, up); 39 | } 40 | 41 | public static Vector3 LeftVector(this Vector3 position, Vector3 up) 42 | { 43 | position.Normalize(); 44 | up.Normalize(); 45 | return -(Vector3.Cross(position, up)); 46 | } 47 | 48 | public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent) 49 | { 50 | Vector3.Normalize(normal); 51 | var vec = Vector3.Multiply(normal, Vector3.Dot(tangent, normal)); 52 | tangent = Vector3.Subtract(tangent, vec); 53 | tangent.Normalize(); 54 | } 55 | 56 | 57 | public static SizeF GetScreenResolutionMantainRatio() 58 | { 59 | int screenw = Game.ScreenResolution.Width; 60 | int screenh = Game.ScreenResolution.Height; 61 | const float height = 1080f; 62 | float ratio = (float)screenw / screenh; 63 | var width = height * ratio; 64 | 65 | return new SizeF(width, height); 66 | } 67 | } 68 | } 69 | --------------------------------------------------------------------------------