├── .gitignore ├── .gitmodules ├── L4D2VR ├── SteamVRActionManifest │ ├── action_manifest.json │ ├── bindings_knuckles.json │ ├── bindings_oculus_touch.json │ └── bindings_vive_cosmos_controller.json ├── config.txt ├── dllmain.cpp ├── game.cpp ├── game.h ├── hooks.cpp ├── hooks.h ├── l4d2vr.vcxproj ├── l4d2vr.vcxproj.filters ├── l4d2vr_capsule_main.png ├── l4d2vr_portrait_main.png ├── manifest.vrmanifest ├── offsets.h ├── sdk │ ├── LICENSE.txt │ ├── checksum_crc.cpp │ ├── checksum_crc.h │ ├── material.h │ ├── sdk.h │ ├── sdk_server.h │ ├── texture.h │ ├── trace.h │ ├── usercmd.h │ └── vector.h ├── sigscanner.h ├── vr.cpp └── vr.h ├── README.md ├── l4d2vr.sln └── thirdparty ├── minhook ├── include │ └── MinHook.h └── lib │ ├── Debug │ └── libMinHook.x86.lib │ └── Release │ └── libMinHook.x86.lib └── openvr ├── bin └── win32 │ └── openvr_api.dll ├── include ├── openvr.h ├── openvr_api.cs ├── openvr_api.json ├── openvr_capi.h └── openvr_driver.h └── lib └── win32 └── openvr_api.lib /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebugPublic/ 21 | [Rr]eleases/ 22 | x64/ 23 | x86/ 24 | [Aa][Rr][Mm]/ 25 | [Aa][Rr][Mm]64/ 26 | bld/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | [Ll]ogs/ 30 | 31 | # Visual Studio 2015/2017 cache/options directory 32 | .vs/ 33 | # Uncomment if you have tasks that create the project's static files in wwwroot 34 | #wwwroot/ 35 | 36 | # Visual Studio 2017 auto generated files 37 | Generated\ Files/ 38 | 39 | # MSTest test Results 40 | [Tt]est[Rr]esult*/ 41 | [Bb]uild[Ll]og.* 42 | 43 | # NUnit 44 | *.VisualState.xml 45 | TestResult.xml 46 | nunit-*.xml 47 | 48 | # Build Results of an ATL Project 49 | [Dd]ebugPS/ 50 | [Rr]eleasePS/ 51 | dlldata.c 52 | 53 | # Benchmark Results 54 | BenchmarkDotNet.Artifacts/ 55 | 56 | # .NET Core 57 | project.lock.json 58 | project.fragment.lock.json 59 | artifacts/ 60 | 61 | # ASP.NET Scaffolding 62 | ScaffoldingReadMe.txt 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.tlog 90 | *.vspscc 91 | *.vssscc 92 | .builds 93 | *.pidb 94 | *.svclog 95 | *.scc 96 | 97 | # Chutzpah Test files 98 | _Chutzpah* 99 | 100 | # Visual C++ cache files 101 | ipch/ 102 | *.aps 103 | *.ncb 104 | *.opendb 105 | *.opensdf 106 | *.sdf 107 | *.cachefile 108 | *.VC.db 109 | *.VC.VC.opendb 110 | 111 | # Visual Studio profiler 112 | *.psess 113 | *.vsp 114 | *.vspx 115 | *.sap 116 | 117 | # Visual Studio Trace Files 118 | *.e2e 119 | 120 | # TFS 2012 Local Workspace 121 | $tf/ 122 | 123 | # Guidance Automation Toolkit 124 | *.gpState 125 | 126 | # ReSharper is a .NET coding add-in 127 | _ReSharper*/ 128 | *.[Rr]e[Ss]harper 129 | *.DotSettings.user 130 | 131 | # TeamCity is a build add-in 132 | _TeamCity* 133 | 134 | # DotCover is a Code Coverage Tool 135 | *.dotCover 136 | 137 | # AxoCover is a Code Coverage Tool 138 | .axoCover/* 139 | !.axoCover/settings.json 140 | 141 | # Coverlet is a free, cross platform Code Coverage Tool 142 | coverage*.json 143 | coverage*.xml 144 | coverage*.info 145 | 146 | # Visual Studio code coverage results 147 | *.coverage 148 | *.coveragexml 149 | 150 | # NCrunch 151 | _NCrunch_* 152 | .*crunch*.local.xml 153 | nCrunchTemp_* 154 | 155 | # MightyMoose 156 | *.mm.* 157 | AutoTest.Net/ 158 | 159 | # Web workbench (sass) 160 | .sass-cache/ 161 | 162 | # Installshield output folder 163 | [Ee]xpress/ 164 | 165 | # DocProject is a documentation generator add-in 166 | DocProject/buildhelp/ 167 | DocProject/Help/*.HxT 168 | DocProject/Help/*.HxC 169 | DocProject/Help/*.hhc 170 | DocProject/Help/*.hhk 171 | DocProject/Help/*.hhp 172 | DocProject/Help/Html2 173 | DocProject/Help/html 174 | 175 | # Click-Once directory 176 | publish/ 177 | 178 | # Publish Web Output 179 | *.[Pp]ublish.xml 180 | *.azurePubxml 181 | # Note: Comment the next line if you want to checkin your web deploy settings, 182 | # but database connection strings (with potential passwords) will be unencrypted 183 | *.pubxml 184 | *.publishproj 185 | 186 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 187 | # checkin your Azure Web App publish settings, but sensitive information contained 188 | # in these scripts will be unencrypted 189 | PublishScripts/ 190 | 191 | # NuGet Packages 192 | *.nupkg 193 | # NuGet Symbol Packages 194 | *.snupkg 195 | # The packages folder can be ignored because of Package Restore 196 | **/[Pp]ackages/* 197 | # except build/, which is used as an MSBuild target. 198 | !**/[Pp]ackages/build/ 199 | # Uncomment if necessary however generally it will be regenerated when needed 200 | #!**/[Pp]ackages/repositories.config 201 | # NuGet v3's project.json files produces more ignorable files 202 | *.nuget.props 203 | *.nuget.targets 204 | 205 | # Microsoft Azure Build Output 206 | csx/ 207 | *.build.csdef 208 | 209 | # Microsoft Azure Emulator 210 | ecf/ 211 | rcf/ 212 | 213 | # Windows Store app package directories and files 214 | AppPackages/ 215 | BundleArtifacts/ 216 | Package.StoreAssociation.xml 217 | _pkginfo.txt 218 | *.appx 219 | *.appxbundle 220 | *.appxupload 221 | 222 | # Visual Studio cache files 223 | # files ending in .cache can be ignored 224 | *.[Cc]ache 225 | # but keep track of directories ending in .cache 226 | !?*.[Cc]ache/ 227 | 228 | # Others 229 | ClientBin/ 230 | ~$* 231 | *~ 232 | *.dbmdl 233 | *.dbproj.schemaview 234 | *.jfm 235 | *.pfx 236 | *.publishsettings 237 | orleans.codegen.cs 238 | 239 | # Including strong name files can present a security risk 240 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 241 | #*.snk 242 | 243 | # Since there are multiple workflows, uncomment next line to ignore bower_components 244 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 245 | #bower_components/ 246 | 247 | # RIA/Silverlight projects 248 | Generated_Code/ 249 | 250 | # Backup & report files from converting an old project file 251 | # to a newer Visual Studio version. Backup files are not needed, 252 | # because we have git ;-) 253 | _UpgradeReport_Files/ 254 | Backup*/ 255 | UpgradeLog*.XML 256 | UpgradeLog*.htm 257 | ServiceFabricBackup/ 258 | *.rptproj.bak 259 | 260 | # SQL Server files 261 | *.mdf 262 | *.ldf 263 | *.ndf 264 | 265 | # Business Intelligence projects 266 | *.rdl.data 267 | *.bim.layout 268 | *.bim_*.settings 269 | *.rptproj.rsuser 270 | *- [Bb]ackup.rdl 271 | *- [Bb]ackup ([0-9]).rdl 272 | *- [Bb]ackup ([0-9][0-9]).rdl 273 | 274 | # Microsoft Fakes 275 | FakesAssemblies/ 276 | 277 | # GhostDoc plugin setting file 278 | *.GhostDoc.xml 279 | 280 | # Node.js Tools for Visual Studio 281 | .ntvs_analysis.dat 282 | node_modules/ 283 | 284 | # Visual Studio 6 build log 285 | *.plg 286 | 287 | # Visual Studio 6 workspace options file 288 | *.opt 289 | 290 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 291 | *.vbw 292 | 293 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 294 | *.vbp 295 | 296 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 297 | *.dsw 298 | *.dsp 299 | 300 | # Visual Studio 6 technical files 301 | *.ncb 302 | *.aps 303 | 304 | # Visual Studio LightSwitch build output 305 | **/*.HTMLClient/GeneratedArtifacts 306 | **/*.DesktopClient/GeneratedArtifacts 307 | **/*.DesktopClient/ModelManifest.xml 308 | **/*.Server/GeneratedArtifacts 309 | **/*.Server/ModelManifest.xml 310 | _Pvt_Extensions 311 | 312 | # Paket dependency manager 313 | .paket/paket.exe 314 | paket-files/ 315 | 316 | # FAKE - F# Make 317 | .fake/ 318 | 319 | # CodeRush personal settings 320 | .cr/personal 321 | 322 | # Python Tools for Visual Studio (PTVS) 323 | __pycache__/ 324 | *.pyc 325 | 326 | # Cake - Uncomment if you are using it 327 | # tools/** 328 | # !tools/packages.config 329 | 330 | # Tabs Studio 331 | *.tss 332 | 333 | # Telerik's JustMock configuration file 334 | *.jmconfig 335 | 336 | # BizTalk build output 337 | *.btp.cs 338 | *.btm.cs 339 | *.odx.cs 340 | *.xsd.cs 341 | 342 | # OpenCover UI analysis results 343 | OpenCover/ 344 | 345 | # Azure Stream Analytics local run output 346 | ASALocalRun/ 347 | 348 | # MSBuild Binary and Structured Log 349 | *.binlog 350 | 351 | # NVidia Nsight GPU debugger configuration file 352 | *.nvuser 353 | 354 | # MFractors (Xamarin productivity tool) working folder 355 | .mfractor/ 356 | 357 | # Local History for Visual Studio 358 | .localhistory/ 359 | 360 | # Visual Studio History (VSHistory) files 361 | .vshistory/ 362 | 363 | # BeatPulse healthcheck temp database 364 | healthchecksdb 365 | 366 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 367 | MigrationBackup/ 368 | 369 | # Ionide (cross platform F# VS Code tools) working folder 370 | .ionide/ 371 | 372 | # Fody - auto-generated XML schema 373 | FodyWeavers.xsd 374 | 375 | # VS Code files for those working on multiple tools 376 | .vscode/* 377 | !.vscode/settings.json 378 | !.vscode/tasks.json 379 | !.vscode/launch.json 380 | !.vscode/extensions.json 381 | *.code-workspace 382 | 383 | # Local History for Visual Studio Code 384 | .history/ 385 | 386 | # Windows Installer files from build outputs 387 | *.cab 388 | *.msi 389 | *.msix 390 | *.msm 391 | *.msp 392 | 393 | # JetBrains Rider 394 | *.sln.iml 395 | 396 | /Release 397 | /Debug 398 | /L4D2VR/Debug 399 | /L4D2VR/Release -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dxvk"] 2 | path = dxvk 3 | url = https://github.com/sd805/dxvk.git 4 | branch = dxvk-async -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/action_manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "default_bindings": [ 3 | { 4 | "controller_type": "oculus_touch", 5 | "binding_url": "bindings_oculus_touch.json" 6 | }, 7 | { 8 | "controller_type": "knuckles", 9 | "binding_url": "bindings_knuckles.json" 10 | }, 11 | { 12 | "controller_type": "vive_cosmos_controller", 13 | "binding_url": "bindings_vive_cosmos_controller.json" 14 | } 15 | ], 16 | 17 | "actions": [ 18 | { 19 | "name": "/actions/base/in/pose_lefthand", 20 | "type": "pose" 21 | }, 22 | { 23 | "name": "/actions/base/in/pose_righthand", 24 | "type": "pose" 25 | }, 26 | { 27 | "name": "/actions/base/out/vibration_left", 28 | "type": "vibration" 29 | }, 30 | { 31 | "name": "/actions/base/out/vibration_right", 32 | "type": "vibration" 33 | }, 34 | { 35 | "name" : "/actions/base/in/skeleton_lefthand", 36 | "skeleton" : "/skeleton/hand/left", 37 | "type" : "skeleton" 38 | }, 39 | { 40 | "name" : "/actions/base/in/skeleton_righthand", 41 | "skeleton" : "/skeleton/hand/right", 42 | "type" : "skeleton" 43 | }, 44 | { 45 | "name": "/actions/main/in/PrimaryAttack", 46 | "type": "boolean" 47 | }, 48 | { 49 | "name": "/actions/main/in/SecondaryAttack", 50 | "type": "boolean" 51 | }, 52 | { 53 | "name": "/actions/main/in/Jump", 54 | "type": "boolean" 55 | }, 56 | { 57 | "name": "/actions/main/in/Walk", 58 | "type": "vector2" 59 | }, 60 | { 61 | "name": "/actions/main/in/Turn", 62 | "type": "vector2" 63 | }, 64 | { 65 | "name": "/actions/main/in/Reload", 66 | "type": "boolean" 67 | }, 68 | { 69 | "name": "/actions/main/in/Use", 70 | "type": "boolean" 71 | }, 72 | { 73 | "name": "/actions/main/in/NextItem", 74 | "type": "boolean" 75 | }, 76 | { 77 | "name": "/actions/main/in/PrevItem", 78 | "type": "boolean" 79 | }, 80 | { 81 | "name": "/actions/main/in/ResetPosition", 82 | "type": "boolean" 83 | }, 84 | { 85 | "name": "/actions/main/in/Crouch", 86 | "type": "boolean" 87 | }, 88 | { 89 | "name": "/actions/main/in/Flashlight", 90 | "type": "boolean" 91 | }, 92 | { 93 | "name": "/actions/main/in/ActivateVR", 94 | "type": "boolean" 95 | }, 96 | { 97 | "name": "/actions/main/in/MenuSelect", 98 | "type": "boolean" 99 | }, 100 | { 101 | "name": "/actions/main/in/MenuBack", 102 | "type": "boolean" 103 | }, 104 | { 105 | "name": "/actions/main/in/MenuUp", 106 | "type": "boolean" 107 | }, 108 | { 109 | "name": "/actions/main/in/MenuDown", 110 | "type": "boolean" 111 | }, 112 | { 113 | "name": "/actions/main/in/MenuLeft", 114 | "type": "boolean" 115 | }, 116 | { 117 | "name": "/actions/main/in/MenuRight", 118 | "type": "boolean" 119 | }, 120 | { 121 | "name": "/actions/main/in/Spray", 122 | "type": "boolean", 123 | "requirement": "optional" 124 | }, 125 | { 126 | "name": "/actions/main/in/Scoreboard", 127 | "type": "boolean" 128 | }, 129 | { 130 | "name": "/actions/main/in/ShowHUD", 131 | "type": "boolean", 132 | "requirement": "optional" 133 | }, 134 | { 135 | "name": "/actions/main/in/Pause", 136 | "type": "boolean" 137 | } 138 | ], 139 | 140 | "action_sets": [ 141 | { 142 | "name": "/actions/main", 143 | "usage": "leftright" 144 | }, 145 | { 146 | "name": "/actions/base", 147 | "usage": "hidden" 148 | } 149 | ], 150 | 151 | "localization" : [ 152 | { 153 | "language_tag": "en_us", 154 | "/actions/main" : "Main", 155 | "/actions/main/in/PrimaryAttack" : "Primary Attack", 156 | "/actions/main/in/SecondaryAttack" : "Secondary Attack", 157 | "/actions/main/in/Jump" : "Jump", 158 | "/actions/main/in/Walk" : "Walk", 159 | "/actions/main/in/Turn" : "Turn", 160 | "/actions/main/in/Reload" : "Reload", 161 | "/actions/main/in/Use" : "Use", 162 | "/actions/main/in/NextItem" : "Next Item", 163 | "/actions/main/in/PrevItem" : "Previous Item", 164 | "/actions/main/in/ResetPosition" : "Reset Position", 165 | "/actions/main/in/Crouch" : "Crouch", 166 | "/actions/main/in/Flashlight" : "Flashlight", 167 | "/actions/main/in/ActivateVR" : "Activate VR", 168 | "/actions/main/in/MenuSelect" : "Menu Select", 169 | "/actions/main/in/MenuBack" : "Menu Back", 170 | "/actions/main/in/MenuUp" : "Menu Up", 171 | "/actions/main/in/MenuDown" : "Menu Down", 172 | "/actions/main/in/MenuLeft" : "Menu Left", 173 | "/actions/main/in/MenuRight" : "Menu Right", 174 | "/actions/main/in/Spray" : "Spray", 175 | "/actions/main/in/Scoreboard" : "Show Scoreboard", 176 | "/actions/main/in/ShowHUD" : "Show HUD", 177 | "/actions/main/in/Pause" : "Pause" 178 | } 179 | ] 180 | } 181 | -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/bindings_knuckles.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "bindings" : { 5 | "/actions/base" : { 6 | "chords" : [], 7 | "haptics" : [ 8 | { 9 | "output" : "/actions/base/out/vibration_left", 10 | "path" : "/user/hand/left/output/haptic" 11 | }, 12 | { 13 | "output" : "/actions/base/out/vibration_right", 14 | "path" : "/user/hand/right/output/haptic" 15 | } 16 | ], 17 | "poses" : [ 18 | { 19 | "output" : "/actions/base/in/pose_lefthand", 20 | "path" : "/user/hand/left/pose/raw" 21 | }, 22 | { 23 | "output" : "/actions/base/in/pose_righthand", 24 | "path" : "/user/hand/right/pose/raw" 25 | } 26 | ], 27 | "skeleton" : [ 28 | { 29 | "output" : "/actions/base/in/skeleton_lefthand", 30 | "path" : "/user/hand/left/input/skeleton/left" 31 | }, 32 | { 33 | "output" : "/actions/base/in/skeleton_righthand", 34 | "path" : "/user/hand/right/input/skeleton/right" 35 | } 36 | ], 37 | "sources" : [] 38 | }, 39 | "/actions/main" : { 40 | "sources" : [ 41 | { 42 | "inputs" : { 43 | "click" : { 44 | "output" : "/actions/main/in/ResetPosition" 45 | }, 46 | "position" : { 47 | "output" : "/actions/main/in/Walk" 48 | } 49 | }, 50 | "mode" : "joystick", 51 | "parameters" : { 52 | "deadzone_pct" : "10" 53 | }, 54 | "path" : "/user/hand/left/input/thumbstick" 55 | }, 56 | { 57 | "inputs" : { 58 | "click" : { 59 | "output" : "/actions/main/in/Flashlight" 60 | }, 61 | "position" : { 62 | "output" : "/actions/main/in/Turn" 63 | } 64 | }, 65 | "mode" : "joystick", 66 | "parameters" : { 67 | "deadzone_pct" : "10" 68 | }, 69 | "path" : "/user/hand/right/input/thumbstick" 70 | }, 71 | { 72 | "inputs" : { 73 | "click" : { 74 | "output" : "/actions/main/in/Reload" 75 | } 76 | }, 77 | "mode" : "button", 78 | "parameters" : { 79 | "force_input" : "force", 80 | "click_activate_threshold": "0.45", 81 | "click_deactivate_threshold": "0.4" 82 | }, 83 | "path" : "/user/hand/left/input/grip" 84 | }, 85 | { 86 | "inputs" : { 87 | "click" : { 88 | "output" : "/actions/main/in/PrimaryAttack" 89 | } 90 | }, 91 | "mode" : "button", 92 | "path" : "/user/hand/right/input/trigger" 93 | }, 94 | { 95 | "inputs" : { 96 | "east" : { 97 | "output" : "/actions/main/in/boolean_turnright" 98 | }, 99 | "north" : { 100 | "output" : "/actions/main/in/PrevItem" 101 | }, 102 | "south" : { 103 | "output" : "/actions/main/in/NextItem" 104 | }, 105 | "west" : { 106 | "output" : "/actions/main/in/boolean_turnleft" 107 | } 108 | }, 109 | "mode" : "dpad", 110 | "parameters" : { 111 | "deadzone_pct" : "70", 112 | "overlap_pct" : "0", 113 | "sub_mode" : "touch" 114 | }, 115 | "path" : "/user/hand/right/input/thumbstick" 116 | }, 117 | { 118 | "inputs" : { 119 | "click" : { 120 | "output" : "/actions/main/in/Use" 121 | } 122 | }, 123 | "mode" : "button", 124 | "path" : "/user/hand/right/input/b" 125 | }, 126 | { 127 | "inputs" : { 128 | "click" : { 129 | "output" : "/actions/main/in/ActivateVR" 130 | } 131 | }, 132 | "mode" : "button", 133 | "path" : "/user/hand/right/input/a" 134 | }, 135 | { 136 | "inputs" : { 137 | "click" : { 138 | "output" : "/actions/main/in/Jump" 139 | } 140 | }, 141 | "mode" : "button", 142 | "path" : "/user/hand/right/input/a" 143 | }, 144 | { 145 | "inputs" : { 146 | "click" : { 147 | "output" : "/actions/main/in/MenuSelect" 148 | } 149 | }, 150 | "mode" : "button", 151 | "path" : "/user/hand/right/input/a" 152 | }, 153 | { 154 | "inputs" : { 155 | "click" : { 156 | "output" : "/actions/main/in/MenuBack" 157 | } 158 | }, 159 | "mode" : "button", 160 | "path" : "/user/hand/right/input/b" 161 | }, 162 | { 163 | "inputs" : { 164 | "east" : { 165 | "output" : "/actions/main/in/MenuRight" 166 | }, 167 | "north" : { 168 | "output" : "/actions/main/in/MenuUp" 169 | }, 170 | "south" : { 171 | "output" : "/actions/main/in/MenuDown" 172 | }, 173 | "west" : { 174 | "output" : "/actions/main/in/MenuLeft" 175 | } 176 | }, 177 | "mode" : "dpad", 178 | "parameters" : { 179 | "deadzone_pct" : "70", 180 | "overlap_pct" : "0", 181 | "sub_mode" : "touch" 182 | }, 183 | "path" : "/user/hand/left/input/thumbstick" 184 | }, 185 | { 186 | "inputs" : { 187 | "click" : { 188 | "output" : "/actions/main/in/Scoreboard" 189 | } 190 | }, 191 | "mode" : "button", 192 | "path" : "/user/hand/left/input/a" 193 | }, 194 | { 195 | "inputs" : { 196 | "click" : { 197 | "output" : "/actions/main/in/Pause" 198 | } 199 | }, 200 | "mode" : "button", 201 | "path" : "/user/hand/left/input/b" 202 | }, 203 | { 204 | "inputs" : { 205 | "click" : { 206 | "output" : "/actions/main/in/Crouch" 207 | } 208 | }, 209 | "mode" : "button", 210 | "parameters" : { 211 | "force_input" : "force", 212 | "click_activate_threshold": "0.45", 213 | "click_deactivate_threshold": "0.4" 214 | }, 215 | "path" : "/user/hand/right/input/grip" 216 | }, 217 | { 218 | "inputs" : { 219 | "click" : { 220 | "output" : "/actions/main/in/SecondaryAttack" 221 | } 222 | }, 223 | "mode" : "button", 224 | "path" : "/user/hand/left/input/trigger" 225 | } 226 | ] 227 | } 228 | }, 229 | "category" : "steamvr_input", 230 | "controller_type" : "knuckles", 231 | "description" : "", 232 | "name" : "Default Left 4 Dead 2 VR bindings for Index Controllers", 233 | "options" : {}, 234 | "simulated_actions" : [] 235 | } 236 | 237 | -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/bindings_oculus_touch.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "bindings" : { 5 | "/actions/base" : { 6 | "chords" : [], 7 | "haptics" : [ 8 | { 9 | "output" : "/actions/base/out/vibration_left", 10 | "path" : "/user/hand/left/output/haptic" 11 | }, 12 | { 13 | "output" : "/actions/base/out/vibration_right", 14 | "path" : "/user/hand/right/output/haptic" 15 | } 16 | ], 17 | "poses" : [ 18 | { 19 | "output" : "/actions/base/in/pose_lefthand", 20 | "path" : "/user/hand/left/pose/raw" 21 | }, 22 | { 23 | "output" : "/actions/base/in/pose_righthand", 24 | "path" : "/user/hand/right/pose/raw" 25 | } 26 | ], 27 | "skeleton" : [ 28 | { 29 | "output" : "/actions/base/in/skeleton_lefthand", 30 | "path" : "/user/hand/left/input/skeleton/left" 31 | }, 32 | { 33 | "output" : "/actions/base/in/skeleton_righthand", 34 | "path" : "/user/hand/right/input/skeleton/right" 35 | } 36 | ], 37 | "sources" : [] 38 | }, 39 | "/actions/main" : { 40 | "sources" : [ 41 | { 42 | "inputs" : { 43 | "click" : { 44 | "output" : "/actions/main/in/ResetPosition" 45 | }, 46 | "position" : { 47 | "output" : "/actions/main/in/Walk" 48 | } 49 | }, 50 | "mode" : "joystick", 51 | "parameters" : { 52 | "deadzone_pct" : "10" 53 | }, 54 | "path" : "/user/hand/left/input/joystick" 55 | }, 56 | { 57 | "inputs" : { 58 | "click" : { 59 | "output" : "/actions/main/in/Flashlight" 60 | }, 61 | "position" : { 62 | "output" : "/actions/main/in/Turn" 63 | } 64 | }, 65 | "mode" : "joystick", 66 | "parameters" : { 67 | "deadzone_pct" : "10" 68 | }, 69 | "path" : "/user/hand/right/input/joystick" 70 | }, 71 | { 72 | "inputs" : { 73 | "click" : { 74 | "output" : "/actions/main/in/Reload" 75 | } 76 | }, 77 | "mode" : "button", 78 | "path" : "/user/hand/left/input/grip" 79 | }, 80 | { 81 | "inputs" : { 82 | "click" : { 83 | "output" : "/actions/main/in/PrimaryAttack" 84 | } 85 | }, 86 | "mode" : "button", 87 | "path" : "/user/hand/right/input/trigger" 88 | }, 89 | { 90 | "inputs" : { 91 | "east" : { 92 | "output" : "/actions/main/in/boolean_turnright" 93 | }, 94 | "north" : { 95 | "output" : "/actions/main/in/PrevItem" 96 | }, 97 | "south" : { 98 | "output" : "/actions/main/in/NextItem" 99 | }, 100 | "west" : { 101 | "output" : "/actions/main/in/boolean_turnleft" 102 | } 103 | }, 104 | "mode" : "dpad", 105 | "parameters" : { 106 | "deadzone_pct" : "70", 107 | "overlap_pct" : "0", 108 | "sub_mode" : "touch" 109 | }, 110 | "path" : "/user/hand/right/input/joystick" 111 | }, 112 | { 113 | "inputs" : { 114 | "click" : { 115 | "output" : "/actions/main/in/Use" 116 | } 117 | }, 118 | "mode" : "button", 119 | "path" : "/user/hand/right/input/b" 120 | }, 121 | { 122 | "inputs" : { 123 | "click" : { 124 | "output" : "/actions/main/in/ActivateVR" 125 | } 126 | }, 127 | "mode" : "button", 128 | "path" : "/user/hand/right/input/a" 129 | }, 130 | { 131 | "inputs" : { 132 | "click" : { 133 | "output" : "/actions/main/in/Jump" 134 | } 135 | }, 136 | "mode" : "button", 137 | "path" : "/user/hand/right/input/a" 138 | }, 139 | { 140 | "inputs" : { 141 | "click" : { 142 | "output" : "/actions/main/in/MenuSelect" 143 | } 144 | }, 145 | "mode" : "button", 146 | "path" : "/user/hand/right/input/a" 147 | }, 148 | { 149 | "inputs" : { 150 | "click" : { 151 | "output" : "/actions/main/in/MenuBack" 152 | } 153 | }, 154 | "mode" : "button", 155 | "path" : "/user/hand/right/input/b" 156 | }, 157 | { 158 | "inputs" : { 159 | "east" : { 160 | "output" : "/actions/main/in/MenuRight" 161 | }, 162 | "north" : { 163 | "output" : "/actions/main/in/MenuUp" 164 | }, 165 | "south" : { 166 | "output" : "/actions/main/in/MenuDown" 167 | }, 168 | "west" : { 169 | "output" : "/actions/main/in/MenuLeft" 170 | } 171 | }, 172 | "mode" : "dpad", 173 | "parameters" : { 174 | "deadzone_pct" : "70", 175 | "overlap_pct" : "0", 176 | "sub_mode" : "touch" 177 | }, 178 | "path" : "/user/hand/left/input/joystick" 179 | }, 180 | { 181 | "inputs" : { 182 | "click" : { 183 | "output" : "/actions/main/in/Scoreboard" 184 | } 185 | }, 186 | "mode" : "button", 187 | "path" : "/user/hand/left/input/x" 188 | }, 189 | { 190 | "inputs" : { 191 | "click" : { 192 | "output" : "/actions/main/in/Pause" 193 | } 194 | }, 195 | "mode" : "button", 196 | "path" : "/user/hand/left/input/y" 197 | }, 198 | { 199 | "inputs" : { 200 | "click" : { 201 | "output" : "/actions/main/in/Crouch" 202 | } 203 | }, 204 | "mode" : "button", 205 | "path" : "/user/hand/right/input/grip" 206 | }, 207 | { 208 | "inputs" : { 209 | "click" : { 210 | "output" : "/actions/main/in/SecondaryAttack" 211 | } 212 | }, 213 | "mode" : "button", 214 | "path" : "/user/hand/left/input/trigger" 215 | } 216 | ] 217 | } 218 | }, 219 | "category" : "steamvr_input", 220 | "controller_type" : "oculus_touch", 221 | "description" : "", 222 | "name" : "Default Left 4 Dead 2 VR bindings for Oculus Touch", 223 | "options" : {}, 224 | "simulated_actions" : [] 225 | } 226 | 227 | -------------------------------------------------------------------------------- /L4D2VR/SteamVRActionManifest/bindings_vive_cosmos_controller.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_manifest_version" : 0, 3 | "alias_info" : {}, 4 | "bindings" : { 5 | "/actions/base" : { 6 | "chords" : [], 7 | "haptics" : [ 8 | { 9 | "output" : "/actions/base/out/vibration_left", 10 | "path" : "/user/hand/left/output/haptic" 11 | }, 12 | { 13 | "output" : "/actions/base/out/vibration_right", 14 | "path" : "/user/hand/right/output/haptic" 15 | } 16 | ], 17 | "poses" : [ 18 | { 19 | "output" : "/actions/base/in/pose_lefthand", 20 | "path" : "/user/hand/left/pose/raw" 21 | }, 22 | { 23 | "output" : "/actions/base/in/pose_righthand", 24 | "path" : "/user/hand/right/pose/raw" 25 | } 26 | ], 27 | "skeleton" : [ 28 | { 29 | "output" : "/actions/base/in/skeleton_lefthand", 30 | "path" : "/user/hand/left/input/skeleton/left" 31 | }, 32 | { 33 | "output" : "/actions/base/in/skeleton_righthand", 34 | "path" : "/user/hand/right/input/skeleton/right" 35 | } 36 | ], 37 | "sources" : [] 38 | }, 39 | "/actions/main" : { 40 | "sources" : [ 41 | { 42 | "inputs" : { 43 | "click" : { 44 | "output" : "/actions/main/in/ResetPosition" 45 | }, 46 | "position" : { 47 | "output" : "/actions/main/in/Walk" 48 | } 49 | }, 50 | "mode" : "joystick", 51 | "parameters" : { 52 | "deadzone_pct" : "10" 53 | }, 54 | "path" : "/user/hand/left/input/joystick" 55 | }, 56 | { 57 | "inputs" : { 58 | "click" : { 59 | "output" : "/actions/main/in/Flashlight" 60 | }, 61 | "position" : { 62 | "output" : "/actions/main/in/Turn" 63 | } 64 | }, 65 | "mode" : "joystick", 66 | "parameters" : { 67 | "deadzone_pct" : "10" 68 | }, 69 | "path" : "/user/hand/right/input/joystick" 70 | }, 71 | { 72 | "inputs" : { 73 | "click" : { 74 | "output" : "/actions/main/in/Reload" 75 | } 76 | }, 77 | "mode" : "button", 78 | "path" : "/user/hand/left/input/grip" 79 | }, 80 | { 81 | "inputs" : { 82 | "click" : { 83 | "output" : "/actions/main/in/PrimaryAttack" 84 | } 85 | }, 86 | "mode" : "button", 87 | "path" : "/user/hand/right/input/trigger" 88 | }, 89 | { 90 | "inputs" : { 91 | "east" : { 92 | "output" : "/actions/main/in/boolean_turnright" 93 | }, 94 | "north" : { 95 | "output" : "/actions/main/in/PrevItem" 96 | }, 97 | "south" : { 98 | "output" : "/actions/main/in/NextItem" 99 | }, 100 | "west" : { 101 | "output" : "/actions/main/in/boolean_turnleft" 102 | } 103 | }, 104 | "mode" : "dpad", 105 | "parameters" : { 106 | "deadzone_pct" : "70", 107 | "overlap_pct" : "0", 108 | "sub_mode" : "touch" 109 | }, 110 | "path" : "/user/hand/right/input/joystick" 111 | }, 112 | { 113 | "inputs" : { 114 | "click" : { 115 | "output" : "/actions/main/in/Use" 116 | } 117 | }, 118 | "mode" : "button", 119 | "path" : "/user/hand/right/input/b" 120 | }, 121 | { 122 | "inputs" : { 123 | "click" : { 124 | "output" : "/actions/main/in/ActivateVR" 125 | } 126 | }, 127 | "mode" : "button", 128 | "path" : "/user/hand/right/input/a" 129 | }, 130 | { 131 | "inputs" : { 132 | "click" : { 133 | "output" : "/actions/main/in/Jump" 134 | } 135 | }, 136 | "mode" : "button", 137 | "path" : "/user/hand/right/input/a" 138 | }, 139 | { 140 | "inputs" : { 141 | "click" : { 142 | "output" : "/actions/main/in/MenuSelect" 143 | } 144 | }, 145 | "mode" : "button", 146 | "path" : "/user/hand/right/input/a" 147 | }, 148 | { 149 | "inputs" : { 150 | "click" : { 151 | "output" : "/actions/main/in/MenuBack" 152 | } 153 | }, 154 | "mode" : "button", 155 | "path" : "/user/hand/right/input/b" 156 | }, 157 | { 158 | "inputs" : { 159 | "east" : { 160 | "output" : "/actions/main/in/MenuRight" 161 | }, 162 | "north" : { 163 | "output" : "/actions/main/in/MenuUp" 164 | }, 165 | "south" : { 166 | "output" : "/actions/main/in/MenuDown" 167 | }, 168 | "west" : { 169 | "output" : "/actions/main/in/MenuLeft" 170 | } 171 | }, 172 | "mode" : "dpad", 173 | "parameters" : { 174 | "deadzone_pct" : "70", 175 | "overlap_pct" : "0", 176 | "sub_mode" : "touch" 177 | }, 178 | "path" : "/user/hand/left/input/joystick" 179 | }, 180 | { 181 | "inputs" : { 182 | "click" : { 183 | "output" : "/actions/main/in/Scoreboard" 184 | } 185 | }, 186 | "mode" : "button", 187 | "path" : "/user/hand/left/input/x" 188 | }, 189 | { 190 | "inputs" : { 191 | "click" : { 192 | "output" : "/actions/main/in/Pause" 193 | } 194 | }, 195 | "mode" : "button", 196 | "path" : "/user/hand/left/input/y" 197 | }, 198 | { 199 | "inputs" : { 200 | "click" : { 201 | "output" : "/actions/main/in/Crouch" 202 | } 203 | }, 204 | "mode" : "button", 205 | "path" : "/user/hand/right/input/grip" 206 | }, 207 | { 208 | "inputs" : { 209 | "click" : { 210 | "output" : "/actions/main/in/SecondaryAttack" 211 | } 212 | }, 213 | "mode" : "button", 214 | "path" : "/user/hand/left/input/trigger" 215 | } 216 | ] 217 | } 218 | }, 219 | "category" : "steamvr_input", 220 | "controller_type" : "vive_cosmos_controller", 221 | "description" : "", 222 | "name" : "Default Left 4 Dead 2 VR bindings for Vive Cosmos Controllers", 223 | "options" : {}, 224 | "simulated_actions" : [] 225 | } 226 | 227 | -------------------------------------------------------------------------------- /L4D2VR/config.txt: -------------------------------------------------------------------------------- 1 | TurnSpeed=0.3 2 | SnapTurning=false 3 | SnapTurnAngle=45.0 4 | LeftHanded=false 5 | VRScale=43.2 6 | IPDScale=1.0 7 | HideArms=false 8 | HudDistance=1.3 9 | HudSize=1.1 10 | HudAlwaysVisible=false -------------------------------------------------------------------------------- /L4D2VR/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include 3 | #include 4 | #include "game.h" 5 | #include "hooks.h" 6 | #include "vr.h" 7 | #include "sdk.h" 8 | 9 | DWORD WINAPI InitL4D2VR(HMODULE hModule) 10 | { 11 | #ifdef _DEBUG 12 | AllocConsole(); 13 | FILE *fp; 14 | freopen_s(&fp, "CONOUT$", "w", stdout); 15 | #endif 16 | 17 | // Make sure -insecure is used 18 | LPWSTR *szArglist; 19 | int nArgs; 20 | szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); 21 | bool insecureEnabled = false; 22 | for (int i = 0; i < nArgs; ++i) 23 | { 24 | if (wcscmp(szArglist[i], L"-insecure") == 0) 25 | insecureEnabled = true; 26 | } 27 | LocalFree(szArglist); 28 | 29 | if (!insecureEnabled) 30 | ExitProcess(0); 31 | 32 | g_Game = new Game(); 33 | 34 | return 0; 35 | } 36 | 37 | 38 | 39 | BOOL APIENTRY DllMain( HMODULE hModule, 40 | DWORD ul_reason_for_call, 41 | LPVOID lpReserved 42 | ) 43 | { 44 | switch (ul_reason_for_call) 45 | { 46 | case DLL_PROCESS_ATTACH: 47 | CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)InitL4D2VR, hModule, 0, NULL); 48 | case DLL_THREAD_ATTACH: 49 | case DLL_THREAD_DETACH: 50 | case DLL_PROCESS_DETACH: 51 | break; 52 | } 53 | return TRUE; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /L4D2VR/game.cpp: -------------------------------------------------------------------------------- 1 | #include "game.h" 2 | #include 3 | #include 4 | #include "sdk.h" 5 | #include "vr.h" 6 | #include "hooks.h" 7 | #include "offsets.h" 8 | #include "sigscanner.h" 9 | 10 | Game::Game() 11 | { 12 | while (!(m_BaseClient = (uintptr_t)GetModuleHandle("client.dll"))) 13 | Sleep(50); 14 | while (!(m_BaseEngine = (uintptr_t)GetModuleHandle("engine.dll"))) 15 | Sleep(50); 16 | while (!(m_BaseMaterialSystem = (uintptr_t)GetModuleHandle("MaterialSystem.dll"))) 17 | Sleep(50); 18 | while (!(m_BaseServer = (uintptr_t)GetModuleHandle("server.dll"))) 19 | Sleep(50); 20 | while (!(m_BaseVgui2 = (uintptr_t)GetModuleHandle("vgui2.dll"))) 21 | Sleep(50); 22 | 23 | m_ClientEntityList = (IClientEntityList *)GetInterface("client.dll", "VClientEntityList003"); 24 | m_EngineTrace = (IEngineTrace *)GetInterface("engine.dll", "EngineTraceClient003"); 25 | m_EngineClient = (IEngineClient *)GetInterface("engine.dll", "VEngineClient013"); 26 | m_MaterialSystem = (IMaterialSystem *)GetInterface("MaterialSystem.dll", "VMaterialSystem080"); 27 | m_ClientViewRender = (IViewRender *)GetInterface("client.dll", "VEngineRenderView013"); 28 | m_EngineViewRender = (IViewRender *)GetInterface("engine.dll", "VEngineRenderView013"); 29 | m_ModelInfo = (IModelInfo *)GetInterface("engine.dll", "VModelInfoClient004"); 30 | m_ModelRender = (IModelRender *)GetInterface("engine.dll", "VEngineModel016"); 31 | m_VguiInput = (IInput *)GetInterface("vgui2.dll", "VGUI_InputInternal001"); 32 | m_VguiSurface = (ISurface *)GetInterface("vguimatsurface.dll", "VGUI_Surface031"); 33 | 34 | m_Offsets = new Offsets(); 35 | m_VR = new VR(this); 36 | m_Hooks = new Hooks(this); 37 | 38 | m_Initialized = true; 39 | } 40 | 41 | void *Game::GetInterface(const char *dllname, const char *interfacename) 42 | { 43 | tCreateInterface CreateInterface = (tCreateInterface)GetProcAddress(GetModuleHandle(dllname), "CreateInterface"); 44 | 45 | int returnCode = 0; 46 | void *createdInterface = CreateInterface(interfacename, &returnCode); 47 | 48 | return createdInterface; 49 | } 50 | 51 | void Game::errorMsg(const char *msg) 52 | { 53 | MessageBox(0, msg, "L4D2VR", MB_ICONERROR | MB_OK); 54 | } 55 | 56 | CBaseEntity *Game::GetClientEntity(int entityIndex) 57 | { 58 | return (CBaseEntity *)(m_ClientEntityList->GetClientEntity(entityIndex)); 59 | } 60 | 61 | char *Game::getNetworkName(uintptr_t *entity) 62 | { 63 | uintptr_t *IClientNetworkableVtable = (uintptr_t *)*(entity + 0x8); 64 | uintptr_t *GetClientClassPtr = (uintptr_t *)*(IClientNetworkableVtable + 0x8); 65 | uintptr_t *ClientClassPtr = (uintptr_t *)*(GetClientClassPtr + 0x1); 66 | char *m_pNetworkName = (char *)*(ClientClassPtr + 0x8); 67 | int classID = (int)*(ClientClassPtr + 0x10); 68 | std::cout << "ClassID: " << classID << std::endl; 69 | return m_pNetworkName; 70 | } 71 | 72 | void Game::ClientCmd(const char *szCmdString) 73 | { 74 | m_EngineClient->ClientCmd(szCmdString); 75 | } 76 | 77 | void Game::ClientCmd_Unrestricted(const char *szCmdString) 78 | { 79 | m_EngineClient->ClientCmd_Unrestricted(szCmdString); 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /L4D2VR/game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "vector.h" 5 | 6 | class IClientEntityList; 7 | class IEngineTrace; 8 | class IEngineClient; 9 | class IMaterialSystem; 10 | class IBaseClientDLL; 11 | class IViewRender; 12 | class IViewRender; 13 | class CBaseEntity; 14 | class IModelInfo; 15 | class IModelRender; 16 | class IMaterial; 17 | class IInput; 18 | class ISurface; 19 | class C_BasePlayer; 20 | struct model_t; 21 | 22 | class Game; 23 | class Offsets; 24 | class VR; 25 | class Hooks; 26 | 27 | inline Game *g_Game; 28 | 29 | struct Player 30 | { 31 | C_BasePlayer *pPlayer; 32 | bool isUsingVR; 33 | QAngle controllerAngle; 34 | Vector controllerPos; 35 | bool isMeleeing; 36 | bool isNewSwing; 37 | QAngle prevControllerAngle; 38 | 39 | Player() 40 | : isUsingVR(false), 41 | controllerAngle({ 0,0,0 }), 42 | controllerPos({ 0,0,0 }), 43 | isMeleeing(false), 44 | isNewSwing(false), 45 | prevControllerAngle({ 0,0,0 }) 46 | {} 47 | }; 48 | 49 | class Game 50 | { 51 | public: 52 | IClientEntityList *m_ClientEntityList = nullptr; 53 | IEngineTrace *m_EngineTrace = nullptr; 54 | IEngineClient *m_EngineClient = nullptr; 55 | IMaterialSystem *m_MaterialSystem = nullptr; 56 | IBaseClientDLL *m_BaseClientDll = nullptr; 57 | IViewRender *m_ClientViewRender = nullptr; 58 | IViewRender *m_EngineViewRender = nullptr; 59 | IModelInfo *m_ModelInfo = nullptr; 60 | IModelRender *m_ModelRender = nullptr; 61 | IInput *m_VguiInput = nullptr; 62 | ISurface *m_VguiSurface = nullptr; 63 | 64 | uintptr_t m_BaseEngine; 65 | uintptr_t m_BaseClient; 66 | uintptr_t m_BaseServer; 67 | uintptr_t m_BaseMaterialSystem; 68 | uintptr_t m_BaseVgui2; 69 | 70 | Offsets *m_Offsets = nullptr; 71 | VR *m_VR = nullptr; 72 | Hooks *m_Hooks = nullptr; 73 | 74 | bool m_Initialized = false; 75 | 76 | std::array m_PlayersVRInfo; 77 | int m_CurrentUsercmdID = -1; 78 | bool m_PerformingMelee = false; 79 | 80 | model_t *m_ArmsModel = nullptr; 81 | IMaterial *m_ArmsMaterial = nullptr; 82 | bool m_CachedArmsModel = false; 83 | 84 | bool m_IsMeleeWeaponActive = false; 85 | bool m_SwitchedWeapons = false; 86 | 87 | Game(); 88 | 89 | void *GetInterface(const char *dllname, const char *interfacename); 90 | 91 | static void errorMsg(const char *msg); 92 | 93 | CBaseEntity *GetClientEntity(int entityIndex); 94 | char *getNetworkName(uintptr_t *entity); 95 | void ClientCmd(const char *szCmdString); 96 | void ClientCmd_Unrestricted(const char *szCmdString); 97 | 98 | typedef void *(__cdecl *tCreateInterface)(const char *name, int *returnCode); 99 | }; 100 | 101 | -------------------------------------------------------------------------------- /L4D2VR/hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks.h" 2 | #include "game.h" 3 | #include "texture.h" 4 | #include "sdk.h" 5 | #include "sdk_server.h" 6 | #include "vr.h" 7 | #include "offsets.h" 8 | #include 9 | 10 | Hooks::Hooks(Game *game) 11 | { 12 | if (MH_Initialize() != MH_OK) 13 | { 14 | Game::errorMsg("Failed to init MinHook"); 15 | } 16 | 17 | m_Game = game; 18 | m_VR = m_Game->m_VR; 19 | 20 | m_PushHUDStep = -999; 21 | m_PushedHud = false; 22 | 23 | initSourceHooks(); 24 | 25 | hkGetRenderTarget.enableHook(); 26 | hkCalcViewModelView.enableHook(); 27 | hkServerFireTerrorBullets.enableHook(); 28 | hkClientFireTerrorBullets.enableHook(); 29 | hkProcessUsercmds.enableHook(); 30 | hkReadUsercmd.enableHook(); 31 | hkWriteUsercmdDeltaToBuffer.enableHook(); 32 | hkWriteUsercmd.enableHook(); 33 | hkAdjustEngineViewport.enableHook(); 34 | hkViewport.enableHook(); 35 | hkGetViewport.enableHook(); 36 | hkCreateMove.enableHook(); 37 | hkTestMeleeSwingCollisionClient.enableHook(); 38 | hkTestMeleeSwingCollisionServer.enableHook(); 39 | hkDoMeleeSwingServer.enableHook(); 40 | hkStartMeleeSwingServer.enableHook(); 41 | hkPrimaryAttackServer.enableHook(); 42 | hkItemPostFrameServer.enableHook(); 43 | hkGetPrimaryAttackActivity.enableHook(); 44 | hkEyePosition.enableHook(); 45 | hkDrawModelExecute.enableHook(); 46 | hkRenderView.enableHook(); 47 | hkPushRenderTargetAndViewport.enableHook(); 48 | hkPopRenderTargetAndViewport.enableHook(); 49 | hkVgui_Paint.enableHook(); 50 | hkIsSplitScreen.enableHook(); 51 | hkPrePushRenderTarget.enableHook(); 52 | } 53 | 54 | Hooks::~Hooks() 55 | { 56 | if (MH_Uninitialize() != MH_OK) 57 | { 58 | Game::errorMsg("Failed to uninitialize MinHook"); 59 | } 60 | } 61 | 62 | 63 | int Hooks::initSourceHooks() 64 | { 65 | LPVOID pGetRenderTargetVFunc = (LPVOID)(m_Game->m_Offsets->GetRenderTarget.address); 66 | hkGetRenderTarget.createHook(pGetRenderTargetVFunc, &dGetRenderTarget); 67 | 68 | LPVOID pRenderViewVFunc = (LPVOID)(m_Game->m_Offsets->RenderView.address); 69 | hkRenderView.createHook(pRenderViewVFunc, &dRenderView); 70 | 71 | LPVOID calcViewModelViewAddr = (LPVOID)(m_Game->m_Offsets->CalcViewModelView.address); 72 | hkCalcViewModelView.createHook(calcViewModelViewAddr, &dCalcViewModelView); 73 | 74 | LPVOID serverFireTerrorBulletsAddr = (LPVOID)(m_Game->m_Offsets->ServerFireTerrorBullets.address); 75 | hkServerFireTerrorBullets.createHook(serverFireTerrorBulletsAddr, &dServerFireTerrorBullets); 76 | 77 | LPVOID clientFireTerrorBulletsAddr = (LPVOID)(m_Game->m_Offsets->ClientFireTerrorBullets.address); 78 | hkClientFireTerrorBullets.createHook(clientFireTerrorBulletsAddr, &dClientFireTerrorBullets); 79 | 80 | LPVOID ProcessUsercmdsAddr = (LPVOID)(m_Game->m_Offsets->ProcessUsercmds.address); 81 | hkProcessUsercmds.createHook(ProcessUsercmdsAddr, &dProcessUsercmds); 82 | 83 | LPVOID ReadUserCmdAddr = (LPVOID)(m_Game->m_Offsets->ReadUserCmd.address); 84 | hkReadUsercmd.createHook(ReadUserCmdAddr, &dReadUsercmd); 85 | 86 | LPVOID WriteUsercmdDeltaToBufferAddr = (LPVOID)(m_Game->m_Offsets->WriteUsercmdDeltaToBuffer.address); 87 | hkWriteUsercmdDeltaToBuffer.createHook(WriteUsercmdDeltaToBufferAddr, &dWriteUsercmdDeltaToBuffer); 88 | 89 | LPVOID WriteUsercmdAddr = (LPVOID)(m_Game->m_Offsets->WriteUsercmd.address); 90 | hkWriteUsercmd.createHook(WriteUsercmdAddr, &dWriteUsercmd); 91 | 92 | LPVOID AdjustEngineViewportAddr = (LPVOID)(m_Game->m_Offsets->AdjustEngineViewport.address); 93 | hkAdjustEngineViewport.createHook(AdjustEngineViewportAddr, &dAdjustEngineViewport); 94 | 95 | LPVOID ViewportAddr = (LPVOID)(m_Game->m_Offsets->Viewport.address); 96 | hkViewport.createHook(ViewportAddr, &dViewport); 97 | 98 | LPVOID GetViewportAddr = (LPVOID)(m_Game->m_Offsets->GetViewport.address); 99 | hkGetViewport.createHook(GetViewportAddr, &dGetViewport); 100 | 101 | LPVOID MeleeSwingClientAddr = (LPVOID)(m_Game->m_Offsets->TestMeleeSwingClient.address); 102 | hkTestMeleeSwingCollisionClient.createHook(MeleeSwingClientAddr, &dTestMeleeSwingCollisionClient); 103 | 104 | LPVOID MeleeSwingServerAddr = (LPVOID)(m_Game->m_Offsets->TestMeleeSwingServer.address); 105 | hkTestMeleeSwingCollisionServer.createHook(MeleeSwingServerAddr, &dTestMeleeSwingCollisionServer); 106 | 107 | LPVOID DoMeleeSwingServerAddr = (LPVOID)(m_Game->m_Offsets->DoMeleeSwingServer.address); 108 | hkDoMeleeSwingServer.createHook(DoMeleeSwingServerAddr, &dDoMeleeSwingServer); 109 | 110 | LPVOID StartMeleeSwingServerAddr = (LPVOID)(m_Game->m_Offsets->StartMeleeSwingServer.address); 111 | hkStartMeleeSwingServer.createHook(StartMeleeSwingServerAddr, &dStartMeleeSwingServer); 112 | 113 | LPVOID PrimaryAttackServerAddr = (LPVOID)(m_Game->m_Offsets->PrimaryAttackServer.address); 114 | hkPrimaryAttackServer.createHook(PrimaryAttackServerAddr, &dPrimaryAttackServer); 115 | 116 | LPVOID ItemPostFrameServerAddr = (LPVOID)(m_Game->m_Offsets->ItemPostFrameServer.address); 117 | hkItemPostFrameServer.createHook(ItemPostFrameServerAddr, &dItemPostFrameServer); 118 | 119 | LPVOID GetPrimaryAttackActivityAddr = (LPVOID)(m_Game->m_Offsets->GetPrimaryAttackActivity.address); 120 | hkGetPrimaryAttackActivity.createHook(GetPrimaryAttackActivityAddr, &dGetPrimaryAttackActivity); 121 | 122 | LPVOID EyePositionAddr = (LPVOID)(m_Game->m_Offsets->EyePosition.address); 123 | hkEyePosition.createHook(EyePositionAddr, &dEyePosition); 124 | 125 | LPVOID DrawModelExecuteAddr = (LPVOID)(m_Game->m_Offsets->DrawModelExecute.address); 126 | hkDrawModelExecute.createHook(DrawModelExecuteAddr, &dDrawModelExecute); 127 | 128 | LPVOID PushRenderTargetAddr = (LPVOID)(m_Game->m_Offsets->PushRenderTargetAndViewport.address); 129 | hkPushRenderTargetAndViewport.createHook(PushRenderTargetAddr, &dPushRenderTargetAndViewport); 130 | 131 | LPVOID PopRenderTargetAddr = (LPVOID)(m_Game->m_Offsets->PopRenderTargetAndViewport.address); 132 | hkPopRenderTargetAndViewport.createHook(PopRenderTargetAddr, &dPopRenderTargetAndViewport); 133 | 134 | LPVOID VGui_PaintAddr = (LPVOID)(m_Game->m_Offsets->VGui_Paint.address); 135 | hkVgui_Paint.createHook(VGui_PaintAddr, &dVGui_Paint); 136 | 137 | LPVOID IsSplitScreenAddr = (LPVOID)(m_Game->m_Offsets->IsSplitScreen.address); 138 | hkIsSplitScreen.createHook(IsSplitScreenAddr, &dIsSplitScreen); 139 | 140 | LPVOID PrePushRenderTargetAddr = (LPVOID)(m_Game->m_Offsets->PrePushRenderTarget.address); 141 | hkPrePushRenderTarget.createHook(PrePushRenderTargetAddr, &dPrePushRenderTarget); 142 | 143 | void *clientMode = nullptr; 144 | while (!clientMode) 145 | { 146 | Sleep(10); 147 | clientMode = **(void ***)(m_Game->m_Offsets->g_pClientMode.address); 148 | } 149 | hkCreateMove.createHook( (*(void ***)clientMode)[27], dCreateMove ); 150 | 151 | return 1; 152 | } 153 | 154 | 155 | ITexture *__fastcall Hooks::dGetRenderTarget(void *ecx, void *edx) 156 | { 157 | ITexture *result = hkGetRenderTarget.fOriginal(ecx); 158 | return result; 159 | } 160 | 161 | void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw) 162 | { 163 | if (!m_VR->m_CreatedVRTextures) 164 | m_VR->CreateVRTextures(); 165 | 166 | IMatRenderContext *rndrContext = m_Game->m_MaterialSystem->GetRenderContext(); 167 | 168 | CViewSetup leftEyeView = setup; 169 | CViewSetup rightEyeView = setup; 170 | 171 | // Left eye CViewSetup 172 | leftEyeView.x = 0; 173 | leftEyeView.width = m_VR->m_RenderWidth; 174 | leftEyeView.height = m_VR->m_RenderHeight; 175 | leftEyeView.fov = m_VR->m_Fov; 176 | leftEyeView.fovViewmodel = m_VR->m_Fov; 177 | leftEyeView.m_flAspectRatio = m_VR->m_Aspect; 178 | leftEyeView.zNear = 6; 179 | leftEyeView.zNearViewmodel = 6; 180 | leftEyeView.origin = m_VR->GetViewOriginLeft(); 181 | leftEyeView.angles = m_VR->GetViewAngle(); 182 | 183 | m_VR->m_SetupOrigin = setup.origin; 184 | 185 | Vector hmdAngle = m_VR->GetViewAngle(); 186 | QAngle inGameAngle(hmdAngle.x, hmdAngle.y, hmdAngle.z); 187 | m_Game->m_EngineClient->SetViewAngles(inGameAngle); 188 | 189 | rndrContext->SetRenderTarget(m_VR->m_LeftEyeTexture); 190 | hkRenderView.fOriginal(ecx, leftEyeView, hudViewSetup, nClearFlags, whatToDraw); 191 | m_PushedHud = false; 192 | 193 | // Right eye CViewSetup 194 | rightEyeView.x = 0; 195 | rightEyeView.width = m_VR->m_RenderWidth; 196 | rightEyeView.height = m_VR->m_RenderHeight; 197 | rightEyeView.fov = m_VR->m_Fov; 198 | rightEyeView.fovViewmodel = m_VR->m_Fov; 199 | rightEyeView.m_flAspectRatio = m_VR->m_Aspect; 200 | rightEyeView.zNear = 6; 201 | rightEyeView.zNearViewmodel = 6; 202 | rightEyeView.origin = m_VR->GetViewOriginRight(); 203 | rightEyeView.angles = m_VR->GetViewAngle(); 204 | 205 | rndrContext->SetRenderTarget(m_VR->m_RightEyeTexture); 206 | hkRenderView.fOriginal(ecx, rightEyeView, hudViewSetup, nClearFlags, whatToDraw); 207 | 208 | m_VR->m_RenderedNewFrame = true; 209 | } 210 | 211 | bool __fastcall Hooks::dCreateMove(void *ecx, void *edx, float flInputSampleTime, CUserCmd *cmd) 212 | { 213 | if (!cmd->command_number) 214 | return hkCreateMove.fOriginal(ecx, flInputSampleTime, cmd); 215 | 216 | if (m_VR->m_IsVREnabled && m_VR->m_RoomscaleActive) 217 | { 218 | Vector setupOriginToHMD = m_VR->m_SetupOriginToHMD; 219 | setupOriginToHMD.z = 0; 220 | float distance = VectorLength(setupOriginToHMD); 221 | if (distance > 1) 222 | { 223 | float forwardSpeed = DotProduct2D(setupOriginToHMD, m_VR->m_HmdForward); 224 | float sideSpeed = DotProduct2D(setupOriginToHMD, m_VR->m_HmdRight); 225 | cmd->forwardmove += distance * forwardSpeed; 226 | cmd->sidemove += distance * sideSpeed; 227 | } 228 | } 229 | 230 | return false; 231 | } 232 | 233 | void __fastcall Hooks::dEndFrame(void *ecx, void *edx) 234 | { 235 | return hkEndFrame.fOriginal(ecx); 236 | } 237 | 238 | void __fastcall Hooks::dCalcViewModelView(void *ecx, void *edx, void *owner, const Vector &eyePosition, const QAngle &eyeAngles) 239 | { 240 | Vector vecNewOrigin = eyePosition; 241 | QAngle vecNewAngles = eyeAngles; 242 | 243 | if (m_VR->m_IsVREnabled) 244 | { 245 | vecNewOrigin = m_VR->GetRecommendedViewmodelAbsPos(); 246 | vecNewAngles = m_VR->GetRecommendedViewmodelAbsAngle(); 247 | } 248 | 249 | return hkCalcViewModelView.fOriginal(ecx, owner, vecNewOrigin, vecNewAngles); 250 | } 251 | 252 | int Hooks::dServerFireTerrorBullets(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7) 253 | { 254 | Vector vecNewOrigin = vecOrigin; 255 | QAngle vecNewAngles = vecAngles; 256 | 257 | // Server host 258 | if (m_VR->m_IsVREnabled && playerId == m_Game->m_EngineClient->GetLocalPlayer()) 259 | { 260 | vecNewOrigin = m_VR->GetRightControllerAbsPos(); 261 | vecNewAngles = m_VR->GetRightControllerAbsAngle(); 262 | } 263 | // Clients 264 | else if (m_Game->m_PlayersVRInfo[playerId].isUsingVR) 265 | { 266 | vecNewOrigin = m_Game->m_PlayersVRInfo[playerId].controllerPos; 267 | vecNewAngles = m_Game->m_PlayersVRInfo[playerId].controllerAngle; 268 | } 269 | 270 | return hkServerFireTerrorBullets.fOriginal(playerId, vecNewOrigin, vecNewAngles, a4, a5, a6, a7); 271 | } 272 | 273 | int Hooks::dClientFireTerrorBullets(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7) 274 | { 275 | Vector vecNewOrigin = vecOrigin; 276 | QAngle vecNewAngles = vecAngles; 277 | 278 | if (m_VR->m_IsVREnabled && playerId == m_Game->m_EngineClient->GetLocalPlayer()) 279 | { 280 | vecNewOrigin = m_VR->GetRightControllerAbsPos(); 281 | vecNewAngles = m_VR->GetRightControllerAbsAngle(); 282 | } 283 | 284 | return hkClientFireTerrorBullets.fOriginal(playerId, vecNewOrigin, vecNewAngles, a4, a5, a6, a7); 285 | } 286 | 287 | 288 | float __fastcall Hooks::dProcessUsercmds(void *ecx, void *edx, edict_t *player, void *buf, int numcmds, int totalcmds, int dropped_packets, bool ignore, bool paused) 289 | { 290 | // Function pointer for CBaseEntity::entindex 291 | typedef int(__thiscall *tEntindex)(void *thisptr); 292 | static tEntindex oEntindex = (tEntindex)(m_Game->m_Offsets->CBaseEntity_entindex.address); 293 | 294 | IServerUnknown * pUnknown = player->m_pUnk; 295 | Server_BaseEntity *pPlayer = (Server_BaseEntity*)pUnknown->GetBaseEntity(); 296 | 297 | int index = oEntindex(pPlayer); 298 | m_Game->m_CurrentUsercmdID = index; 299 | 300 | float result = hkProcessUsercmds.fOriginal(ecx, player, buf, numcmds, totalcmds, dropped_packets, ignore, paused); 301 | 302 | // check if swinging melee wep 303 | if (m_Game->m_PlayersVRInfo[index].isUsingVR && m_Game->m_PlayersVRInfo[index].isMeleeing) 304 | { 305 | typedef Server_WeaponCSBase *(__thiscall *tGetActiveWep)(void *thisptr); 306 | static tGetActiveWep oGetActiveWep = (tGetActiveWep)(m_Game->m_Offsets->GetActiveWeapon.address); 307 | Server_WeaponCSBase *curWep = oGetActiveWep(pPlayer); 308 | 309 | if (curWep) 310 | { 311 | int wepID = curWep->GetWeaponID(); 312 | if (wepID == 19) // melee weapon 313 | { 314 | if (m_Game->m_PlayersVRInfo[index].isNewSwing) 315 | { 316 | m_Game->m_PlayersVRInfo[index].isNewSwing = false; 317 | curWep->entitiesHitThisSwing = 0; 318 | } 319 | 320 | typedef void *(__thiscall *tGetMeleeWepInfo)(void *thisptr); 321 | static tGetMeleeWepInfo oGetMeleeWepInfo = (tGetMeleeWepInfo)(m_Game->m_Offsets->GetMeleeWeaponInfo.address); 322 | void *meleeWepInfo = oGetMeleeWepInfo(curWep); 323 | 324 | Vector initialForward, initialRight, initialUp; 325 | QAngle::AngleVectors(m_Game->m_PlayersVRInfo[index].prevControllerAngle, &initialForward, &initialRight, &initialUp); 326 | Vector initialMeleeDirection = VectorRotate(initialForward, initialRight, 50.0); 327 | VectorNormalize(initialMeleeDirection); 328 | 329 | Vector finalForward, finalRight, finalUp; 330 | QAngle::AngleVectors(m_Game->m_PlayersVRInfo[index].controllerAngle, &finalForward, &finalRight, &finalUp); 331 | Vector finalMeleeDirection = VectorRotate(finalForward, finalRight, 50.0); 332 | VectorNormalize(finalMeleeDirection); 333 | 334 | Vector pivot; 335 | CrossProduct(initialMeleeDirection, finalMeleeDirection, pivot); 336 | VectorNormalize(pivot); 337 | 338 | float swingAngle = acos(DotProduct(initialMeleeDirection, finalMeleeDirection)) * 180 / 3.14159265; 339 | 340 | m_Game->m_Hooks->hkGetPrimaryAttackActivity.fOriginal(curWep, meleeWepInfo); // Needed to call TestMeleeSwingCollision 341 | 342 | m_Game->m_PerformingMelee = true; 343 | 344 | Vector traceDirection = initialMeleeDirection; 345 | int numTraces = 10; 346 | float traceAngle = swingAngle / numTraces; 347 | for (int i = 0; i < numTraces; ++i) 348 | { 349 | traceDirection = VectorRotate(traceDirection, pivot, traceAngle); 350 | m_Game->m_Hooks->hkTestMeleeSwingCollisionServer.fOriginal(curWep, traceDirection); 351 | } 352 | 353 | m_Game->m_PerformingMelee = false; 354 | } 355 | } 356 | } 357 | else 358 | { 359 | m_Game->m_PlayersVRInfo[index].isNewSwing = true; 360 | } 361 | 362 | m_Game->m_PlayersVRInfo[index].prevControllerAngle = m_Game->m_PlayersVRInfo[index].controllerAngle; 363 | 364 | return result; 365 | } 366 | 367 | int Hooks::dReadUsercmd(void *buf, CUserCmd *move, CUserCmd *from) 368 | { 369 | hkReadUsercmd.fOriginal(buf, move, from); 370 | 371 | int i = m_Game->m_CurrentUsercmdID; 372 | if (move->tick_count < 0) // Signal for VR CUserCmd 373 | { 374 | move->tick_count *= -1; 375 | 376 | if (move->command_number < 0) 377 | { 378 | move->command_number *= -1; 379 | m_Game->m_PlayersVRInfo[i].isMeleeing = true; 380 | } 381 | else 382 | { 383 | m_Game->m_PlayersVRInfo[i].isMeleeing = false; 384 | } 385 | 386 | m_Game->m_PlayersVRInfo[i].isUsingVR = true; 387 | m_Game->m_PlayersVRInfo[i].controllerAngle.x = (float)move->mousedx / 10; 388 | m_Game->m_PlayersVRInfo[i].controllerAngle.y = (float)move->mousedy / 10; 389 | m_Game->m_PlayersVRInfo[i].controllerPos.x = move->viewangles.z; 390 | m_Game->m_PlayersVRInfo[i].controllerPos.y = move->upmove; 391 | 392 | // Decode controllerAngle.z 393 | int rollEncoding = move->command_number / 10000000; 394 | move->command_number -= rollEncoding * 10000000; 395 | m_Game->m_PlayersVRInfo[i].controllerAngle.z = (rollEncoding * 2) - 180; 396 | 397 | // Decode viewangles.x 398 | int decodedZInt = (move->viewangles.x / 10000); 399 | float decodedAngle = abs((float)(move->viewangles.x - (decodedZInt * 10000)) / 10); 400 | decodedAngle -= 360; 401 | float decodedZ = (float)decodedZInt / 10; 402 | 403 | m_Game->m_PlayersVRInfo[i].controllerPos.z = decodedZ; 404 | 405 | move->viewangles.x = decodedAngle; 406 | move->viewangles.z = 0; 407 | move->upmove = 0; 408 | } 409 | else 410 | { 411 | m_Game->m_PlayersVRInfo[i].isUsingVR = false; 412 | } 413 | return 1; 414 | } 415 | 416 | void __fastcall Hooks::dWriteUsercmdDeltaToBuffer(void *ecx, void *edx, int a1, void *buf, int from, int to, bool isnewcommand) 417 | { 418 | return hkWriteUsercmdDeltaToBuffer.fOriginal(ecx, a1, buf, from, to, isnewcommand); 419 | } 420 | 421 | int Hooks::dWriteUsercmd(void *buf, CUserCmd *to, CUserCmd *from) 422 | { 423 | if (m_VR->m_IsVREnabled) 424 | { 425 | CInput *m_Input = **(CInput ***)(m_Game->m_Offsets->g_pppInput.address); 426 | CVerifiedUserCmd *pVerifiedCommands = *(CVerifiedUserCmd **)((uintptr_t)m_Input + 0xF0); 427 | CVerifiedUserCmd *pVerified = &pVerifiedCommands[(to->command_number) % 150]; 428 | 429 | // Signal to the server that this CUserCmd has VR info 430 | to->tick_count *= -1; 431 | 432 | int originalCommandNum = to->command_number; 433 | 434 | QAngle controllerAngles = m_VR->GetRightControllerAbsAngle(); 435 | to->mousedx = controllerAngles.x * 10; // Strip off 2nd decimal to save bits. 436 | to->mousedy = controllerAngles.y * 10; 437 | int rollEncoding = (((int)controllerAngles.z + 180) / 2 * 10000000); 438 | to->command_number += rollEncoding; 439 | 440 | if (VectorLength(m_VR->m_RightControllerPose.TrackedDeviceVel) > 1.1) 441 | { 442 | to->command_number *= -1; // Signal to server that melee swing in motion 443 | } 444 | 445 | Vector controllerPos = m_VR->GetRightControllerAbsPos(); 446 | to->viewangles.z = controllerPos.x; 447 | to->upmove = controllerPos.y; 448 | 449 | // Space in CUserCmd is tight, so encode viewangle.x and controllerPos.z together. 450 | // Encoding will overflow if controllerPos.z goes beyond +-21474.8 451 | float xAngle = to->viewangles.x; 452 | int encodedAngle = (xAngle + 360) * 10; 453 | int encoding = (int)(controllerPos.z * 10) * 10000; 454 | encoding += encoding < 0 ? -encodedAngle : encodedAngle; 455 | to->viewangles.x = encoding; 456 | 457 | hkWriteUsercmd.fOriginal(buf, to, from); 458 | 459 | to->viewangles.x = xAngle; 460 | to->tick_count *= -1; 461 | to->viewangles.z = 0; 462 | to->upmove = 0; 463 | to->command_number = originalCommandNum; 464 | 465 | // Must recalculate checksum for the edited CUserCmd or gunshots will sound 466 | // terrible in multiplayer. 467 | pVerified->m_cmd = *to; 468 | pVerified->m_crc = to->GetChecksum(); 469 | return 1; 470 | } 471 | return hkWriteUsercmd.fOriginal(buf, to, from); 472 | } 473 | 474 | void Hooks::dAdjustEngineViewport(int &x, int &y, int &width, int &height) 475 | { 476 | hkAdjustEngineViewport.fOriginal(x, y, width, height); 477 | } 478 | 479 | void Hooks::dViewport(void *ecx, void *edx, int x, int y, int width, int height) 480 | { 481 | hkViewport.fOriginal(ecx, x, y, width, height); 482 | } 483 | 484 | void Hooks::dGetViewport(void *ecx, void *edx, int &x, int &y, int &width, int &height) 485 | { 486 | hkGetViewport.fOriginal(ecx, x, y, width, height); 487 | } 488 | 489 | int Hooks::dTestMeleeSwingCollisionClient(void *ecx, void *edx, Vector const &vec) 490 | { 491 | return hkTestMeleeSwingCollisionClient.fOriginal(ecx, vec); 492 | } 493 | 494 | int Hooks::dTestMeleeSwingCollisionServer(void *ecx, void *edx, Vector const &vec) 495 | { 496 | return hkTestMeleeSwingCollisionServer.fOriginal(ecx, vec); 497 | } 498 | 499 | void Hooks::dDoMeleeSwingServer(void *ecx, void *edx) 500 | { 501 | return hkDoMeleeSwingServer.fOriginal(ecx); 502 | } 503 | 504 | void Hooks::dStartMeleeSwingServer(void *ecx, void *edx, void *player, bool a3) 505 | { 506 | return hkStartMeleeSwingServer.fOriginal(ecx, player, a3); 507 | } 508 | 509 | int Hooks::dPrimaryAttackServer(void *ecx, void *edx) 510 | { 511 | return hkPrimaryAttackServer.fOriginal(ecx); 512 | } 513 | 514 | void Hooks::dItemPostFrameServer(void *ecx, void *edx) 515 | { 516 | hkItemPostFrameServer.fOriginal(ecx); 517 | } 518 | 519 | int Hooks::dGetPrimaryAttackActivity(void *ecx, void *edx, void *meleeInfo) 520 | { 521 | return hkGetPrimaryAttackActivity.fOriginal(ecx, meleeInfo); 522 | } 523 | 524 | Vector *Hooks::dEyePosition(void *ecx, void *edx, Vector *eyePos) 525 | { 526 | Vector *result = hkEyePosition.fOriginal(ecx, eyePos); 527 | 528 | if (m_Game->m_PerformingMelee) 529 | { 530 | int i = m_Game->m_CurrentUsercmdID; 531 | *result = m_Game->m_PlayersVRInfo[i].controllerPos; 532 | } 533 | 534 | return result; 535 | } 536 | 537 | void Hooks::dDrawModelExecute(void *ecx, void *edx, void *state, const ModelRenderInfo_t &info, void *pCustomBoneToWorld) 538 | { 539 | if (m_Game->m_SwitchedWeapons) 540 | m_Game->m_CachedArmsModel = false; 541 | 542 | bool hideArms = m_Game->m_IsMeleeWeaponActive || m_VR->m_HideArms; 543 | 544 | if (info.pModel && hideArms && !m_Game->m_CachedArmsModel) 545 | { 546 | std::string modelName = m_Game->m_ModelInfo->GetModelName(info.pModel); 547 | if (modelName.find("/arms/") != std::string::npos) 548 | { 549 | m_Game->m_ArmsMaterial = m_Game->m_MaterialSystem->FindMaterial(modelName.c_str(), "Model textures"); 550 | m_Game->m_ArmsModel = info.pModel; 551 | m_Game->m_CachedArmsModel = true; 552 | } 553 | } 554 | 555 | if (info.pModel && info.pModel == m_Game->m_ArmsModel && hideArms) 556 | { 557 | m_Game->m_ArmsMaterial->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, true); 558 | m_Game->m_ModelRender->ForcedMaterialOverride(m_Game->m_ArmsMaterial); 559 | hkDrawModelExecute.fOriginal(ecx, state, info, pCustomBoneToWorld); 560 | m_Game->m_ModelRender->ForcedMaterialOverride(NULL); 561 | return; 562 | } 563 | 564 | hkDrawModelExecute.fOriginal(ecx, state, info, pCustomBoneToWorld); 565 | } 566 | 567 | void Hooks::dPushRenderTargetAndViewport(void *ecx, void *edx, ITexture *pTexture, ITexture *pDepthTexture, int nViewX, int nViewY, int nViewW, int nViewH) 568 | { 569 | if (!m_VR->m_CreatedVRTextures) 570 | return hkPushRenderTargetAndViewport.fOriginal(ecx, pTexture, pDepthTexture, nViewX, nViewY, nViewW, nViewH); 571 | 572 | if (m_PushHUDStep == 2) 573 | ++m_PushHUDStep; 574 | else 575 | m_PushHUDStep = -999; 576 | 577 | // RenderView calls PushRenderTargetAndViewport multiple times with different textures. 578 | // When the call order goes PopRenderTargetAndViewport -> IsSplitScreen -> PrePushRenderTarget -> PushRenderTargetAndViewport, 579 | // then it pushed the HUD/GUI render target to the RT stack. 580 | if (m_PushHUDStep == 3) 581 | { 582 | pTexture = m_VR->m_HUDTexture; 583 | 584 | IMatRenderContext *renderContext = m_Game->m_MaterialSystem->GetRenderContext(); 585 | renderContext->ClearBuffers(false, true, true); 586 | 587 | hkPushRenderTargetAndViewport.fOriginal(ecx, pTexture, pDepthTexture, nViewX, nViewY, nViewW, nViewH); 588 | 589 | renderContext->OverrideAlphaWriteEnable(true, true); 590 | renderContext->ClearColor4ub(0, 0, 0, 0); 591 | renderContext->ClearBuffers(true, false); 592 | 593 | m_VR->m_RenderedHud = true; 594 | m_PushedHud = true; 595 | } 596 | else 597 | { 598 | hkPushRenderTargetAndViewport.fOriginal(ecx, pTexture, pDepthTexture, nViewX, nViewY, nViewW, nViewH); 599 | } 600 | } 601 | 602 | void Hooks::dPopRenderTargetAndViewport(void *ecx, void *edx) 603 | { 604 | if (!m_VR->m_CreatedVRTextures) 605 | return hkPopRenderTargetAndViewport.fOriginal(ecx); 606 | 607 | m_PushHUDStep = 0; 608 | 609 | if (m_PushedHud) 610 | { 611 | m_Game->m_MaterialSystem->GetRenderContext()->OverrideAlphaWriteEnable(false, true); 612 | m_Game->m_MaterialSystem->GetRenderContext()->ClearColor4ub(0, 0, 0, 255); 613 | } 614 | 615 | hkPopRenderTargetAndViewport.fOriginal(ecx); 616 | } 617 | 618 | void Hooks::dVGui_Paint(void *ecx, void *edx, int mode) 619 | { 620 | if (!m_VR->m_CreatedVRTextures) 621 | return hkVgui_Paint.fOriginal(ecx, mode); 622 | 623 | if (m_PushedHud) 624 | mode = PAINT_UIPANELS | PAINT_INGAMEPANELS; 625 | 626 | hkVgui_Paint.fOriginal(ecx, mode); 627 | } 628 | 629 | int Hooks::dIsSplitScreen() 630 | { 631 | if (m_PushHUDStep == 0) 632 | ++m_PushHUDStep; 633 | else 634 | m_PushHUDStep = -999; 635 | 636 | return hkIsSplitScreen.fOriginal(); 637 | } 638 | 639 | DWORD *Hooks::dPrePushRenderTarget(void *ecx, void *edx, int a2) 640 | { 641 | if (m_PushHUDStep == 1) 642 | ++m_PushHUDStep; 643 | else 644 | m_PushHUDStep = -999; 645 | 646 | return hkPrePushRenderTarget.fOriginal(ecx, a2); 647 | } -------------------------------------------------------------------------------- /L4D2VR/hooks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "MinHook.h" 4 | 5 | class Game; 6 | class VR; 7 | class ITexture; 8 | class CViewSetup; 9 | class CUserCmd; 10 | class QAngle; 11 | class Vector; 12 | class edict_t; 13 | class ModelRenderInfo_t; 14 | 15 | 16 | template 17 | struct Hook { 18 | T fOriginal; 19 | LPVOID pTarget; 20 | bool isEnabled; 21 | 22 | int createHook(LPVOID targetFunc, LPVOID detourFunc) 23 | { 24 | if (MH_CreateHook(targetFunc, detourFunc, reinterpret_cast(&fOriginal)) != MH_OK) 25 | { 26 | char errorString[512]; 27 | sprintf_s(errorString, 512, "Failed to create hook with this signature: %s", typeid(T).name()); 28 | Game::errorMsg(errorString); 29 | return 1; 30 | } 31 | pTarget = targetFunc; 32 | } 33 | 34 | int enableHook() 35 | { 36 | if (MH_EnableHook(pTarget) != MH_OK) 37 | { 38 | Game::errorMsg("Failed to enable hook"); 39 | return 1; 40 | } 41 | isEnabled = true; 42 | } 43 | 44 | int disableHook() 45 | { 46 | if (MH_DisableHook(pTarget) != MH_OK) 47 | { 48 | Game::errorMsg("Failed to disable hook"); 49 | return 1; 50 | } 51 | isEnabled = false; 52 | } 53 | }; 54 | 55 | 56 | // Source Engine functions 57 | typedef ITexture *(__thiscall *tGetRenderTarget)(void *thisptr); 58 | typedef void(__thiscall *tRenderView)(void *thisptr, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw); 59 | typedef bool(__thiscall *tCreateMove)(void *thisptr, float flInputSampleTime, CUserCmd *cmd); 60 | typedef void(__thiscall *tEndFrame)(PVOID); 61 | typedef void(__thiscall *tCalcViewModelView)(void *thisptr, void *owner, const Vector &eyePosition, const QAngle &eyeAngles); 62 | typedef int(__cdecl *tFireTerrorBullets)(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7); 63 | typedef float(__thiscall *tProcessUsercmds)(void *thisptr, edict_t *player, void *buf, int numcmds, int totalcmds, int dropped_packets, bool ignore, bool paused); 64 | typedef int(__cdecl *tReadUsercmd)(void *buf, CUserCmd *move, CUserCmd *from); 65 | typedef void(__thiscall *tWriteUsercmdDeltaToBuffer)(void *thisptr, int a1, void *buf, int from, int to, bool isnewcommand); 66 | typedef int(__cdecl *tWriteUsercmd)(void *buf, CUserCmd *to, CUserCmd *from); 67 | typedef int(__cdecl *tAdjustEngineViewport)(int &x, int &y, int &width, int &height); 68 | typedef void(__thiscall *tViewport)(void *thisptr, int x, int y, int width, int height); 69 | typedef void(__thiscall *tGetViewport)(void *thisptr, int &x, int &y, int &width, int &height); 70 | typedef int(__thiscall *tTestMeleeSwingCollision)(void *thisptr, Vector const &vec); 71 | typedef void(__thiscall *tDoMeleeSwing)(void *thisptr); 72 | typedef void(__thiscall *tStartMeleeSwing)(void *thisptr, void* player, bool a3); 73 | typedef int(__thiscall *tPrimaryAttack)(void *thisptr); 74 | typedef void(__thiscall *tItemPostFrame)(void *thisptr); 75 | typedef int(__thiscall *tGetPrimaryAttackActivity)(void *thisptr, void *meleeInfo); 76 | typedef Vector *(__thiscall *tEyePosition)(void *thisptr, Vector *eyePos); 77 | typedef void(__thiscall *tDrawModelExecute)(void *thisptr, void *state, const ModelRenderInfo_t &info, void *pCustomBoneToWorld); 78 | typedef void(__thiscall *tPushRenderTargetAndViewport)(void *thisptr, ITexture *pTexture, ITexture *pDepthTexture, int nViewX, int nViewY, int nViewW, int nViewH); 79 | typedef void(__thiscall *tPopRenderTargetAndViewport)(void *thisptr); 80 | typedef void(__thiscall *tVgui_Paint)(void *thisptr, int mode); 81 | typedef int(__cdecl *tIsSplitScreen)(); 82 | typedef DWORD *(__thiscall *tPrePushRenderTarget)(void *thisptr, int a2); 83 | 84 | 85 | class Hooks 86 | { 87 | public: 88 | static inline Game *m_Game; 89 | static inline VR *m_VR; 90 | 91 | static inline Hook hkGetRenderTarget; 92 | static inline Hook hkRenderView; 93 | static inline Hook hkCreateMove; 94 | static inline Hook hkEndFrame; 95 | static inline Hook hkCalcViewModelView; 96 | static inline Hook hkServerFireTerrorBullets; 97 | static inline Hook hkClientFireTerrorBullets; 98 | static inline Hook hkProcessUsercmds; 99 | static inline Hook hkReadUsercmd; 100 | static inline Hook hkWriteUsercmdDeltaToBuffer; 101 | static inline Hook hkWriteUsercmd; 102 | static inline Hook hkAdjustEngineViewport; 103 | static inline Hook hkViewport; 104 | static inline Hook hkGetViewport; 105 | static inline Hook hkTestMeleeSwingCollisionClient; 106 | static inline Hook hkTestMeleeSwingCollisionServer; 107 | static inline Hook hkDoMeleeSwingServer; 108 | static inline Hook hkStartMeleeSwingServer; 109 | static inline Hook hkPrimaryAttackServer; 110 | static inline Hook hkItemPostFrameServer; 111 | static inline Hook hkGetPrimaryAttackActivity; 112 | static inline Hook hkEyePosition; 113 | static inline Hook hkDrawModelExecute; 114 | static inline Hook hkPushRenderTargetAndViewport; 115 | static inline Hook hkPopRenderTargetAndViewport; 116 | static inline Hook hkVgui_Paint; 117 | static inline Hook hkIsSplitScreen; 118 | static inline Hook hkPrePushRenderTarget; 119 | 120 | Hooks() {}; 121 | Hooks(Game *game); 122 | 123 | ~Hooks(); 124 | 125 | int initSourceHooks(); 126 | 127 | // Detour functions 128 | static ITexture *__fastcall dGetRenderTarget(void *ecx, void *edx); 129 | static void __fastcall dRenderView(void *ecx, void *edx, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw); 130 | static bool __fastcall dCreateMove(void *ecx, void *edx, float flInputSampleTime, CUserCmd *cmd); 131 | static void __fastcall dEndFrame(void *ecx, void *edx); 132 | static void __fastcall dCalcViewModelView(void *ecx, void *edx, void *owner, const Vector &eyePosition, const QAngle &eyeAngles); 133 | static int dServerFireTerrorBullets(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7); 134 | static int dClientFireTerrorBullets(int playerId, const Vector &vecOrigin, const QAngle &vecAngles, int a4, int a5, int a6, float a7); 135 | static float __fastcall dProcessUsercmds(void *ecx, void *edx, edict_t *player, void *buf, int numcmds, int totalcmds, int dropped_packets, bool ignore, bool paused); 136 | static int dReadUsercmd(void *buf, CUserCmd *move, CUserCmd *from); 137 | static void __fastcall dWriteUsercmdDeltaToBuffer(void *ecx, void *edx, int a1, void *buf, int from, int to, bool isnewcommand); 138 | static int dWriteUsercmd(void *buf, CUserCmd *to, CUserCmd *from); 139 | static void dAdjustEngineViewport(int &x, int &y, int &width, int &height); 140 | static void __fastcall dViewport(void *ecx, void *edx, int x, int y, int width, int height); 141 | static void __fastcall dGetViewport(void *ecx, void *edx, int &x, int &y, int &width, int &height); 142 | static int __fastcall dTestMeleeSwingCollisionClient(void *ecx, void *edx, Vector const &vec); 143 | static int __fastcall dTestMeleeSwingCollisionServer(void *ecx, void *edx, Vector const &vec); 144 | static void __fastcall dDoMeleeSwingServer(void *ecx, void *edx); 145 | static void __fastcall dStartMeleeSwingServer(void *ecx, void *edx, void *player, bool a3); 146 | static int __fastcall dPrimaryAttackServer(void *ecx, void *edx); 147 | static void __fastcall dItemPostFrameServer(void *ecx, void *edx); 148 | static int __fastcall dGetPrimaryAttackActivity(void *ecx, void *edx, void* meleeInfo); 149 | static Vector *__fastcall dEyePosition(void *ecx, void *edx, Vector *eyePos); 150 | static void __fastcall dDrawModelExecute(void *ecx, void* edx, void *state, const ModelRenderInfo_t &info, void *pCustomBoneToWorld); 151 | static void __fastcall dPushRenderTargetAndViewport(void *ecx, void *edx, ITexture *pTexture, ITexture *pDepthTexture, int nViewX, int nViewY, int nViewW, int nViewH); 152 | static void __fastcall dPopRenderTargetAndViewport(void *ecx, void *edx); 153 | static void __fastcall dVGui_Paint(void *ecx, void *edx, int mode); 154 | static int __fastcall dIsSplitScreen(); 155 | static DWORD *__fastcall dPrePushRenderTarget(void *ecx, void *edx, int a2); 156 | 157 | static inline int m_PushHUDStep; 158 | static inline bool m_PushedHud; 159 | }; -------------------------------------------------------------------------------- /L4D2VR/l4d2vr_capsule_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/L4D2VR/l4d2vr_capsule_main.png -------------------------------------------------------------------------------- /L4D2VR/l4d2vr_portrait_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/L4D2VR/l4d2vr_portrait_main.png -------------------------------------------------------------------------------- /L4D2VR/manifest.vrmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "source" : "builtin", 3 | "applications": [{ 4 | "app_key": "steam.app.550", 5 | 6 | "launch_type": "url", 7 | "url": "steam://launch/550/VR", 8 | "action_manifest_path" : "SteamVRActionManifest/action_manifest.json", 9 | "image_path" : "l4d2vr_capsule_main.png", 10 | 11 | "strings": { 12 | "en_us": { 13 | "name": "Left 4 Dead 2 VR", 14 | "description": "Left 4 Dead 2 VR Mod" 15 | } 16 | } 17 | }] 18 | } 19 | -------------------------------------------------------------------------------- /L4D2VR/offsets.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sigscanner.h" 3 | #include "game.h" 4 | 5 | 6 | struct Offset 7 | { 8 | std::string moduleName; 9 | int offset; 10 | int address; 11 | std::string signature; 12 | int sigOffset; 13 | 14 | Offset(std::string moduleName, int currentOffset, std::string signature, int sigOffset = 0) 15 | { 16 | this->moduleName = moduleName; 17 | this->offset = currentOffset; 18 | this->signature = signature; 19 | this->sigOffset = sigOffset; 20 | 21 | int newOffset = SigScanner::VerifyOffset(moduleName, currentOffset, signature, sigOffset); 22 | if (newOffset > 0) 23 | { 24 | this->offset = newOffset; 25 | } 26 | 27 | if (newOffset == -1) 28 | { 29 | Game::errorMsg(("Signature not found: " + signature).c_str()); 30 | return; 31 | } 32 | 33 | this->address = (uintptr_t)GetModuleHandle(moduleName.c_str()) + this->offset; 34 | } 35 | }; 36 | 37 | class Offsets 38 | { 39 | public: 40 | Offset RenderView = { "client.dll", 0x1D6C30, "55 8B EC 81 EC ? ? ? ? 53 56 57 8B D9" }; 41 | Offset g_pClientMode = { "client.dll", 0x228351, "89 04 B5 ? ? ? ? E8", 3 }; 42 | Offset CalcViewModelView = { "client.dll", 0x287270, "55 8B EC 83 EC 48 A1 ? ? ? ? 33 C5 89 45 FC 8B 45 10 8B 10" }; 43 | Offset ClientFireTerrorBullets = { "client.dll", 0x2F4350, "55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 8B 45 08 8B 4D 10"}; 44 | Offset WriteUsercmdDeltaToBuffer = { "client.dll", 0x134790, "55 8B EC 83 EC 60 0F 57 C0 8B 55 0C" }; 45 | Offset WriteUsercmd = { "client.dll", 0x1AAD50, "55 8B EC A1 ? ? ? ? 83 78 30 00 53 8B 5D 10 56 57" }; 46 | Offset g_pppInput = { "client.dll", 0xA8A22, "8B 0D ? ? ? ? 8B 01 8B 50 58 FF E2", 2 }; 47 | Offset AdjustEngineViewport = { "client.dll", 0x31A890, "55 8B EC 8B 0D ? ? ? ? 85 C9 74 17" }; 48 | Offset TestMeleeSwingClient = { "client.dll", 0x30C040, "55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 53 56 8B 75 08 57 8B D9 E8 ? ? ? ? 8B" }; 49 | Offset GetMeleeWeaponInfoClient = { "client.dll", 0x30B570, "8B 81 ? ? ? ? 50 B9 ? ? ? ? E8 ? ? ? ? C3" }; 50 | Offset IsSplitScreen = { "client.dll", 0x1B2A60, "33 C0 83 3D ? ? ? ? ? 0F 9D C0" }; 51 | Offset PrePushRenderTarget = { "client.dll", 0xA8C80, "55 8B EC 8B C1 56 8B 75 08 8B 0E 89 08 8B 56 04 89" }; 52 | 53 | Offset ServerFireTerrorBullets = { "server.dll", 0x3C3FC0, "55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 8B 45 08 8B 4D 10" }; 54 | Offset ReadUserCmd = { "server.dll", 0x205100, "55 8B EC 53 8B 5D 10 56 57 8B 7D 0C 53" }; 55 | Offset ProcessUsercmds = { "server.dll", 0xEF710, "55 8B EC B8 ? ? ? ? E8 ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 8B 45 0C 8B 55 08" }; 56 | Offset CBaseEntity_entindex = { "server.dll", 0x25390, "8B 41 28 85 C0 75 01 C3 8B 0D ? ? ? ? 2B 41 58 C1 F8 04 C3 CC CC CC CC CC CC CC CC CC CC CC 55"}; 57 | Offset TestMeleeSwingServer = { "server.dll", 0x3E79E0, "24 FF D2 5B 5F 5E C3", 20}; 58 | Offset DoMeleeSwingServer = { "server.dll", 0x3E84C0, "55 8B EC 83 EC 3C 53 56 8B F1 E8 ? ? ? ? 8B D8 85" }; 59 | Offset StartMeleeSwingServer = { "server.dll", 0x3E8780, "55 8B EC 53 56 8B F1 8B 86 ? ? ? ? 50 B9 ? ? ? ? E8 ? ? ? ? 8B" }; 60 | Offset PrimaryAttackServer = { "server.dll", 0x3E8AB0, "56 57 8B F1 E8 ? ? ? ? 8B F8 85 FF 0F 84 ? ? ? ? 8B 87 ? ? ? ? 83 F8 FF" }; 61 | Offset ItemPostFrameServer = { "server.dll", 0x3E8BA0, "56 57 8B F1 E8 ? ? ? ? 8B CE E8 ? ? ? ? 8B F8 85 FF 0F 84 ? ? ? ? 53" }; 62 | Offset GetPrimaryAttackActivity = { "server.dll", 0x3E7630, "55 8B EC 53 8B 5D 08 56 57 8B BB ? ? ? ?" }; 63 | Offset GetActiveWeapon = { "server.dll", 0x464F0, "55 8B EC 8B 45 0C 56 8B 75 08 50 56 E8 ? ? ? ? 84 C0 74 47 8B", -64 }; 64 | Offset GetMeleeWeaponInfo = { "server.dll", 0x3E67D0, "8B 81 ? ? ? ? 50 B9 ? ? ? ? E8 ? ? ? ? C3" }; 65 | Offset EyePosition = { "server.dll", 0x6D610, "55 8B EC 56 8B F1 8B 86 ? ? ? ? C1 E8 0B A8 01 74 05 E8 ? ? ? ? 8B 45 08 F3" }; 66 | 67 | Offset GetRenderTarget = { "materialsystem.dll", 0x2CD30, "83 79 4C 00" }; 68 | Offset Viewport = { "materialsystem.dll", 0x2E010, "55 8B EC 83 EC 28 8B C1" }; 69 | Offset GetViewport = { "materialsystem.dll", 0x2D240, "55 8B EC 8B 41 4C 8B 49 40 8D 04 C0 83 7C 81 ? ?" }; 70 | Offset PushRenderTargetAndViewport = { "materialsystem.dll", 0x2D5F0, "55 8B EC 83 EC 24 8B 45 08 8B 55 10 89" }; 71 | Offset PopRenderTargetAndViewport = { "materialsystem.dll", 0x2CE80, "56 8B F1 83 7E 4C 00" }; 72 | 73 | Offset DrawModelExecute = { "engine.dll", 0xE05E0, "55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 8B 45 10 56 8B 75 08 57 8B" }; 74 | Offset VGui_Paint = { "engine.dll", 0x115CE0, "55 8B EC E8 ? ? ? ? 8B 10 8B C8 8B 52 38" }; 75 | }; -------------------------------------------------------------------------------- /L4D2VR/sdk/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/L4D2VR/sdk/LICENSE.txt -------------------------------------------------------------------------------- /L4D2VR/sdk/checksum_crc.cpp: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | // 3 | // Purpose: Generic CRC functions 4 | // 5 | //=============================================================================// 6 | 7 | #include "checksum_crc.h" 8 | 9 | #define CRC32_INIT_VALUE 0xFFFFFFFFUL 10 | #define CRC32_XOR_VALUE 0xFFFFFFFFUL 11 | 12 | #define NUM_BYTES 256 13 | 14 | #define LittleLong( val ) ( val ) 15 | 16 | static const CRC32_t pulCRCTable[NUM_BYTES] = 17 | { 18 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 19 | 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 20 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 21 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 22 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 23 | 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 24 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 25 | 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 26 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 27 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 28 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 29 | 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 30 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 31 | 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 32 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 33 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 34 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 35 | 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 36 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 37 | 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 38 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 39 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 40 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 41 | 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 42 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 43 | 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 44 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 45 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 46 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 47 | 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 48 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 49 | 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 50 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 51 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 52 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 53 | 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 54 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 55 | 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 56 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 57 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 58 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 59 | 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 60 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 61 | 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 62 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 63 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 64 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 65 | 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 66 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 67 | 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 68 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 69 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 70 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 71 | 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 72 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 73 | 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 74 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 75 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 76 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 77 | 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 78 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 79 | 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 80 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 81 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 82 | }; 83 | 84 | void CRC32_Init(CRC32_t *pulCRC) 85 | { 86 | *pulCRC = CRC32_INIT_VALUE; 87 | } 88 | 89 | void CRC32_Final(CRC32_t *pulCRC) 90 | { 91 | *pulCRC ^= CRC32_XOR_VALUE; 92 | } 93 | 94 | CRC32_t CRC32_GetTableEntry( unsigned int slot ) 95 | { 96 | return pulCRCTable[(unsigned char)slot]; 97 | } 98 | 99 | void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *pBuffer, int nBuffer) 100 | { 101 | CRC32_t ulCrc = *pulCRC; 102 | unsigned char *pb = (unsigned char *)pBuffer; 103 | unsigned int nFront; 104 | int nMain; 105 | 106 | JustAfew: 107 | 108 | switch (nBuffer) 109 | { 110 | case 7: 111 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 112 | 113 | case 6: 114 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 115 | 116 | case 5: 117 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 118 | 119 | case 4: 120 | ulCrc ^= LittleLong( *(CRC32_t *)pb ); 121 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 122 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 123 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 124 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 125 | *pulCRC = ulCrc; 126 | return; 127 | 128 | case 3: 129 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 130 | 131 | case 2: 132 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 133 | 134 | case 1: 135 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 136 | 137 | case 0: 138 | *pulCRC = ulCrc; 139 | return; 140 | } 141 | 142 | // We may need to do some alignment work up front, and at the end, so that 143 | // the main loop is aligned and only has to worry about 8 byte at a time. 144 | // 145 | // The low-order two bits of pb and nBuffer in total control the 146 | // upfront work. 147 | // 148 | nFront = ((unsigned int)pb) & 3; 149 | nBuffer -= nFront; 150 | switch (nFront) 151 | { 152 | case 3: 153 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 154 | case 2: 155 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 156 | case 1: 157 | ulCrc = pulCRCTable[*pb++ ^ (unsigned char)ulCrc] ^ (ulCrc >> 8); 158 | } 159 | 160 | nMain = nBuffer >> 3; 161 | while (nMain--) 162 | { 163 | ulCrc ^= LittleLong( *(CRC32_t *)pb ); 164 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 165 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 166 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 167 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 168 | ulCrc ^= LittleLong( *(CRC32_t *)(pb + 4) ); 169 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 170 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 171 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 172 | ulCrc = pulCRCTable[(unsigned char)ulCrc] ^ (ulCrc >> 8); 173 | pb += 8; 174 | } 175 | 176 | nBuffer &= 7; 177 | goto JustAfew; 178 | } 179 | -------------------------------------------------------------------------------- /L4D2VR/sdk/checksum_crc.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | // 3 | // Purpose: Generic CRC functions 4 | // 5 | // $NoKeywords: $ 6 | //=============================================================================// 7 | #ifndef CHECKSUM_CRC_H 8 | #define CHECKSUM_CRC_H 9 | #ifdef _WIN32 10 | #pragma once 11 | #endif 12 | 13 | typedef unsigned int CRC32_t; 14 | 15 | void CRC32_Init( CRC32_t *pulCRC ); 16 | void CRC32_ProcessBuffer( CRC32_t *pulCRC, const void *p, int len ); 17 | void CRC32_Final( CRC32_t *pulCRC ); 18 | CRC32_t CRC32_GetTableEntry( unsigned int slot ); 19 | 20 | inline CRC32_t CRC32_ProcessSingleBuffer( const void *p, int len ) 21 | { 22 | CRC32_t crc; 23 | 24 | CRC32_Init( &crc ); 25 | CRC32_ProcessBuffer( &crc, p, len ); 26 | CRC32_Final( &crc ); 27 | 28 | return crc; 29 | } 30 | 31 | #endif -------------------------------------------------------------------------------- /L4D2VR/sdk/material.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "texture.h" 4 | 5 | enum MaterialRenderTargetDepth_t 6 | { 7 | MATERIAL_RT_DEPTH_SHARED = 0x0, 8 | MATERIAL_RT_DEPTH_SEPARATE = 0x1, 9 | MATERIAL_RT_DEPTH_NONE = 0x2, 10 | MATERIAL_RT_DEPTH_ONLY = 0x3, 11 | }; 12 | 13 | enum MaterialVarFlags_t 14 | { 15 | MATERIAL_VAR_DEBUG = (1 << 0), 16 | MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1), 17 | MATERIAL_VAR_NO_DRAW = (1 << 2), 18 | MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3), 19 | 20 | MATERIAL_VAR_VERTEXCOLOR = (1 << 4), 21 | MATERIAL_VAR_VERTEXALPHA = (1 << 5), 22 | MATERIAL_VAR_SELFILLUM = (1 << 6), 23 | MATERIAL_VAR_ADDITIVE = (1 << 7), 24 | MATERIAL_VAR_ALPHATEST = (1 << 8), 25 | MATERIAL_VAR_MULTIPASS = (1 << 9), 26 | MATERIAL_VAR_ZNEARER = (1 << 10), 27 | MATERIAL_VAR_MODEL = (1 << 11), 28 | MATERIAL_VAR_FLAT = (1 << 12), 29 | MATERIAL_VAR_NOCULL = (1 << 13), 30 | MATERIAL_VAR_NOFOG = (1 << 14), 31 | MATERIAL_VAR_IGNOREZ = (1 << 15), 32 | MATERIAL_VAR_DECAL = (1 << 16), 33 | MATERIAL_VAR_ENVMAPSPHERE = (1 << 17), 34 | MATERIAL_VAR_NOALPHAMOD = (1 << 18), 35 | MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19), 36 | MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20), 37 | MATERIAL_VAR_TRANSLUCENT = (1 << 21), 38 | MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22), 39 | MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23), 40 | MATERIAL_VAR_OPAQUETEXTURE = (1 << 24), 41 | MATERIAL_VAR_ENVMAPMODE = (1 << 25), 42 | MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26), 43 | MATERIAL_VAR_HALFLAMBERT = (1 << 27), 44 | MATERIAL_VAR_WIREFRAME = (1 << 28), 45 | MATERIAL_VAR_ALLOWALPHATOCOVERAGE = (1 << 29), 46 | MATERIAL_VAR_IGNORE_ALPHA_MODULATION = (1 << 30) 47 | }; 48 | 49 | 50 | enum CompiledVtfFlags 51 | { 52 | // flags from the *.txt config file 53 | TEXTUREFLAGS_POINTSAMPLE = 0x00000001, 54 | TEXTUREFLAGS_TRILINEAR = 0x00000002, 55 | TEXTUREFLAGS_CLAMPS = 0x00000004, 56 | TEXTUREFLAGS_CLAMPT = 0x00000008, 57 | TEXTUREFLAGS_ANISOTROPIC = 0x00000010, 58 | TEXTUREFLAGS_HINT_DXT5 = 0x00000020, 59 | TEXTUREFLAGS_SRGB = 0x00000040, 60 | TEXTUREFLAGS_NORMAL = 0x00000080, 61 | TEXTUREFLAGS_NOMIP = 0x00000100, 62 | TEXTUREFLAGS_NOLOD = 0x00000200, 63 | TEXTUREFLAGS_ALL_MIPS = 0x00000400, 64 | TEXTUREFLAGS_PROCEDURAL = 0x00000800, 65 | 66 | // These are automatically generated by vtex from the texture data. 67 | TEXTUREFLAGS_ONEBITALPHA = 0x00001000, 68 | TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000, 69 | 70 | // newer flags from the *.txt config file 71 | TEXTUREFLAGS_ENVMAP = 0x00004000, 72 | TEXTUREFLAGS_RENDERTARGET = 0x00008000, 73 | TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000, 74 | TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000, 75 | TEXTUREFLAGS_SINGLECOPY = 0x00040000, 76 | 77 | TEXTUREFLAGS_STAGING_MEMORY = 0x00080000, 78 | TEXTUREFLAGS_IMMEDIATE_CLEANUP = 0x00100000, 79 | TEXTUREFLAGS_IGNORE_PICMIP = 0x00200000, 80 | TEXTUREFLAGS_UNUSED_00400000 = 0x00400000, 81 | 82 | TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000, 83 | 84 | TEXTUREFLAGS_UNUSED_01000000 = 0x01000000, 85 | 86 | TEXTUREFLAGS_CLAMPU = 0x02000000, 87 | 88 | TEXTUREFLAGS_VERTEXTEXTURE = 0x04000000, // Useable as a vertex texture 89 | 90 | TEXTUREFLAGS_SSBUMP = 0x08000000, 91 | 92 | TEXTUREFLAGS_UNUSED_10000000 = 0x10000000, 93 | 94 | // Clamp to border color on all texture coordinates 95 | TEXTUREFLAGS_BORDER = 0x20000000, 96 | 97 | TEXTUREFLAGS_UNUSED_40000000 = 0x40000000, 98 | TEXTUREFLAGS_UNUSED_80000000 = 0x80000000, 99 | }; 100 | 101 | enum RenderTargetSizeMode_t 102 | { 103 | RT_SIZE_NO_CHANGE = 0, // Only allowed for render targets that don't want a depth buffer 104 | // (because if they have a depth buffer, the render target must be less than or equal to the size of the framebuffer). 105 | RT_SIZE_DEFAULT = 1, // Don't play with the specified width and height other than making sure it fits in the framebuffer. 106 | RT_SIZE_PICMIP = 2, // Apply picmip to the render target's width and height. 107 | RT_SIZE_HDR = 3, // frame_buffer_width / 4 108 | RT_SIZE_FULL_FRAME_BUFFER = 4, // Same size as frame buffer, or next lower power of 2 if we can't do that. 109 | RT_SIZE_OFFSCREEN = 5, // Target of specified size, don't mess with dimensions 110 | RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP = 6, // Same size as the frame buffer, rounded up if necessary for systems that can't do non-power of two textures. 111 | RT_SIZE_REPLAY_SCREENSHOT = 7, // Rounded down to power of 2, essentially... 112 | RT_SIZE_LITERAL = 8, // Use the size passed in. Don't clamp it to the frame buffer size. Really. 113 | RT_SIZE_LITERAL_PICMIP = 9 // Use the size passed in, don't clamp to the frame buffer size, but do apply picmip restrictions. 114 | 115 | }; 116 | 117 | enum PaintMode_t 118 | { 119 | PAINT_UIPANELS = (1 << 0), 120 | PAINT_INGAMEPANELS = (1 << 1), 121 | PAINT_CURSOR = (1 << 2), // software cursor, if appropriate 122 | }; 123 | 124 | class IMatRenderContext; 125 | class IMaterial; 126 | 127 | class IMaterialSystem 128 | { 129 | public: 130 | virtual void ConnectEPFPvPKcPiE() = 0; //CMaterialSystem::Connect(void * (*)(char const*,int *)) 131 | virtual void DisconnectEv() = 0; //CMaterialSystem::Disconnect(void) 132 | virtual void QueryInterfaceEPKc() = 0; //CMaterialSystem::QueryInterface(char const*) 133 | virtual void InitEv() = 0; //CMaterialSystem::Init(void) 134 | virtual void ShutdownEv() = 0; //CMaterialSystem::Shutdown(void) 135 | virtual void InitEPKcP21IMaterialProxyFactoryPFPvS1_PiES7_() = 0; //CMaterialSystem::Init(char const*,IMaterialProxyFactory *,void * (*)(char const*,int *),void * (*)(char const*,int *)) 136 | virtual void SetShaderAPIEPKc() = 0; //CMaterialSystem::SetShaderAPI(char const*) 137 | virtual void SetAdapterEii() = 0; //CMaterialSystem::SetAdapter(int,int) 138 | virtual void ModInitEv() = 0; //CMaterialSystem::ModInit(void) 139 | virtual void ModShutdownEv() = 0; //CMaterialSystem::ModShutdown(void) 140 | virtual void SetThreadModeE20MaterialThreadMode_ti() = 0; //CMaterialSystem::SetThreadMode(MaterialThreadMode_t,int) 141 | virtual void GetThreadModeEv() = 0; //CMaterialSystem::GetThreadMode(void) 142 | virtual void IsRenderThreadSafeEv() = 0; //CMaterialSystem::IsRenderThreadSafe(void) 143 | virtual void ExecuteQueuedEv() = 0; //CMaterialSystem::ExecuteQueued(void) 144 | virtual void GetHardwareConfigEPKcPi() = 0; //CMaterialSystem::GetHardwareConfig(char const*,int *) 145 | virtual void UpdateConfigEb() = 0; //CMaterialSystem::UpdateConfig(bool) 146 | virtual void OverrideConfigERK23MaterialSystem_Config_tb() = 0; //CMaterialSystem::OverrideConfig(MaterialSystem_Config_t const&,bool) 147 | virtual void GetCurrentConfigForVideoCardEv() = 0; //CMaterialSystem::GetCurrentConfigForVideoCard(void) 148 | virtual void GetRecommendedConfigurationInfoEiP9KeyValues() = 0; //CMaterialSystem::GetRecommendedConfigurationInfo(int,KeyValues *) 149 | virtual void GetDisplayAdapterCountEv() = 0; //CMaterialSystem::GetDisplayAdapterCount(void) 150 | virtual void GetCurrentAdapterEv() = 0; //CMaterialSystem::GetCurrentAdapter(void) 151 | virtual void GetDisplayAdapterInfoEiR21MaterialAdapterInfo_t() = 0; //CMaterialSystem::GetDisplayAdapterInfo(int,MaterialAdapterInfo_t &) 152 | virtual void GetModeCountEi() = 0; //CMaterialSystem::GetModeCount(int) 153 | virtual void GetModeInfoEiiR19MaterialVideoMode_t() = 0; //CMaterialSystem::GetModeInfo(int,int,MaterialVideoMode_t &) 154 | virtual void AddModeChangeCallBackEPFvvE() = 0; //CMaterialSystem::AddModeChangeCallBack(void (*)(void)) 155 | virtual void GetDisplayModeER19MaterialVideoMode_t() = 0; //CMaterialSystem::GetDisplayMode(MaterialVideoMode_t &) 156 | virtual void SetModeEPvRK23MaterialSystem_Config_t() = 0; //CMaterialSystem::SetMode(void *,MaterialSystem_Config_t const&) 157 | virtual void SupportsMSAAModeEi() = 0; //CMaterialSystem::SupportsMSAAMode(int) 158 | virtual void GetVideoCardIdentifierEv() = 0; //CMaterialSystem::GetVideoCardIdentifier(void) 159 | virtual void SpewDriverInfoEv() = 0; //CMaterialSystem::SpewDriverInfo(void) 160 | virtual void GetBackBufferDimensions(int &, int &) = 0; //CMaterialSystem::GetBackBufferDimensions(int &,int &) 161 | virtual ImageFormat GetBackBufferFormat() = 0; //CMaterialSystem::GetBackBufferFormat(void) 162 | virtual void SupportsHDRModeE9HDRType_t() = 0; //CMaterialSystem::SupportsHDRMode(HDRType_t) 163 | virtual void AddViewEPv() = 0; //CMaterialSystem::AddView(void *) 164 | virtual void RemoveViewEPv() = 0; //CMaterialSystem::RemoveView(void *) 165 | virtual void SetViewEPv() = 0; //CMaterialSystem::SetView(void *) 166 | virtual void BeginFrameEf() = 0; //CMaterialSystem::BeginFrame(float) 167 | virtual void EndFrameEv() = 0; //CMaterialSystem::EndFrame(void) 168 | virtual void FlushEb() = 0; //CMaterialSystem::Flush(bool) 169 | virtual void SwapBuffersEv() = 0; //CMaterialSystem::SwapBuffers(void) 170 | virtual void EvictManagedResourcesEv() = 0; //CMaterialSystem::EvictManagedResources(void) 171 | virtual void ReleaseResourcesEv() = 0; //CMaterialSystem::ReleaseResources(void) 172 | virtual void ReacquireResourcesEv() = 0; //CMaterialSystem::ReacquireResources(void) 173 | virtual void AddReleaseFuncEPFviE() = 0; //CMaterialSystem::AddReleaseFunc(void (*)(int)) 174 | virtual void RemoveReleaseFuncEPFviE() = 0; //CMaterialSystem::RemoveReleaseFunc(void (*)(int)) 175 | virtual void AddRestoreFuncEPFviE() = 0; //CMaterialSystem::AddRestoreFunc(void (*)(int)) 176 | virtual void RemoveRestoreFuncEPFviE() = 0; //CMaterialSystem::RemoveRestoreFunc(void (*)(int)) 177 | virtual void ResetTempHWMemoryEb() = 0; //CMaterialSystem::ResetTempHWMemory(bool) 178 | virtual void HandleDeviceLostEv() = 0; //CMaterialSystem::HandleDeviceLost(void) 179 | virtual void ShaderCountEv() = 0; //CMaterialSystem::ShaderCount(void) 180 | virtual void GetShadersEiiPP7IShader() = 0; //CMaterialSystem::GetShaders(int,int,IShader **) 181 | virtual void ShaderFlagCountEv() = 0; //CMaterialSystem::ShaderFlagCount(void) 182 | virtual void ShaderFlagNameEi() = 0; //CMaterialSystem::ShaderFlagName(int) 183 | virtual void GetShaderFallbackEPKcPci() = 0; //CMaterialSystem::GetShaderFallback(char const*,char *,int) 184 | virtual void GetMaterialProxyFactoryEv() = 0; //CMaterialSystem::GetMaterialProxyFactory(void) 185 | virtual void SetMaterialProxyFactoryEP21IMaterialProxyFactory() = 0; //CMaterialSystem::SetMaterialProxyFactory(IMaterialProxyFactory *) 186 | virtual void EnableEditorMaterialsEv() = 0; //CMaterialSystem::EnableEditorMaterials(void) 187 | virtual void EnableGBuffersEv() = 0; //CMaterialSystem::EnableGBuffers(void) 188 | virtual void SetInStubModeEb() = 0; //CMaterialSystem::SetInStubMode(bool) 189 | virtual void DebugPrintUsedMaterialsEPKcb() = 0; //CMaterialSystem::DebugPrintUsedMaterials(char const*,bool) 190 | virtual void DebugPrintUsedTexturesEv() = 0; //CMaterialSystem::DebugPrintUsedTextures(void) 191 | virtual void ToggleSuppressMaterialEPKc() = 0; //CMaterialSystem::ToggleSuppressMaterial(char const*) 192 | virtual void ToggleDebugMaterialEPKc() = 0; //CMaterialSystem::ToggleDebugMaterial(char const*) 193 | virtual void UsingFastClippingEv() = 0; //CMaterialSystem::UsingFastClipping(void) 194 | virtual void StencilBufferBitsEv() = 0; //CMaterialSystem::StencilBufferBits(void) 195 | virtual void UncacheAllMaterialsEv() = 0; //CMaterialSystem::UncacheAllMaterials(void) 196 | virtual void UncacheUnusedMaterialsEb() = 0; //CMaterialSystem::UncacheUnusedMaterials(bool) 197 | virtual void CacheUsedMaterialsEv() = 0; //CMaterialSystem::CacheUsedMaterials(void) 198 | virtual void ReloadTexturesEv() = 0; //CMaterialSystem::ReloadTextures(void) 199 | virtual void ReloadMaterialsEPKc() = 0; //CMaterialSystem::ReloadMaterials(char const*) 200 | virtual void CreateMaterialEPKcP9KeyValues() = 0; //CMaterialSystem::CreateMaterial(char const*,KeyValues *) 201 | virtual IMaterial *FindMaterial(char const *pMaterialName, const char *pTextureGroupName, bool complain = true, const char *pComplainPrefix = NULL) = 0; //CMaterialSystem::FindMaterial(char const*,char const*,bool,char const*) 202 | virtual void FirstMaterialEv() = 0; //CMaterialSystem::FirstMaterial(void) 203 | virtual void NextMaterialEt() = 0; //CMaterialSystem::NextMaterial(ushort) 204 | virtual void InvalidMaterialEv() = 0; //CMaterialSystem::InvalidMaterial(void) 205 | virtual void GetMaterialEt() = 0; //CMaterialSystem::GetMaterial(ushort) 206 | virtual void GetNumMaterialsEv() = 0; //CMaterialSystem::GetNumMaterials(void) 207 | virtual void FindTextureEPKcS1_bi() = 0; //CMaterialSystem::FindTexture(char const*,char const*,bool,int) 208 | virtual void IsTextureLoadedEPKc() = 0; //CMaterialSystem::IsTextureLoaded(char const*) 209 | virtual void CreateProceduralTextureEPKcS1_ii11ImageFormati() = 0; //CMaterialSystem::CreateProceduralTexture(char const*,char const*,int,int,ImageFormat,int) 210 | virtual void BeginRenderTargetAllocation() = 0; //CMaterialSystem::BeginRenderTargetAllocation(void) 211 | virtual void EndRenderTargetAllocation() = 0; //CMaterialSystem::EndRenderTargetAllocation(void) 212 | virtual void *CreateRenderTargetTexture(int, int, RenderTargetSizeMode_t, ImageFormat, MaterialRenderTargetDepth_t) = 0; //CMaterialSystem::CreateRenderTargetTexture(int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t) 213 | virtual ITexture *CreateNamedRenderTargetTextureEx(const char *pRTName, // Pass in NULL here for an unnamed render target. 214 | int w, 215 | int h, 216 | RenderTargetSizeMode_t sizeMode, // Controls how size is generated (and regenerated on video mode change). 217 | ImageFormat format, 218 | MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, 219 | unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, 220 | unsigned int renderTargetFlags = 0) = 0; //CMaterialSystem::CreateNamedRenderTargetTextureEx(char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,uint,uint) 221 | virtual void *CreateNamedRenderTargetTexture(char const *, int, int, RenderTargetSizeMode_t, ImageFormat, MaterialRenderTargetDepth_t, bool, bool) = 0; //CMaterialSystem::CreateNamedRenderTargetTexture(char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,bool,bool) 222 | virtual ITexture *CreateNamedRenderTargetTextureEx2(const char *pRTName, // Pass in NULL here for an unnamed render target. 223 | int w, 224 | int h, 225 | RenderTargetSizeMode_t sizeMode, // Controls how size is generated (and regenerated on video mode change). 226 | ImageFormat format, 227 | MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, 228 | unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, 229 | unsigned int renderTargetFlags = 0) = 0; //CMaterialSystem::CreateNamedRenderTargetTextureEx2(char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,uint,uint) 230 | virtual void BeginLightmapAllocationEv() = 0; //CMaterialSystem::BeginLightmapAllocation(void) 231 | virtual void EndLightmapAllocationEv() = 0; //CMaterialSystem::EndLightmapAllocation(void) 232 | virtual void AllocateLightmapEiiPiP9IMaterial() = 0; //CMaterialSystem::AllocateLightmap(int,int,int *,IMaterial *) 233 | virtual void AllocateWhiteLightmapEP9IMaterial() = 0; //CMaterialSystem::AllocateWhiteLightmap(IMaterial *) 234 | virtual void UpdateLightmapEiPiS0_PfS1_S1_S1_() = 0; //CMaterialSystem::UpdateLightmap(int,int *,int *,float *,float *,float *,float *) 235 | virtual void GetNumSortIDsEv() = 0; //CMaterialSystem::GetNumSortIDs(void) 236 | virtual void GetSortInfoEP25MaterialSystem_SortInfo_t() = 0; //CMaterialSystem::GetSortInfo(MaterialSystem_SortInfo_t *) 237 | virtual void GetLightmapPageSizeEiPiS0_() = 0; //CMaterialSystem::GetLightmapPageSize(int,int *,int *) 238 | virtual void ResetMaterialLightmapPageInfoEv() = 0; //CMaterialSystem::ResetMaterialLightmapPageInfo(void) 239 | virtual void ClearBuffersEbbb() = 0; //CMaterialSystem::ClearBuffers(bool,bool,bool) 240 | virtual IMatRenderContext *GetRenderContext() = 0; //CMaterialSystem::GetRenderContext(void) 241 | 242 | char pad_0004[10932]; //0x0004 243 | bool isGameRunning; //0x2AB8 244 | }; //Size: 0x2ABC 245 | static_assert(sizeof(IMaterialSystem) == 0x2ABC); 246 | 247 | -------------------------------------------------------------------------------- /L4D2VR/sdk/sdk_server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Server_WeaponCSBase 4 | { 5 | public: 6 | virtual void sub_1024E9C0() = 0; 7 | virtual void sub_100575D0() = 0; 8 | virtual void sub_1002C080() = 0; 9 | virtual void sub_1002C000() = 0; 10 | virtual void sub_1002C010() = 0; 11 | virtual void sub_1002C020() = 0; 12 | virtual void sub_1002C210() = 0; 13 | virtual void sub_1002C040() = 0; 14 | virtual void sub_1002C960() = 0; 15 | virtual void sub_1024DBE0() = 0; 16 | virtual void sub_1024DBF0() = 0; 17 | virtual void sub_1024DC00() = 0; 18 | virtual void sub_10039710() = 0; 19 | virtual void sub_1002C030() = 0; 20 | virtual void sub_1002C060() = 0; 21 | virtual void sub_100334A0() = 0; 22 | virtual void sub_10033590() = 0; 23 | virtual void nullsub_118() = 0; 24 | virtual void sub_1006D720() = 0; 25 | virtual void sub_10062F60() = 0; 26 | virtual void sub_10056BB0() = 0; 27 | virtual void sub_100498E0() = 0; 28 | virtual void sub_10031920() = 0; 29 | virtual void sub_1006D300() = 0; 30 | virtual void sub_1024EF60() = 0; 31 | virtual void sub_1002BA90() = 0; 32 | virtual void sub_1024DCD0() = 0; 33 | virtual void sub_10038980() = 0; 34 | virtual void nullsub_120() = 0; 35 | virtual void sub_100556A0() = 0; 36 | virtual void nullsub_80() = 0; 37 | virtual void sub_10052F60() = 0; 38 | virtual void sub_1006D160() = 0; 39 | virtual void sub_1006D0F0() = 0; 40 | virtual void sub_1024E0F0() = 0; 41 | virtual void sub_1006DED0() = 0; 42 | virtual void sub_1004B220() = 0; 43 | virtual void sub_10065540() = 0; 44 | virtual void sub_10066160() = 0; 45 | virtual void sub_1002BAC0() = 0; 46 | virtual void sub_1004A670() = 0; 47 | virtual void sub_1002C0A0() = 0; 48 | virtual void sub_1002BAD0() = 0; 49 | virtual void sub_1002BAE0() = 0; 50 | virtual void sub_1005EEA0() = 0; 51 | virtual void sub_1002BAF0() = 0; 52 | virtual void sub_1005D5F0() = 0; 53 | virtual void sub_100337A0() = 0; 54 | virtual void sub_10052F40() = 0; 55 | virtual void sub_100319D0() = 0; 56 | virtual void sub_100514C0() = 0; 57 | virtual void sub_1005EDA0() = 0; 58 | virtual void sub_10036670() = 0; 59 | virtual void sub_100345E0() = 0; 60 | virtual void sub_1002BB00() = 0; 61 | virtual void sub_1002BB10() = 0; 62 | virtual void sub_1002BB20() = 0; 63 | virtual void sub_10050A30() = 0; 64 | virtual void sub_10050A60() = 0; 65 | virtual void sub_10036530() = 0; 66 | virtual void sub_1002BB60() = 0; 67 | virtual void sub_10051D90() = 0; 68 | virtual void sub_10063B80() = 0; 69 | virtual void sub_10051330() = 0; 70 | virtual void nullsub_123() = 0; 71 | virtual void sub_1002C6B0() = 0; 72 | virtual void sub_10051340() = 0; 73 | virtual void sub_1002BB80() = 0; 74 | virtual void sub_1006D260() = 0; 75 | virtual void sub_10052D90() = 0; 76 | virtual void sub_1006F9D0() = 0; 77 | virtual void sub_1002BBB0() = 0; 78 | virtual void sub_10059AB0() = 0; 79 | virtual void sub_10059A10() = 0; 80 | virtual void sub_1002C220() = 0; 81 | virtual void sub_10059F80() = 0; 82 | virtual void nullsub_124() = 0; 83 | virtual void sub_1006D2F0() = 0; 84 | virtual void sub_1002BBD0() = 0; 85 | virtual void sub_1002BBE0() = 0; 86 | virtual void sub_1002BBF0() = 0; 87 | virtual void sub_1002BC00() = 0; 88 | virtual void sub_1002BC10() = 0; 89 | virtual void sub_1002BC20() = 0; 90 | virtual void sub_10051630() = 0; 91 | virtual void sub_1006D8C0() = 0; 92 | virtual void sub_1006D740() = 0; 93 | virtual void sub_1006D7C0() = 0; 94 | virtual void sub_1002BC30() = 0; 95 | virtual void sub_10052AF0() = 0; 96 | virtual void sub_1002BC40() = 0; 97 | virtual void sub_1002BC50() = 0; 98 | virtual void sub_1002BC60() = 0; 99 | virtual void sub_1002BC70() = 0; 100 | virtual void sub_1002BC80() = 0; 101 | virtual void sub_1002BC90() = 0; 102 | virtual void sub_10050750() = 0; 103 | virtual void sub_10050760() = 0; 104 | virtual void sub_1002BCC0() = 0; 105 | virtual void sub_10056A30() = 0; 106 | virtual void sub_10060EF0() = 0; 107 | virtual void sub_1005EDC0() = 0; 108 | virtual void sub_1002C1A0() = 0; 109 | virtual void sub_1002BCD0() = 0; 110 | virtual void sub_1002BD00() = 0; 111 | virtual void sub_1002BCF0() = 0; 112 | virtual void sub_1024E420() = 0; 113 | virtual void sub_100562B0() = 0; 114 | virtual void sub_10056310() = 0; 115 | virtual void sub_10056390() = 0; 116 | virtual void nullsub_125() = 0; 117 | virtual void sub_100563F0() = 0; 118 | virtual void nullsub_126() = 0; 119 | virtual void sub_1014E070() = 0; 120 | virtual void nullsub_127() = 0; 121 | virtual void sub_10065A20() = 0; 122 | virtual void nullsub_128() = 0; 123 | virtual void sub_10054850() = 0; 124 | virtual void sub_10031090() = 0; 125 | virtual void nullsub_7() = 0; 126 | virtual void sub_1004B380() = 0; 127 | virtual void sub_1006D2D0() = 0; 128 | virtual void sub_10070AE0() = 0; 129 | virtual void sub_1006D2B0() = 0; 130 | virtual void sub_1024E330() = 0; 131 | virtual void sub_1002BD60() = 0; 132 | virtual void sub_1002C1F0() = 0; 133 | virtual void sub_100306C0() = 0; 134 | virtual void nullsub_129() = 0; 135 | virtual void nullsub_130() = 0; 136 | virtual void nullsub_131() = 0; 137 | virtual void nullsub_132() = 0; 138 | virtual void nullsub_133() = 0; 139 | virtual void nullsub_134() = 0; 140 | virtual void nullsub_135() = 0; 141 | virtual void nullsub_136() = 0; 142 | virtual void nullsub_137() = 0; 143 | virtual void sub_10051740() = 0; 144 | virtual void sub_1002BE00() = 0; 145 | virtual void nullsub_138() = 0; 146 | virtual void sub_1006D610() = 0; 147 | virtual void sub_1006D670() = 0; 148 | virtual void sub_1006DEC0() = 0; 149 | virtual void sub_1006D040() = 0; 150 | virtual void sub_10050D50() = 0; 151 | virtual void sub_10050D80() = 0; 152 | virtual void sub_1005F6F0() = 0; 153 | virtual void sub_1006D690() = 0; 154 | virtual void sub_1006F7F0() = 0; 155 | virtual void sub_1002BFE0() = 0; 156 | virtual void sub_100336D0() = 0; 157 | virtual void sub_1002C200() = 0; 158 | virtual void sub_100568D0() = 0; 159 | virtual void sub_10056790() = 0; 160 | virtual void sub_1002BE20() = 0; 161 | virtual void sub_10059EA0() = 0; 162 | virtual void sub_10059F10() = 0; 163 | virtual void nullsub_139() = 0; 164 | virtual void sub_1002BE40() = 0; 165 | virtual void sub_1024E470() = 0; 166 | virtual void nullsub_140() = 0; 167 | virtual void sub_1006F360() = 0; 168 | virtual void sub_10051490() = 0; 169 | virtual void sub_1006D230() = 0; 170 | virtual void sub_1002BE90() = 0; 171 | virtual void sub_1006D200() = 0; 172 | virtual void sub_100708A0() = 0; 173 | virtual void sub_10052910() = 0; 174 | virtual void nullsub_141() = 0; 175 | virtual void nullsub_142() = 0; 176 | virtual void sub_10056610() = 0; 177 | virtual void sub_10051230() = 0; 178 | virtual void sub_1005EB40() = 0; 179 | virtual void sub_10052D60() = 0; 180 | virtual void sub_100512B0() = 0; 181 | virtual void sub_1002BEB0() = 0; 182 | virtual void sub_1002BEC0() = 0; 183 | virtual void sub_10147360() = 0; 184 | virtual void sub_1014C220() = 0; 185 | virtual void nullsub_143() = 0; 186 | virtual void sub_100325A0() = 0; 187 | virtual void sub_100325E0() = 0; 188 | virtual void sub_1002BED0() = 0; 189 | virtual void nullsub_144() = 0; 190 | virtual void nullsub_145() = 0; 191 | virtual void nullsub_146() = 0; 192 | virtual void nullsub_147() = 0; 193 | virtual void nullsub_148() = 0; 194 | virtual void nullsub_149() = 0; 195 | virtual void nullsub_150() = 0; 196 | virtual void nullsub_151() = 0; 197 | virtual void nullsub_152() = 0; 198 | virtual void nullsub_153() = 0; 199 | virtual void nullsub_154() = 0; 200 | virtual void nullsub_155() = 0; 201 | virtual void nullsub_156() = 0; 202 | virtual void nullsub_157() = 0; 203 | virtual void nullsub_158() = 0; 204 | virtual void nullsub_159() = 0; 205 | virtual void sub_10063F90() = 0; 206 | virtual void sub_10030580() = 0; 207 | virtual void sub_10030590() = 0; 208 | virtual void sub_10038450() = 0; 209 | virtual void nullsub_171() = 0; 210 | virtual void nullsub_172() = 0; 211 | virtual void sub_10036560() = 0; 212 | virtual void sub_10031F40() = 0; 213 | virtual void sub_10031A00() = 0; 214 | virtual void sub_10036570() = 0; 215 | virtual void sub_100368B0() = 0; 216 | virtual void sub_10030F50() = 0; 217 | virtual void sub_10031DE0() = 0; 218 | virtual void sub_10039720() = 0; 219 | virtual void sub_100351F0() = 0; 220 | virtual void sub_10036B20() = 0; 221 | virtual void sub_10035A40() = 0; 222 | virtual void sub_10034F20() = 0; 223 | virtual void sub_10049E30() = 0; 224 | virtual void nullsub_87() = 0; 225 | virtual void sub_10032840() = 0; 226 | virtual void sub_10035F80() = 0; 227 | virtual void sub_100331B0() = 0; 228 | virtual void sub_10036590() = 0; 229 | virtual void sub_10034420() = 0; 230 | virtual void sub_100344C0() = 0; 231 | virtual void sub_10034550() = 0; 232 | virtual void sub_100365A0() = 0; 233 | virtual void sub_100365B0() = 0; 234 | virtual void nullsub_173() = 0; 235 | virtual void sub_10037600() = 0; 236 | virtual void sub_100374E0() = 0; 237 | virtual void sub_10036660() = 0; 238 | virtual void sub_1024DC10() = 0; 239 | virtual void sub_10050780() = 0; 240 | virtual void sub_10050790() = 0; 241 | virtual void sub_1004F160() = 0; 242 | virtual void sub_1024F840() = 0; 243 | virtual void sub_1004D4D0() = 0; 244 | virtual void sub_1004AB70() = 0; 245 | virtual void sub_1004AB80() = 0; 246 | virtual void sub_1004ABA0() = 0; 247 | virtual void sub_1004B2C0() = 0; 248 | virtual void sub_1004B880() = 0; 249 | virtual void sub_1024DDC0() = 0; 250 | virtual void sub_1004B560() = 0; 251 | virtual void sub_1004B5B0() = 0; 252 | virtual void sub_1004B690() = 0; 253 | virtual void sub_1004B6F0() = 0; 254 | virtual void sub_1004B7A0() = 0; 255 | virtual void sub_1004B820() = 0; 256 | virtual void sub_1004D540() = 0; 257 | virtual void sub_1024DC40() = 0; 258 | virtual void sub_1004B8E0() = 0; 259 | virtual void sub_100507A0() = 0; 260 | virtual void sub_1004B9E0() = 0; 261 | virtual void sub_1004AE80() = 0; 262 | virtual void sub_1004D280() = 0; 263 | virtual void sub_1004AEA0() = 0; 264 | virtual void sub_1004BA80() = 0; 265 | virtual void sub_1004BAD0() = 0; 266 | virtual void sub_1004BB50() = 0; 267 | virtual void sub_100507B0() = 0; 268 | virtual void sub_1024EB40() = 0; 269 | virtual void sub_1024E160() = 0; 270 | virtual void sub_1024EE40() = 0; 271 | virtual void sub_1024DD60() = 0; 272 | virtual void sub_100507D0() = 0; 273 | virtual void sub_1004F3E0() = 0; 274 | virtual void sub_1004BBD0() = 0; 275 | virtual void sub_1004D590() = 0; 276 | virtual void sub_1004ABB0() = 0; 277 | virtual void sub_1004C850() = 0; 278 | virtual void sub_1024F220() = 0; 279 | virtual void sub_1004DC90() = 0; 280 | virtual void nullsub_192() = 0; 281 | virtual void sub_1004ACA0() = 0; 282 | virtual void sub_1004ABD0() = 0; 283 | virtual void sub_100507F0() = 0; 284 | virtual void sub_1004E0C0() = 0; 285 | virtual void sub_1004E3F0() = 0; 286 | virtual void sub_1004E600() = 0; 287 | virtual void sub_1024EEE0() = 0; 288 | virtual void sub_1004E640() = 0; 289 | virtual void sub_1024EA00() = 0; 290 | virtual void sub_1004C0F0() = 0; 291 | virtual void sub_1004F960() = 0; 292 | virtual void sub_1004ACD0() = 0; 293 | virtual void sub_1004ACE0() = 0; 294 | virtual void sub_1004ABC0() = 0; 295 | virtual void sub_1004AC90() = 0; 296 | virtual void sub_1024DEA0() = 0; 297 | virtual void sub_1004AC40() = 0; 298 | virtual void sub_10050820() = 0; 299 | virtual void sub_1024DE60() = 0; 300 | virtual void sub_10050850() = 0; 301 | virtual void sub_1004AC60() = 0; 302 | virtual void sub_10050860() = 0; 303 | virtual void sub_10050870() = 0; 304 | virtual void sub_10050880() = 0; 305 | virtual void sub_10050890() = 0; 306 | virtual void sub_100508A0() = 0; 307 | virtual void sub_1004BDA0() = 0; 308 | virtual void sub_1004C000() = 0; 309 | virtual void sub_1004AC50() = 0; 310 | virtual void sub_100508E0() = 0; 311 | virtual void sub_100508F0() = 0; 312 | virtual void sub_10050900() = 0; 313 | virtual void sub_10050910() = 0; 314 | virtual void sub_10050920() = 0; 315 | virtual void sub_1004D2E0() = 0; 316 | virtual void nullsub_194() = 0; 317 | virtual void sub_1004AF80() = 0; 318 | virtual void sub_1024FB00() = 0; 319 | virtual void nullsub_411() = 0; 320 | virtual void sub_1024E000() = 0; 321 | virtual void sub_1004AD00() = 0; 322 | virtual void sub_1004AD10() = 0; 323 | virtual void sub_10050950() = 0; 324 | virtual void sub_10050960() = 0; 325 | virtual void sub_10050970() = 0; 326 | virtual void sub_1024DC60() = 0; 327 | virtual void sub_1004A7B0() = 0; 328 | virtual void sub_1004A7D0() = 0; 329 | virtual void sub_1004A810() = 0; 330 | virtual void sub_1004A830() = 0; 331 | virtual void sub_1004A850() = 0; 332 | virtual void sub_1004A870() = 0; 333 | virtual void sub_1004A8E0() = 0; 334 | virtual void sub_1004A900() = 0; 335 | virtual void sub_1004A920() = 0; 336 | virtual void sub_1004A940() = 0; 337 | virtual void sub_1004A960() = 0; 338 | virtual void sub_1004A980() = 0; 339 | virtual void sub_1004A9A0() = 0; 340 | virtual void sub_1004A7F0() = 0; 341 | virtual void sub_1004AB20() = 0; 342 | virtual void sub_1004AB50() = 0; 343 | virtual void sub_1004A890() = 0; 344 | virtual void sub_1004A8C0() = 0; 345 | virtual void sub_1004A8B0() = 0; 346 | virtual void nullsub_196() = 0; 347 | virtual void sub_1004A760() = 0; 348 | virtual void sub_10050A10() = 0; 349 | virtual void sub_10050A20() = 0; 350 | virtual void sub_1004A9C0() = 0; 351 | virtual void sub_1004A9E0() = 0; 352 | virtual void sub_1004AA00() = 0; 353 | virtual void sub_1004AA20() = 0; 354 | virtual void sub_1004AA40() = 0; 355 | virtual void sub_1004AAA0() = 0; 356 | virtual void sub_1004AAC0() = 0; 357 | virtual void sub_1004AAE0() = 0; 358 | virtual void sub_1004AB00() = 0; 359 | virtual void sub_1004AA60() = 0; 360 | virtual void sub_1004AA80() = 0; 361 | virtual void sub_1004AD20() = 0; 362 | virtual void sub_10050990() = 0; 363 | virtual void sub_100509A0() = 0; 364 | virtual void sub_1004AC70() = 0; 365 | virtual void sub_1004AC80() = 0; 366 | virtual void sub_1004A450() = 0; 367 | virtual void sub_1004A5D0() = 0; 368 | virtual void sub_1024FA60() = 0; 369 | virtual void nullsub_412() = 0; 370 | virtual void sub_100499A0() = 0; 371 | virtual void sub_100499F0() = 0; 372 | virtual void sub_100509B0() = 0; 373 | virtual void sub_1004A0F0() = 0; 374 | virtual void sub_10049900() = 0; 375 | virtual void sub_10049E70() = 0; 376 | virtual void sub_10049980() = 0; 377 | virtual void sub_10049990() = 0; 378 | virtual void sub_10049C00() = 0; 379 | virtual void sub_10049D80() = 0; 380 | virtual void nullsub_197() = 0; 381 | virtual void sub_100509D0() = 0; 382 | virtual void sub_100509E0() = 0; 383 | virtual void sub_100509F0() = 0; 384 | virtual void sub_10050A00() = 0; 385 | virtual void sub_1004BD00() = 0; 386 | virtual void nullsub_413() = 0; 387 | virtual void sub_1024DEC0() = 0; 388 | virtual void sub_1024E6D0() = 0; 389 | virtual void sub_1024E1B0() = 0; 390 | virtual void sub_1024E8C0() = 0; 391 | virtual void sub_1024E1E0() = 0; 392 | virtual void sub_1024C4E0() = 0; 393 | virtual void sub_1024E8D0() = 0; 394 | virtual void unknown_libname_15() = 0; 395 | virtual void sub_1024D9B0() = 0; 396 | virtual void sub_1024C4F0() = 0; 397 | virtual void sub_1024E8F0() = 0; 398 | virtual void sub_1024DC20() = 0; 399 | virtual void sub_1024C500() = 0; 400 | virtual void sub_1024C510() = 0; 401 | virtual void nullsub_414() = 0; 402 | virtual void sub_1024E150() = 0; 403 | virtual int GetWeaponID() = 0; 404 | virtual void sub_1024C540() = 0; 405 | virtual void sub_1024EDE0() = 0; 406 | virtual void sub_1024C550() = 0; 407 | virtual void sub_1024C560() = 0; 408 | virtual void sub_1024E5D0() = 0; 409 | virtual void sub_1024C570() = 0; 410 | virtual void sub_1024DD20() = 0; 411 | virtual void sub_1024C5C0() = 0; 412 | virtual void sub_1024DD10() = 0; 413 | virtual void sub_1024EFF0() = 0; 414 | virtual void sub_1024C580() = 0; 415 | virtual void sub_1024C590() = 0; 416 | virtual void sub_1024C5A0() = 0; 417 | virtual void sub_1024C5B0() = 0; 418 | 419 | char pad_0000[6124]; //0x0000 420 | int entitiesHitThisSwing; //0x17F0 421 | }; //Size: 0x17F4 422 | static_assert(sizeof(Server_WeaponCSBase) == 0x17F4); 423 | 424 | class Server_BaseEntity 425 | { 426 | public: 427 | virtual void sub_10060B30() = 0; 428 | virtual void sub_100575D0() = 0; 429 | virtual void sub_1002C080() = 0; 430 | virtual void sub_1002C000() = 0; 431 | virtual void sub_1002C010() = 0; 432 | virtual void sub_1002C020() = 0; 433 | virtual void sub_1002C210() = 0; 434 | virtual void sub_1002C040() = 0; 435 | virtual void sub_1002C960() = 0; 436 | virtual void sub_10050CF0() = 0; 437 | virtual void sub_10050D00() = 0; 438 | virtual void sub_100510D0() = 0; 439 | virtual void sub_1006D010() = 0; 440 | virtual void sub_1002C030() = 0; 441 | virtual void sub_1002C060() = 0; 442 | virtual void sub_10051500() = 0; 443 | virtual void sub_10051510() = 0; 444 | virtual void nullsub_118() = 0; 445 | virtual void sub_1006D720() = 0; 446 | virtual void sub_10062F60() = 0; 447 | virtual void sub_10056BB0() = 0; 448 | virtual void sub_10056AC0() = 0; 449 | virtual void sub_10056C60() = 0; 450 | virtual void sub_1006D300() = 0; 451 | virtual void sub_1005A230() = 0; 452 | virtual void sub_1002BA90() = 0; 453 | virtual void nullsub_119() = 0; 454 | virtual void sub_10051690() = 0; 455 | virtual void nullsub_120() = 0; 456 | virtual void sub_100556A0() = 0; 457 | virtual void nullsub_80() = 0; 458 | virtual void sub_10052F60() = 0; 459 | virtual void sub_1006D160() = 0; 460 | virtual void sub_1006D0F0() = 0; 461 | virtual void sub_10070300() = 0; 462 | virtual void sub_1006DED0() = 0; 463 | virtual void sub_100659B0() = 0; 464 | virtual void sub_10065540() = 0; 465 | virtual void sub_10066160() = 0; 466 | virtual void sub_1002BAC0() = 0; 467 | virtual void sub_100561E0() = 0; 468 | virtual void sub_1002C0A0() = 0; 469 | virtual void sub_1002BAD0() = 0; 470 | virtual void sub_1002BAE0() = 0; 471 | virtual void sub_1005EEA0() = 0; 472 | virtual void sub_1002BAF0() = 0; 473 | virtual void sub_1005D5F0() = 0; 474 | virtual void sub_1005DB60() = 0; 475 | virtual void sub_10052F40() = 0; 476 | virtual void sub_1006B950() = 0; 477 | virtual void sub_100514C0() = 0; 478 | virtual void sub_1005EDA0() = 0; 479 | virtual void sub_10060C70() = 0; 480 | virtual void sub_100601B0() = 0; 481 | virtual void sub_1002BB00() = 0; 482 | virtual void sub_1002BB10() = 0; 483 | virtual void sub_1002BB20() = 0; 484 | virtual void nullsub_121() = 0; 485 | virtual void nullsub_122() = 0; 486 | virtual void sub_1002BB50() = 0; 487 | virtual void sub_1002BB60() = 0; 488 | virtual void sub_10051D90() = 0; 489 | virtual void sub_10063B80() = 0; 490 | virtual void sub_10051330() = 0; 491 | virtual void nullsub_123() = 0; 492 | virtual void sub_1002C6B0() = 0; 493 | virtual void sub_10051340() = 0; 494 | virtual void sub_1002BB80() = 0; 495 | virtual void sub_1006D260() = 0; 496 | virtual void sub_10052D90() = 0; 497 | virtual void sub_1006F9D0() = 0; 498 | virtual void sub_1002BBB0() = 0; 499 | virtual void sub_10059AB0() = 0; 500 | virtual void sub_10059A10() = 0; 501 | virtual void sub_1002C220() = 0; 502 | virtual void sub_10059F80() = 0; 503 | virtual void nullsub_124() = 0; 504 | virtual void sub_1006D2F0() = 0; 505 | virtual void sub_1002BBD0() = 0; 506 | virtual void sub_1002BBE0() = 0; 507 | virtual void sub_1002BBF0() = 0; 508 | virtual void sub_1002BC00() = 0; 509 | virtual void sub_1002BC10() = 0; 510 | virtual void sub_1002BC20() = 0; 511 | virtual void sub_10051630() = 0; 512 | virtual void sub_1006D8C0() = 0; 513 | virtual void sub_1006D740() = 0; 514 | virtual void sub_1006D7C0() = 0; 515 | virtual void sub_1002BC30() = 0; 516 | virtual void sub_10052AF0() = 0; 517 | virtual void sub_1002BC40() = 0; 518 | virtual void sub_1002BC50() = 0; 519 | virtual void sub_1002BC60() = 0; 520 | virtual void sub_1002BC70() = 0; 521 | virtual void sub_1002BC80() = 0; 522 | virtual void sub_1002BC90() = 0; 523 | virtual void sub_1002BCA0() = 0; 524 | virtual void sub_1002BCB0() = 0; 525 | virtual void sub_1002BCC0() = 0; 526 | virtual void sub_10056A30() = 0; 527 | virtual void sub_10060EF0() = 0; 528 | virtual void sub_1005EDC0() = 0; 529 | virtual void sub_1002C1A0() = 0; 530 | virtual void sub_1002BCD0() = 0; 531 | virtual void sub_1002BD00() = 0; 532 | virtual void sub_1002BCF0() = 0; 533 | virtual void sub_10056470() = 0; 534 | virtual void sub_100562B0() = 0; 535 | virtual void sub_10056310() = 0; 536 | virtual void sub_10056390() = 0; 537 | virtual void nullsub_125() = 0; 538 | virtual void sub_100563F0() = 0; 539 | virtual void nullsub_126() = 0; 540 | virtual void sub_1014E070() = 0; 541 | virtual void nullsub_127() = 0; 542 | virtual void sub_10065A20() = 0; 543 | virtual void nullsub_128() = 0; 544 | virtual void sub_10054850() = 0; 545 | virtual void sub_10066620() = 0; 546 | virtual void nullsub_7() = 0; 547 | virtual void sub_1006DB90() = 0; 548 | virtual void sub_1006D2D0() = 0; 549 | virtual void sub_10070AE0() = 0; 550 | virtual void sub_1006D2B0() = 0; 551 | virtual void sub_1002BD50() = 0; 552 | virtual void sub_1002BD60() = 0; 553 | virtual void sub_1002C1F0() = 0; 554 | virtual void sub_10061150() = 0; 555 | virtual void nullsub_129() = 0; 556 | virtual void nullsub_130() = 0; 557 | virtual void nullsub_131() = 0; 558 | virtual void nullsub_132() = 0; 559 | virtual void nullsub_133() = 0; 560 | virtual void nullsub_134() = 0; 561 | virtual void nullsub_135() = 0; 562 | virtual void nullsub_136() = 0; 563 | virtual void nullsub_137() = 0; 564 | virtual void sub_10051740() = 0; 565 | virtual void sub_1002BE00() = 0; 566 | virtual void nullsub_138() = 0; 567 | virtual Vector EyePosition() = 0; 568 | virtual void sub_1006D670() = 0; 569 | virtual void sub_1006DEC0() = 0; 570 | virtual void sub_1006D040() = 0; 571 | virtual void sub_10050D50() = 0; 572 | virtual void sub_10050D80() = 0; 573 | virtual void sub_1005F6F0() = 0; 574 | virtual void sub_1006D690() = 0; 575 | virtual void sub_1006F7F0() = 0; 576 | virtual void sub_1002BFE0() = 0; 577 | virtual void sub_1005F630() = 0; 578 | virtual void sub_1002C200() = 0; 579 | virtual void sub_100568D0() = 0; 580 | virtual void sub_10056790() = 0; 581 | virtual void sub_1002BE20() = 0; 582 | virtual void sub_10059EA0() = 0; 583 | virtual void sub_10059F10() = 0; 584 | virtual void nullsub_139() = 0; 585 | virtual void sub_1002BE40() = 0; 586 | virtual void sub_1002BE70() = 0; 587 | virtual void nullsub_140() = 0; 588 | virtual void sub_1006F360() = 0; 589 | virtual void sub_10051490() = 0; 590 | virtual void sub_1006D230() = 0; 591 | virtual void sub_1002BE90() = 0; 592 | virtual void sub_1006D200() = 0; 593 | virtual void sub_100708A0() = 0; 594 | virtual void sub_10052910() = 0; 595 | virtual void nullsub_141() = 0; 596 | virtual void nullsub_142() = 0; 597 | virtual void sub_10056610() = 0; 598 | virtual void sub_10051230() = 0; 599 | virtual void sub_1005EB40() = 0; 600 | virtual void sub_10052D60() = 0; 601 | virtual void sub_100512B0() = 0; 602 | virtual void sub_1002BEB0() = 0; 603 | virtual void sub_1002BEC0() = 0; 604 | virtual void sub_10147360() = 0; 605 | virtual void sub_1014C220() = 0; 606 | virtual void nullsub_143() = 0; 607 | virtual void sub_10057570() = 0; 608 | virtual void sub_100575A0() = 0; 609 | virtual void sub_1002BED0() = 0; 610 | virtual void nullsub_144() = 0; 611 | virtual void nullsub_145() = 0; 612 | virtual void nullsub_146() = 0; 613 | virtual void nullsub_147() = 0; 614 | virtual void nullsub_148() = 0; 615 | virtual void nullsub_149() = 0; 616 | virtual void nullsub_150() = 0; 617 | virtual void nullsub_151() = 0; 618 | virtual void nullsub_152() = 0; 619 | virtual void nullsub_153() = 0; 620 | virtual void nullsub_154() = 0; 621 | virtual void nullsub_155() = 0; 622 | virtual void nullsub_156() = 0; 623 | virtual void nullsub_157() = 0; 624 | virtual void nullsub_158() = 0; 625 | virtual void nullsub_159() = 0; 626 | virtual void sub_10063F90() = 0; 627 | 628 | }; -------------------------------------------------------------------------------- /L4D2VR/sdk/texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned int uint32; 4 | 5 | class IVTFTexture; 6 | class ITexture; 7 | struct Rect_t; 8 | 9 | enum NormalDecodeMode_t 10 | { 11 | NORMAL_DECODE_NONE = 0, 12 | NORMAL_DECODE_ATI2N = 1, 13 | NORMAL_DECODE_ATI2N_ALPHA = 2 14 | }; 15 | 16 | enum ImageFormat 17 | { 18 | IMAGE_FORMAT_UNKNOWN = -1, 19 | IMAGE_FORMAT_RGBA8888 = 0, 20 | IMAGE_FORMAT_ABGR8888, 21 | IMAGE_FORMAT_RGB888, 22 | IMAGE_FORMAT_BGR888, 23 | IMAGE_FORMAT_RGB565, 24 | IMAGE_FORMAT_I8, 25 | IMAGE_FORMAT_IA88, 26 | IMAGE_FORMAT_P8, 27 | IMAGE_FORMAT_A8, 28 | IMAGE_FORMAT_RGB888_BLUESCREEN, 29 | IMAGE_FORMAT_BGR888_BLUESCREEN, 30 | IMAGE_FORMAT_ARGB8888, 31 | IMAGE_FORMAT_BGRA8888, 32 | IMAGE_FORMAT_DXT1, 33 | IMAGE_FORMAT_DXT3, 34 | IMAGE_FORMAT_DXT5, 35 | IMAGE_FORMAT_BGRX8888, 36 | IMAGE_FORMAT_BGR565, 37 | IMAGE_FORMAT_BGRX5551, 38 | IMAGE_FORMAT_BGRA4444, 39 | IMAGE_FORMAT_DXT1_ONEBITALPHA, 40 | IMAGE_FORMAT_BGRA5551, 41 | IMAGE_FORMAT_UV88, 42 | IMAGE_FORMAT_UVWQ8888, 43 | IMAGE_FORMAT_RGBA16161616F, 44 | IMAGE_FORMAT_RGBA16161616, 45 | IMAGE_FORMAT_UVLX8888, 46 | IMAGE_FORMAT_R32F, // Single-channel 32-bit floating point 47 | IMAGE_FORMAT_RGB323232F, 48 | IMAGE_FORMAT_RGBA32323232F, 49 | 50 | // Depth-stencil texture formats for shadow depth mapping 51 | IMAGE_FORMAT_NV_DST16, // 52 | IMAGE_FORMAT_NV_DST24, // 53 | IMAGE_FORMAT_NV_INTZ, // Vendor-specific depth-stencil texture 54 | IMAGE_FORMAT_NV_RAWZ, // formats for shadow depth mapping 55 | IMAGE_FORMAT_ATI_DST16, // 56 | IMAGE_FORMAT_ATI_DST24, // 57 | IMAGE_FORMAT_NV_NULL, // Dummy format which takes no video memory 58 | 59 | // Compressed normal map formats 60 | IMAGE_FORMAT_ATI2N, // One-surface ATI2N / DXN format 61 | IMAGE_FORMAT_ATI1N, // Two-surface ATI1N format 62 | 63 | #if defined( _X360 ) 64 | // Depth-stencil texture formats 65 | IMAGE_FORMAT_X360_DST16, 66 | IMAGE_FORMAT_X360_DST24, 67 | IMAGE_FORMAT_X360_DST24F, 68 | // supporting these specific formats as non-tiled for procedural cpu access 69 | IMAGE_FORMAT_LINEAR_BGRX8888, 70 | IMAGE_FORMAT_LINEAR_RGBA8888, 71 | IMAGE_FORMAT_LINEAR_ABGR8888, 72 | IMAGE_FORMAT_LINEAR_ARGB8888, 73 | IMAGE_FORMAT_LINEAR_BGRA8888, 74 | IMAGE_FORMAT_LINEAR_RGB888, 75 | IMAGE_FORMAT_LINEAR_BGR888, 76 | IMAGE_FORMAT_LINEAR_BGRX5551, 77 | IMAGE_FORMAT_LINEAR_I8, 78 | IMAGE_FORMAT_LINEAR_RGBA16161616, 79 | 80 | IMAGE_FORMAT_LE_BGRX8888, 81 | IMAGE_FORMAT_LE_BGRA8888, 82 | #endif 83 | 84 | IMAGE_FORMAT_DXT1_RUNTIME, 85 | IMAGE_FORMAT_DXT5_RUNTIME, 86 | 87 | NUM_IMAGE_FORMATS 88 | }; 89 | 90 | //----------------------------------------------------------------------------- 91 | // This will get called on procedural textures to re-fill the textures 92 | // with the appropriate bit pattern. Calling Download() will also 93 | // cause this interface to be called. It will also be called upon 94 | // mode switch, or on other occasions where the bits are discarded. 95 | //----------------------------------------------------------------------------- 96 | class ITextureRegenerator 97 | { 98 | public: 99 | // This will be called when the texture bits need to be regenerated. 100 | // Use the VTFTexture interface, which has been set up with the 101 | // appropriate texture size + format 102 | // The rect specifies which part of the texture needs to be updated 103 | // You can choose to update all of the bits if you prefer 104 | virtual void RegenerateTextureBits(ITexture * pTexture, IVTFTexture * pVTFTexture, Rect_t * pRect) = 0; 105 | 106 | // This will be called when the regenerator needs to be deleted 107 | // which will happen when the texture is destroyed 108 | virtual void Release() = 0; 109 | 110 | // (erics): This should have a virtual destructor, but would be ABI breaking (non-versioned interface implemented 111 | // by the game) 112 | // virtual ~ITextureRegenerator(){} 113 | }; 114 | 115 | class ITexture 116 | { 117 | public: 118 | // Various texture polling methods 119 | virtual const char *GetName(void) const = 0; 120 | virtual int GetMappingWidth() const = 0; 121 | virtual int GetMappingHeight() const = 0; 122 | virtual int GetActualWidth() const = 0; 123 | virtual int GetActualHeight() const = 0; 124 | virtual int GetNumAnimationFrames() const = 0; 125 | virtual bool IsTranslucent() const = 0; 126 | virtual bool IsMipmapped() const = 0; 127 | 128 | virtual void GetLowResColorSample(float s, float t, float *color) const = 0; 129 | 130 | // Gets texture resource data of the specified type. 131 | // Params: 132 | // eDataType type of resource to retrieve. 133 | // pnumBytes on return is the number of bytes available in the read-only data buffer or is undefined 134 | // Returns: 135 | // pointer to the resource data, or NULL 136 | virtual void *GetResourceData(uint32 eDataType, size_t *pNumBytes) const = 0; 137 | 138 | // Methods associated with reference count 139 | virtual void IncrementReferenceCount(void) = 0; 140 | virtual void DecrementReferenceCount(void) = 0; 141 | 142 | inline void AddRef() { IncrementReferenceCount(); } 143 | inline void Release() { DecrementReferenceCount(); } 144 | 145 | // Used to modify the texture bits (procedural textures only) 146 | virtual void SetTextureRegenerator(ITextureRegenerator *pTextureRegen) = 0; 147 | 148 | // Reconstruct the texture bits in HW memory 149 | 150 | // If rect is not specified, reconstruct all bits, otherwise just 151 | // reconstruct a subrect. 152 | virtual void Download(Rect_t *pRect = 0, int nAdditionalCreationFlags = 0) = 0; 153 | 154 | // Uses for stats. . .get the approximate size of the texture in it's current format. 155 | virtual int GetApproximateVidMemBytes(void) const = 0; 156 | 157 | // Returns true if the texture data couldn't be loaded. 158 | virtual bool IsError() const = 0; 159 | 160 | // NOTE: Stuff after this is added after shipping HL2. 161 | 162 | // For volume textures 163 | virtual bool IsVolumeTexture() const = 0; 164 | virtual int GetMappingDepth() const = 0; 165 | virtual int GetActualDepth() const = 0; 166 | 167 | virtual ImageFormat GetImageFormat() const = 0; 168 | virtual NormalDecodeMode_t GetNormalDecodeMode() const = 0; 169 | 170 | // Various information about the texture 171 | virtual bool IsRenderTarget() const = 0; 172 | virtual bool IsCubeMap() const = 0; 173 | virtual bool IsNormalMap() const = 0; 174 | virtual bool IsProcedural() const = 0; 175 | 176 | virtual void DeleteIfUnreferenced() = 0; 177 | 178 | #if defined( _X360 ) 179 | virtual bool ClearTexture(int r, int g, int b, int a) = 0; 180 | virtual bool CreateRenderTargetSurface(int width, int height, ImageFormat format, bool bSameAsTexture) = 0; 181 | #endif 182 | 183 | // swap everything except the name with another texture 184 | virtual void SwapContents(ITexture *pOther) = 0; 185 | 186 | // Retrieve the vtf flags mask 187 | virtual unsigned int GetFlags(void) const = 0; 188 | 189 | // Force LOD override (automatically downloads the texture) 190 | virtual void ForceLODOverride(int iNumLodsOverrideUpOrDown) = 0; 191 | 192 | // Save texture to a file. 193 | virtual bool SaveToFile(const char *fileName) = 0; 194 | 195 | // Copy this texture, which must be a render target or a renderable texture, to the destination texture, 196 | // which must have been created with the STAGING bit. 197 | virtual void CopyToStagingTexture(ITexture *pDstTex) = 0; 198 | 199 | // Set that this texture should return true for the call "IsError" 200 | virtual void SetErrorTexture(bool bIsErrorTexture) = 0; 201 | }; 202 | 203 | 204 | inline bool IsErrorTexture(ITexture *pTex) 205 | { 206 | return !pTex || pTex->IsError(); 207 | } -------------------------------------------------------------------------------- /L4D2VR/sdk/trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "vector.h" 4 | 5 | 6 | 7 | struct cplane_t 8 | { 9 | Vector normal; 10 | float dist; 11 | unsigned char type; // for fast side tests 12 | unsigned char signbits; // signx + (signy<<1) + (signz<<1) 13 | unsigned char pad[2]; 14 | }; 15 | 16 | struct csurface_t 17 | { 18 | const char *name; 19 | short surfaceProps; 20 | unsigned short flags; // BUGBUG: These are declared per surface, not per material, but this database is per-material now 21 | }; 22 | 23 | #define CONTENTS_SOLID 0x1 // an eye is never valid in a solid 24 | #define CONTENTS_WINDOW 0x2 // translucent, but not watery (glass) 25 | #define CONTENTS_GRATE 0x8 // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't 26 | #define CONTENTS_MOVEABLE 0x4000 27 | #define CONTENTS_PLAYERCLIP 0x10000 28 | #define CONTENTS_MONSTERCLIP 0x20000 29 | #define CONTENTS_MONSTER 0x2000000 30 | #define CONTENTS_DEBRIS 0x4000000 31 | #define CONTENTS_HITBOX 0x40000000 // use accurate hitboxes on trace 32 | 33 | #define MASK_NPCWORLDSTATIC (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 34 | #define STANDARD_TRACE_MASK ( MASK_NPCWORLDSTATIC | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_DEBRIS | CONTENTS_HITBOX ) 35 | #define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) 36 | #define MASK_SHOT_HULL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) 37 | #define MASK_STATICWORLD (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_GRATE) 38 | 39 | #define DISPSURF_FLAG_SURFACE (1<<0) 40 | #define DISPSURF_FLAG_WALKABLE (1<<1) 41 | #define DISPSURF_FLAG_BUILDABLE (1<<2) 42 | #define DISPSURF_FLAG_SURFPROP1 (1<<3) 43 | #define DISPSURF_FLAG_SURFPROP2 (1<<4) 44 | 45 | enum SpewType_t 46 | { 47 | SPEW_MESSAGE = 0, 48 | SPEW_WARNING, 49 | SPEW_ASSERT, 50 | SPEW_ERROR, 51 | SPEW_LOG, 52 | 53 | SPEW_TYPE_COUNT 54 | }; 55 | 56 | #define __T(x) L ## x 57 | #define _T(x) __T(x) 58 | #define Assert( _exp ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), ((void)0), false ) 59 | 60 | #define FLT_MAX 3.402823466e+38F // max value 61 | 62 | #define _AssertMsg( _exp, _msg, _executeExp, _bFatal ) \ 63 | do { \ 64 | if (!(_exp)) \ 65 | { \ 66 | _SpewInfo( SPEW_ASSERT, __TFILE__, __LINE__ ); \ 67 | SpewRetval_t ret = _SpewMessage("%s", static_cast( _msg )); \ 68 | CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ 69 | _executeExp; \ 70 | if ( ret == SPEW_DEBUGGER) \ 71 | { \ 72 | if ( !ShouldUseNewAssertDialog() || DoNewAssertDialog( __TFILE__, __LINE__, _msg ) ) \ 73 | { \ 74 | DebuggerBreak(); \ 75 | } \ 76 | if ( _bFatal ) \ 77 | { \ 78 | _ExitOnFatalAssert( __TFILE__, __LINE__ ); \ 79 | } \ 80 | } \ 81 | } \ 82 | } while (0) 83 | 84 | class CBaseTrace 85 | { 86 | public: 87 | 88 | // Displacement flags tests. 89 | bool IsDispSurface(void) { return ((dispFlags & DISPSURF_FLAG_SURFACE) != 0); } 90 | bool IsDispSurfaceWalkable(void) { return ((dispFlags & DISPSURF_FLAG_WALKABLE) != 0); } 91 | bool IsDispSurfaceBuildable(void) { return ((dispFlags & DISPSURF_FLAG_BUILDABLE) != 0); } 92 | bool IsDispSurfaceProp1(void) { return ((dispFlags & DISPSURF_FLAG_SURFPROP1) != 0); } 93 | bool IsDispSurfaceProp2(void) { return ((dispFlags & DISPSURF_FLAG_SURFPROP2) != 0); } 94 | 95 | public: 96 | 97 | // these members are aligned!! 98 | Vector startpos; // start position 99 | Vector endpos; // final position 100 | cplane_t plane; // surface normal at impact 101 | 102 | float fraction; // time completed, 1.0 = didn't hit anything 103 | 104 | int contents; // contents on other side of surface hit 105 | unsigned short dispFlags; // displacement flags for marking surfaces with data 106 | 107 | bool allsolid; // if true, plane is not valid 108 | bool startsolid; // if true, the initial point was in a solid area 109 | 110 | CBaseTrace() {} 111 | }; 112 | 113 | class CGameTrace : public CBaseTrace 114 | { 115 | public: 116 | 117 | bool DidHitWorld() const; 118 | bool DidHitNonWorldEntity() const; 119 | int GetEntityIndex() const; 120 | bool DidHit() const; 121 | // bool isVisible() const; 122 | // The engine doesn't know what a CBaseEntity is, so it has a backdoor to 123 | // let it get at the edict. 124 | 125 | public: 126 | 127 | float fractionleftsolid; 128 | csurface_t surface; 129 | int hitgroup; 130 | short physicsbone; 131 | void *m_pEnt; 132 | int hitbox; 133 | 134 | CGameTrace() {} 135 | 136 | private: 137 | // No copy constructors allowed 138 | CGameTrace(const CGameTrace &vOther); 139 | }; 140 | 141 | enum TraceType_t 142 | { 143 | TRACE_EVERYTHING = 0, 144 | TRACE_WORLD_ONLY, // NOTE: This does *not* test static props!!! 145 | TRACE_ENTITIES_ONLY, // NOTE: This version will *not* test static props 146 | TRACE_EVERYTHING_FILTER_PROPS, // NOTE: This version will pass the IHandleEntity for props through the filter, unlike all other filters 147 | }; 148 | 149 | enum class TraceType 150 | { 151 | TRACE_EVERYTHING = 0, 152 | TRACE_WORLD_ONLY, 153 | TRACE_ENTITIES_ONLY, 154 | TRACE_EVERYTHING_FILTER_PROPS, 155 | }; 156 | 157 | class ITraceFilter 158 | { 159 | public: 160 | virtual bool ShouldHitEntity(IHandleEntity * pEntity, int contentsMask) = 0; 161 | virtual TraceType GetTraceType() const = 0; 162 | }; 163 | 164 | class CTraceFilter : public ITraceFilter 165 | { 166 | public: 167 | CTraceFilter(IHandleEntity *passentity, int collisionGroup, void *pExtraShouldHitCheckFn = NULL) 168 | { 169 | m_pPassEnt = passentity; 170 | m_collisionGroup = collisionGroup; 171 | m_pExtraShouldHitCheckFunction = pExtraShouldHitCheckFn; 172 | } 173 | virtual TraceType GetTraceType() const 174 | { 175 | return TraceType::TRACE_EVERYTHING; 176 | } 177 | 178 | IHandleEntity *m_pPassEnt; 179 | int m_collisionGroup; 180 | void *m_pExtraShouldHitCheckFunction; 181 | }; 182 | 183 | 184 | class CTraceFilterSkipNPCsAndPlayers : public CTraceFilter 185 | { 186 | public: 187 | CTraceFilterSkipNPCsAndPlayers(IHandleEntity *passentity, int collisionGroup) 188 | : CTraceFilter(passentity, collisionGroup) 189 | { 190 | } 191 | 192 | virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask) 193 | { 194 | C_BasePlayer *pEntity = (C_BasePlayer *)pServerEntity; 195 | if (!pEntity) 196 | return true; 197 | 198 | if (m_pPassEnt == pServerEntity) 199 | return false; 200 | 201 | if (pEntity->IsNPC() || pEntity->IsPlayer()) 202 | { 203 | return false; 204 | } 205 | 206 | return true; 207 | } 208 | }; 209 | 210 | 211 | 212 | struct Ray_t 213 | { 214 | VectorAligned m_Start; // starting point, centered within the extents 215 | VectorAligned m_Delta; // direction + length of the ray 216 | VectorAligned m_StartOffset; // Add this to m_Start to get the actual ray start 217 | VectorAligned m_Extents; // Describes an axis aligned box extruded along a ray 218 | const matrix3x4_t *m_pWorldAxisTransform; 219 | bool m_IsRay; // are the extents zero? 220 | bool m_IsSwept; // is delta != 0? 221 | 222 | void Init(Vector const &start, Vector const &end) 223 | { 224 | //Assert(&end); 225 | VectorSubtract(end, start, m_Delta); 226 | 227 | m_IsSwept = (m_Delta.LengthSqr() != 0); 228 | 229 | VectorClear(m_Extents); 230 | m_IsRay = true; 231 | 232 | m_pWorldAxisTransform = 0; 233 | 234 | // Offset m_Start to be in the center of the box... 235 | VectorClear(m_StartOffset); 236 | VectorCopy(start, m_Start); 237 | } 238 | 239 | void Init(Vector const &start, Vector const &end, Vector const &mins, Vector const &maxs) 240 | { 241 | //Assert(&end); 242 | VectorSubtract(end, start, m_Delta); 243 | 244 | m_IsSwept = (m_Delta.LengthSqr() != 0); 245 | 246 | VectorSubtract(maxs, mins, m_Extents); 247 | m_Extents *= 0.5f; 248 | m_IsRay = (m_Extents.LengthSqr() < 1e-6); 249 | 250 | // Offset m_Start to be in the center of the box... 251 | VectorAdd(mins, maxs, m_StartOffset); 252 | m_StartOffset *= 0.5f; 253 | VectorAdd(start, m_StartOffset, m_Start); 254 | m_StartOffset *= -1.0f; 255 | } 256 | 257 | // compute inverse delta 258 | Vector InvDelta() const 259 | { 260 | Vector vecInvDelta; 261 | for (int iAxis = 0; iAxis < 3; ++iAxis) 262 | { 263 | if (m_Delta[iAxis] != 0.0f) 264 | { 265 | vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis]; 266 | } 267 | else 268 | { 269 | vecInvDelta[iAxis] = FLT_MAX; 270 | } 271 | } 272 | return vecInvDelta; 273 | } 274 | 275 | private: 276 | }; 277 | 278 | typedef CGameTrace trace_t; 279 | class IEngineTrace 280 | { 281 | public: 282 | 283 | virtual void fn0() = 0; 284 | virtual void fn1() = 0; 285 | virtual void fn2() = 0; 286 | virtual void fn3() = 0; 287 | virtual void fn4() = 0; 288 | virtual void TraceRay(const Ray_t &ray, unsigned int fMask, CTraceFilter *pTraceFilter, trace_t *pTrace) = 0; 289 | }; 290 | 291 | 292 | typedef void(__fastcall *tTraceRay)(void *thisptr, void *not_edx, Ray_t &ray, unsigned int fMask, CTraceFilter *pTraceFilter, CGameTrace *pTrace); -------------------------------------------------------------------------------- /L4D2VR/sdk/usercmd.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | #pragma once 3 | #include "vector.h" 4 | #include "checksum_crc.h" 5 | 6 | typedef unsigned int CRC32_t; 7 | typedef unsigned char byte; 8 | 9 | class CUserCmd 10 | { 11 | public: 12 | CUserCmd() 13 | { 14 | Reset(); 15 | } 16 | 17 | virtual ~CUserCmd() { }; 18 | 19 | void Reset() 20 | { 21 | command_number = 0; 22 | tick_count = 0; 23 | viewangles.Init(); 24 | forwardmove = 0.0f; 25 | sidemove = 0.0f; 26 | upmove = 0.0f; 27 | buttons = 0; 28 | impulse = 0; 29 | weaponselect = 0; 30 | weaponsubtype = 0; 31 | random_seed = 0; 32 | mousedx = 0; 33 | mousedy = 0; 34 | hasbeenpredicted = false; 35 | } 36 | 37 | CUserCmd &operator =(const CUserCmd &src) 38 | { 39 | if (this == &src) 40 | return *this; 41 | 42 | command_number = src.command_number; 43 | tick_count = src.tick_count; 44 | viewangles = src.viewangles; 45 | forwardmove = src.forwardmove; 46 | sidemove = src.sidemove; 47 | upmove = src.upmove; 48 | buttons = src.buttons; 49 | impulse = src.impulse; 50 | weaponselect = src.weaponselect; 51 | weaponsubtype = src.weaponsubtype; 52 | random_seed = src.random_seed; 53 | mousedx = src.mousedx; 54 | mousedy = src.mousedy; 55 | 56 | hasbeenpredicted = src.hasbeenpredicted; 57 | 58 | return *this; 59 | } 60 | 61 | CUserCmd(const CUserCmd &src) 62 | { 63 | *this = src; 64 | } 65 | 66 | CRC32_t GetChecksum(void) const 67 | { 68 | CRC32_t crc; 69 | 70 | CRC32_Init(&crc); 71 | CRC32_ProcessBuffer(&crc, &command_number, sizeof(command_number)); 72 | CRC32_ProcessBuffer(&crc, &tick_count, sizeof(tick_count)); 73 | CRC32_ProcessBuffer(&crc, &viewangles, sizeof(viewangles)); 74 | CRC32_ProcessBuffer(&crc, &forwardmove, sizeof(forwardmove)); 75 | CRC32_ProcessBuffer(&crc, &sidemove, sizeof(sidemove)); 76 | CRC32_ProcessBuffer(&crc, &upmove, sizeof(upmove)); 77 | CRC32_ProcessBuffer(&crc, &buttons, sizeof(buttons)); 78 | CRC32_ProcessBuffer(&crc, &impulse, sizeof(impulse)); 79 | CRC32_ProcessBuffer(&crc, &weaponselect, sizeof(weaponselect)); 80 | CRC32_ProcessBuffer(&crc, &weaponsubtype, sizeof(weaponsubtype)); 81 | CRC32_ProcessBuffer(&crc, &random_seed, sizeof(random_seed)); 82 | CRC32_ProcessBuffer(&crc, &mousedx, sizeof(mousedx)); 83 | CRC32_ProcessBuffer(&crc, &mousedy, sizeof(mousedy)); 84 | CRC32_Final(&crc); 85 | 86 | return crc; 87 | } 88 | 89 | // Allow command, but negate gameplay-affecting values 90 | void MakeInert(void) 91 | { 92 | //viewangles = vec3_angle; 93 | forwardmove = 0.f; 94 | sidemove = 0.f; 95 | upmove = 0.f; 96 | buttons = 0; 97 | impulse = 0; 98 | } 99 | 100 | int command_number; 101 | int tick_count; 102 | QAngle viewangles; 103 | float forwardmove; 104 | float sidemove; 105 | float upmove; 106 | int buttons; 107 | byte impulse; 108 | int weaponselect; 109 | int weaponsubtype; 110 | int random_seed; 111 | short mousedx; 112 | short mousedy; 113 | bool hasbeenpredicted; 114 | char pad[25]; 115 | }; 116 | static_assert(sizeof(CUserCmd) == 0x58); 117 | 118 | class CVerifiedUserCmd 119 | { 120 | public: 121 | CUserCmd m_cmd; 122 | CRC32_t m_crc; 123 | }; 124 | 125 | class CInput 126 | { 127 | public: 128 | virtual void Init_All(void); 129 | virtual void Shutdown_All(void); 130 | virtual int GetButtonBits(int); 131 | virtual void CreateMove(int sequence_number, float input_sample_frametime, bool active); 132 | virtual void ExtraMouseSample(float frametime, bool active); 133 | virtual bool WriteUsercmdDeltaToBuffer(int *buf, int from, int to, bool isnewcommand); 134 | virtual void EncodeUserCmdToBuffer(int buf, int slot); 135 | virtual void DecodeUserCmdFromBuffer(int buf, int slot); 136 | virtual CUserCmd *GetUserCmd(int uk, int sequence_number); 137 | virtual void func0(void); 138 | virtual void func1(void); 139 | virtual void KeyEvent(int x, int y, char const * z); 140 | virtual void func3(void); 141 | virtual void func4(void); 142 | virtual void Joystick_Advanced(void); 143 | virtual void func5(void); 144 | virtual void func6(void); 145 | virtual void func7(void); 146 | virtual void func8(void); 147 | virtual void func9(void); 148 | virtual void func10(void); 149 | virtual void ActivateMouse(void); 150 | virtual void DeactivateMouse(void); 151 | }; -------------------------------------------------------------------------------- /L4D2VR/sdk/vector.h: -------------------------------------------------------------------------------- 1 | //========= Copyright Valve Corporation, All rights reserved. ============// 2 | #pragma once 3 | #include 4 | 5 | #define FORCEINLINE __forceinline 6 | 7 | #define DECL_ALIGN(x) __declspec(align(x)) 8 | #define ALIGN16 DECL_ALIGN(16) 9 | #define ALIGN16_POST DECL_ALIGN(16) 10 | 11 | #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h 12 | #define M_PI_F ((float)(M_PI)) // Shouldn't collide with anything. 13 | #define DEG2RAD( x ) ( (float)(x) * (float)(M_PI_F / 180.f) ) 14 | #define RAD2DEG( x ) ( (float)(x) * (float)(180.f / M_PI_F) ) 15 | 16 | typedef float vec_t; 17 | 18 | 19 | class Vector2D 20 | { 21 | public: 22 | // Members 23 | vec_t x, y; 24 | 25 | // Construction/destruction 26 | Vector2D(void); 27 | Vector2D(vec_t X, vec_t Y); 28 | Vector2D(const float *pFloat); 29 | 30 | // Initialization 31 | void Init(vec_t ix = 0.0f, vec_t iy = 0.0f); 32 | 33 | // Got any nasty NAN's? 34 | bool IsValid() const; 35 | 36 | // array access... 37 | vec_t operator[](int i) const; 38 | vec_t &operator[](int i); 39 | 40 | // Base address... 41 | vec_t *Base(); 42 | vec_t const *Base() const; 43 | 44 | // Initialization methods 45 | void Random(float minVal, float maxVal); 46 | 47 | // equality 48 | bool operator==(const Vector2D &v) const; 49 | bool operator!=(const Vector2D &v) const; 50 | 51 | // arithmetic operations 52 | Vector2D &operator+=(const Vector2D &v); 53 | Vector2D &operator-=(const Vector2D &v); 54 | Vector2D &operator*=(const Vector2D &v); 55 | Vector2D &operator*=(float s); 56 | Vector2D &operator/=(const Vector2D &v); 57 | Vector2D &operator/=(float s); 58 | 59 | // negate the Vector2D components 60 | void Negate(); 61 | 62 | // Get the Vector2D's magnitude. 63 | vec_t Length() const; 64 | 65 | // Get the Vector2D's magnitude squared. 66 | vec_t LengthSqr(void) const; 67 | 68 | // return true if this vector is (0,0) within tolerance 69 | bool IsZero(float tolerance = 0.01f) const 70 | { 71 | return (x > -tolerance && x < tolerance && 72 | y > -tolerance && y < tolerance); 73 | } 74 | 75 | // Normalize in place and return the old length. 76 | vec_t NormalizeInPlace(); 77 | 78 | // Compare length. 79 | bool IsLengthGreaterThan(float val) const; 80 | bool IsLengthLessThan(float val) const; 81 | 82 | // Get the distance from this Vector2D to the other one. 83 | vec_t DistTo(const Vector2D &vOther) const; 84 | 85 | // Get the distance from this Vector2D to the other one squared. 86 | vec_t DistToSqr(const Vector2D &vOther) const; 87 | 88 | // Copy 89 | void CopyToArray(float *rgfl) const; 90 | 91 | // Multiply, add, and assign to this (ie: *this = a + b * scalar). This 92 | // is about 12% faster than the actual Vector2D equation (because it's done per-component 93 | // rather than per-Vector2D). 94 | void MulAdd(const Vector2D &a, const Vector2D &b, float scalar); 95 | 96 | // Dot product. 97 | vec_t Dot(const Vector2D &vOther) const; 98 | 99 | // assignment 100 | Vector2D &operator=(const Vector2D &vOther); 101 | 102 | #ifndef VECTOR_NO_SLOW_OPERATIONS 103 | // copy constructors 104 | Vector2D(const Vector2D &vOther); 105 | 106 | // arithmetic operations 107 | Vector2D operator-(void) const; 108 | 109 | Vector2D operator+(const Vector2D &v) const; 110 | Vector2D operator-(const Vector2D &v) const; 111 | Vector2D operator*(const Vector2D &v) const; 112 | Vector2D operator/(const Vector2D &v) const; 113 | Vector2D operator*(float fl) const; 114 | Vector2D operator/(float fl) const; 115 | 116 | // Cross product between two vectors. 117 | Vector2D Cross(const Vector2D &vOther) const; 118 | 119 | // Returns a Vector2D with the min or max in X, Y, and Z. 120 | Vector2D Min(const Vector2D &vOther) const; 121 | Vector2D Max(const Vector2D &vOther) const; 122 | 123 | #else 124 | 125 | private: 126 | // No copy constructors allowed if we're in optimal mode 127 | Vector2D(const Vector2D &vOther); 128 | #endif 129 | }; 130 | 131 | class VectorByValue; 132 | 133 | class Vector 134 | { 135 | public: 136 | // Members 137 | vec_t x, y, z; 138 | 139 | // Construction/destruction: 140 | Vector(void); 141 | Vector(vec_t X, vec_t Y, vec_t Z); 142 | explicit Vector(vec_t XYZ); ///< broadcast initialize 143 | 144 | // Initialization 145 | void Init(vec_t ix = 0.0f, vec_t iy = 0.0f, vec_t iz = 0.0f); 146 | // TODO (Ilya): Should there be an init that takes a single float for consistency? 147 | 148 | // Got any nasty NAN's? 149 | bool IsValid() const; 150 | void Invalidate(); 151 | 152 | // array access... 153 | vec_t operator[](int i) const; 154 | vec_t &operator[](int i); 155 | 156 | // Base address... 157 | vec_t *Base(); 158 | vec_t const *Base() const; 159 | 160 | // Cast to Vector2D... 161 | Vector2D &AsVector2D(); 162 | const Vector2D &AsVector2D() const; 163 | 164 | // Initialization methods 165 | void Random(vec_t minVal, vec_t maxVal); 166 | inline void Zero(); ///< zero out a vector 167 | 168 | // equality 169 | bool operator==(const Vector &v) const; 170 | bool operator!=(const Vector &v) const; 171 | 172 | // arithmetic operations 173 | FORCEINLINE Vector &operator+=(const Vector &v); 174 | FORCEINLINE Vector &operator-=(const Vector &v); 175 | FORCEINLINE Vector &operator*=(const Vector &v); 176 | FORCEINLINE Vector &operator*=(float s); 177 | FORCEINLINE Vector &operator/=(const Vector &v); 178 | FORCEINLINE Vector &operator/=(float s); 179 | FORCEINLINE Vector &operator+=(float fl); ///< broadcast add 180 | FORCEINLINE Vector &operator-=(float fl); ///< broadcast sub 181 | 182 | // negate the vector components 183 | void Negate(); 184 | 185 | // Get the vector's magnitude. 186 | inline vec_t Length() const; 187 | 188 | // Get the vector's magnitude squared. 189 | FORCEINLINE vec_t LengthSqr(void) const 190 | { 191 | return (x * x + y * y + z * z); 192 | } 193 | 194 | 195 | 196 | // return true if this vector is (0,0,0) within tolerance 197 | bool IsZero(float tolerance = 0.01f) const 198 | { 199 | return (x > -tolerance && x < tolerance && 200 | y > -tolerance && y < tolerance && 201 | z > -tolerance && z < tolerance); 202 | } 203 | 204 | 205 | vec_t NormalizeInPlace(); 206 | Vector Normalized() const; 207 | bool IsLengthGreaterThan(float val) const; 208 | bool IsLengthLessThan(float val) const; 209 | 210 | // check if a vector is within the box defined by two other vectors 211 | FORCEINLINE bool WithinAABox(Vector const &boxmin, Vector const &boxmax); 212 | 213 | // Get the distance from this vector to the other one. 214 | vec_t DistTo(const Vector &vOther) const; 215 | 216 | // Get the distance from this vector to the other one squared. 217 | // NJS: note, VC wasn't inlining it correctly in several deeply nested inlines due to being an 'out of line' inline. 218 | // may be able to tidy this up after switching to VC7 219 | FORCEINLINE vec_t DistToSqr(const Vector &vOther) const 220 | { 221 | Vector delta; 222 | 223 | delta.x = x - vOther.x; 224 | delta.y = y - vOther.y; 225 | delta.z = z - vOther.z; 226 | 227 | return delta.LengthSqr(); 228 | } 229 | 230 | // Copy 231 | void CopyToArray(float *rgfl) const; 232 | 233 | // Multiply, add, and assign to this (ie: *this = a + b * scalar). This 234 | // is about 12% faster than the actual vector equation (because it's done per-component 235 | // rather than per-vector). 236 | void MulAdd(const Vector &a, const Vector &b, float scalar); 237 | 238 | // Dot product. 239 | vec_t Dot(const Vector &vOther) const; 240 | 241 | // assignment 242 | Vector &operator=(const Vector &vOther); 243 | 244 | // 2d 245 | vec_t Length2D(void) const; 246 | vec_t Length2DSqr(void) const; 247 | 248 | operator VectorByValue &() { return *((VectorByValue *)(this)); } 249 | operator const VectorByValue &() const { return *((const VectorByValue *)(this)); } 250 | 251 | #ifndef VECTOR_NO_SLOW_OPERATIONS 252 | // copy constructors 253 | // Vector(const Vector &vOther); 254 | 255 | // arithmetic operations 256 | Vector operator-(void) const; 257 | 258 | Vector operator+(const Vector &v) const; 259 | Vector operator-(const Vector &v) const; 260 | Vector operator*(const Vector &v) const; 261 | Vector operator/(const Vector &v) const; 262 | Vector operator*(float fl) const; 263 | Vector operator/(float fl) const; 264 | 265 | // Cross product between two vectors. 266 | Vector Cross(const Vector &vOther) const; 267 | 268 | // Returns a vector with the min or max in X, Y, and Z. 269 | Vector Min(const Vector &vOther) const; 270 | Vector Max(const Vector &vOther) const; 271 | 272 | #else 273 | 274 | private: 275 | // No copy constructors allowed if we're in optimal mode 276 | Vector(const Vector &vOther); 277 | #endif 278 | }; 279 | 280 | inline Vector::Vector(void) 281 | { 282 | #ifdef _DEBUG 283 | #ifdef VECTOR_PARANOIA 284 | // Initialize to NAN to catch errors 285 | x = y = z = VEC_T_NAN; 286 | #endif 287 | #endif 288 | } 289 | 290 | FORCEINLINE Vector::Vector(vec_t X, vec_t Y, vec_t Z) 291 | { 292 | x = X; y = Y; z = Z; 293 | } 294 | 295 | inline vec_t &Vector::operator[](int i) 296 | { 297 | return ((vec_t *)this)[i]; 298 | } 299 | 300 | inline vec_t Vector::operator[](int i) const 301 | { 302 | return ((vec_t *)this)[i]; 303 | } 304 | 305 | class VectorByValue : public Vector 306 | { 307 | public: 308 | // Construction/destruction: 309 | VectorByValue(void) : Vector() {} 310 | VectorByValue(vec_t X, vec_t Y, vec_t Z) : Vector(X, Y, Z) {} 311 | VectorByValue(const VectorByValue &vOther) { *this = vOther; } 312 | }; 313 | 314 | class ALIGN16 VectorAligned : public Vector 315 | { 316 | public: 317 | inline VectorAligned(void) {}; 318 | inline VectorAligned(vec_t X, vec_t Y, vec_t Z) 319 | { 320 | Init(X, Y, Z); 321 | } 322 | 323 | #ifdef VECTOR_NO_SLOW_OPERATIONS 324 | 325 | private: 326 | // No copy constructors allowed if we're in optimal mode 327 | VectorAligned(const VectorAligned &vOther); 328 | VectorAligned(const Vector &vOther); 329 | 330 | #else 331 | public: 332 | explicit VectorAligned(const Vector &vOther) 333 | { 334 | Init(vOther.x, vOther.y, vOther.z); 335 | } 336 | 337 | VectorAligned &operator=(const Vector &vOther) 338 | { 339 | Init(vOther.x, vOther.y, vOther.z); 340 | return *this; 341 | } 342 | 343 | #endif 344 | float w; // this space is used anyway 345 | } ALIGN16_POST; 346 | 347 | 348 | FORCEINLINE void VectorAdd(const Vector &a, const Vector &b, Vector &c) 349 | { 350 | c.x = a.x + b.x; 351 | c.y = a.y + b.y; 352 | c.z = a.z + b.z; 353 | } 354 | 355 | FORCEINLINE void VectorSubtract(const Vector &a, const Vector &b, Vector &c) 356 | { 357 | c.x = a.x - b.x; 358 | c.y = a.y - b.y; 359 | c.z = a.z - b.z; 360 | } 361 | 362 | inline unsigned long &FloatBits(vec_t &f) 363 | { 364 | return *reinterpret_cast(&f); 365 | } 366 | 367 | inline bool IsFinite(vec_t f) 368 | { 369 | return ((FloatBits(f) & 0x7F800000) != 0x7F800000); 370 | } 371 | 372 | FORCEINLINE void VectorMultiply(const Vector &a, vec_t b, Vector &c) 373 | { 374 | c.x = a.x * b; 375 | c.y = a.y * b; 376 | c.z = a.z * b; 377 | } 378 | 379 | FORCEINLINE void VectorMultiply(const Vector &a, const Vector &b, Vector &c) 380 | { 381 | c.x = a.x * b.x; 382 | c.y = a.y * b.y; 383 | c.z = a.z * b.z; 384 | } 385 | 386 | inline void VectorClear(Vector &a) 387 | { 388 | a.x = a.y = a.z = 0.0f; 389 | } 390 | 391 | FORCEINLINE void VectorCopy(const Vector &src, Vector &dst) 392 | { 393 | dst.x = src.x; 394 | dst.y = src.y; 395 | dst.z = src.z; 396 | } 397 | 398 | class matrix3x4_t; 399 | class Vector4D; 400 | class VPlane; 401 | class QAngle; 402 | 403 | class VMatrix 404 | { 405 | public: 406 | 407 | VMatrix() 408 | { 409 | } 410 | 411 | VMatrix( 412 | vec_t m00, vec_t m01, vec_t m02, vec_t m03, 413 | vec_t m10, vec_t m11, vec_t m12, vec_t m13, 414 | vec_t m20, vec_t m21, vec_t m22, vec_t m23, 415 | vec_t m30, vec_t m31, vec_t m32, vec_t m33 416 | ) 417 | { 418 | Init( 419 | m00, m01, m02, m03, 420 | m10, m11, m12, m13, 421 | m20, m21, m22, m23, 422 | m30, m31, m32, m33 423 | ); 424 | } 425 | 426 | // Creates a matrix where the X axis = forward 427 | // the Y axis = left, and the Z axis = up 428 | VMatrix(const Vector &forward, const Vector &left, const Vector &up); 429 | VMatrix(const Vector &forward, const Vector &left, const Vector &up, const Vector &translation); 430 | 431 | // Construct from a 3x4 matrix 432 | VMatrix(const matrix3x4_t &matrix3x4); 433 | 434 | // Set the values in the matrix. 435 | void Init( 436 | vec_t m00, vec_t m01, vec_t m02, vec_t m03, 437 | vec_t m10, vec_t m11, vec_t m12, vec_t m13, 438 | vec_t m20, vec_t m21, vec_t m22, vec_t m23, 439 | vec_t m30, vec_t m31, vec_t m32, vec_t m33 440 | ) 441 | { 442 | m[0][0] = m00; 443 | m[0][1] = m01; 444 | m[0][2] = m02; 445 | m[0][3] = m03; 446 | 447 | m[1][0] = m10; 448 | m[1][1] = m11; 449 | m[1][2] = m12; 450 | m[1][3] = m13; 451 | 452 | m[2][0] = m20; 453 | m[2][1] = m21; 454 | m[2][2] = m22; 455 | m[2][3] = m23; 456 | 457 | m[3][0] = m30; 458 | m[3][1] = m31; 459 | m[3][2] = m32; 460 | m[3][3] = m33; 461 | } 462 | 463 | 464 | // Initialize from a 3x4 465 | void Init(const matrix3x4_t &matrix3x4); 466 | 467 | // array access 468 | inline float *operator[](int i) 469 | { 470 | return m[i]; 471 | } 472 | 473 | inline const float *operator[](int i) const 474 | { 475 | return m[i]; 476 | } 477 | 478 | // Get a pointer to m[0][0] 479 | inline float *Base() 480 | { 481 | return &m[0][0]; 482 | } 483 | 484 | inline const float *Base() const 485 | { 486 | return &m[0][0]; 487 | } 488 | 489 | void SetLeft(const Vector &vLeft); 490 | void SetUp(const Vector &vUp); 491 | void SetForward(const Vector &vForward); 492 | 493 | void GetBasisVectors(Vector &vForward, Vector &vLeft, Vector &vUp) const; 494 | void SetBasisVectors(const Vector &vForward, const Vector &vLeft, const Vector &vUp); 495 | 496 | // Get/set the translation. 497 | Vector &GetTranslation(Vector &vTrans) const; 498 | void SetTranslation(const Vector &vTrans); 499 | 500 | void PreTranslate(const Vector &vTrans); 501 | void PostTranslate(const Vector &vTrans); 502 | 503 | const matrix3x4_t &As3x4() const; 504 | void CopyFrom3x4(const matrix3x4_t &m3x4); 505 | void Set3x4(matrix3x4_t &matrix3x4) const; 506 | 507 | bool operator==(const VMatrix &src) const; 508 | bool operator!=(const VMatrix &src) const { return !(*this == src); } 509 | 510 | #ifndef VECTOR_NO_SLOW_OPERATIONS 511 | // Access the basis vectors. 512 | Vector GetLeft() const; 513 | Vector GetUp() const; 514 | Vector GetForward() const; 515 | Vector GetTranslation() const; 516 | #endif 517 | 518 | 519 | // Matrix->vector operations. 520 | public: 521 | // Multiply by a 3D vector (same as operator*). 522 | void V3Mul(const Vector &vIn, Vector &vOut) const; 523 | 524 | // Multiply by a 4D vector. 525 | void V4Mul(const Vector4D &vIn, Vector4D &vOut) const; 526 | 527 | #ifndef VECTOR_NO_SLOW_OPERATIONS 528 | // Applies the rotation (ignores translation in the matrix). (This just calls VMul3x3). 529 | Vector ApplyRotation(const Vector &vVec) const; 530 | 531 | // Multiply by a vector (divides by w, assumes input w is 1). 532 | Vector operator*(const Vector &vVec) const; 533 | 534 | // Multiply by the upper 3x3 part of the matrix (ie: only apply rotation). 535 | Vector VMul3x3(const Vector &vVec) const; 536 | 537 | // Apply the inverse (transposed) rotation (only works on pure rotation matrix) 538 | Vector VMul3x3Transpose(const Vector &vVec) const; 539 | 540 | // Multiply by the upper 3 rows. 541 | Vector VMul4x3(const Vector &vVec) const; 542 | 543 | // Apply the inverse (transposed) transformation (only works on pure rotation/translation) 544 | Vector VMul4x3Transpose(const Vector &vVec) const; 545 | #endif 546 | 547 | 548 | // Matrix->plane operations. 549 | public: 550 | // Transform the plane. The matrix can only contain translation and rotation. 551 | void TransformPlane(const VPlane &inPlane, VPlane &outPlane) const; 552 | 553 | #ifndef VECTOR_NO_SLOW_OPERATIONS 554 | // Just calls TransformPlane and returns the result. 555 | VPlane operator*(const VPlane &thePlane) const; 556 | #endif 557 | 558 | // Matrix->matrix operations. 559 | public: 560 | 561 | VMatrix &operator=(const VMatrix &mOther); 562 | 563 | // Multiply two matrices (out = this * vm). 564 | void MatrixMul(const VMatrix &vm, VMatrix &out) const 565 | { 566 | out.Init( 567 | m[0][0]*vm.m[0][0] + m[0][1]*vm.m[1][0] + m[0][2]*vm.m[2][0] + m[0][3]*vm.m[3][0], 568 | m[0][0]*vm.m[0][1] + m[0][1]*vm.m[1][1] + m[0][2]*vm.m[2][1] + m[0][3]*vm.m[3][1], 569 | m[0][0]*vm.m[0][2] + m[0][1]*vm.m[1][2] + m[0][2]*vm.m[2][2] + m[0][3]*vm.m[3][2], 570 | m[0][0]*vm.m[0][3] + m[0][1]*vm.m[1][3] + m[0][2]*vm.m[2][3] + m[0][3]*vm.m[3][3], 571 | 572 | m[1][0]*vm.m[0][0] + m[1][1]*vm.m[1][0] + m[1][2]*vm.m[2][0] + m[1][3]*vm.m[3][0], 573 | m[1][0]*vm.m[0][1] + m[1][1]*vm.m[1][1] + m[1][2]*vm.m[2][1] + m[1][3]*vm.m[3][1], 574 | m[1][0]*vm.m[0][2] + m[1][1]*vm.m[1][2] + m[1][2]*vm.m[2][2] + m[1][3]*vm.m[3][2], 575 | m[1][0]*vm.m[0][3] + m[1][1]*vm.m[1][3] + m[1][2]*vm.m[2][3] + m[1][3]*vm.m[3][3], 576 | 577 | m[2][0]*vm.m[0][0] + m[2][1]*vm.m[1][0] + m[2][2]*vm.m[2][0] + m[2][3]*vm.m[3][0], 578 | m[2][0]*vm.m[0][1] + m[2][1]*vm.m[1][1] + m[2][2]*vm.m[2][1] + m[2][3]*vm.m[3][1], 579 | m[2][0]*vm.m[0][2] + m[2][1]*vm.m[1][2] + m[2][2]*vm.m[2][2] + m[2][3]*vm.m[3][2], 580 | m[2][0]*vm.m[0][3] + m[2][1]*vm.m[1][3] + m[2][2]*vm.m[2][3] + m[2][3]*vm.m[3][3], 581 | 582 | m[3][0]*vm.m[0][0] + m[3][1]*vm.m[1][0] + m[3][2]*vm.m[2][0] + m[3][3]*vm.m[3][0], 583 | m[3][0]*vm.m[0][1] + m[3][1]*vm.m[1][1] + m[3][2]*vm.m[2][1] + m[3][3]*vm.m[3][1], 584 | m[3][0]*vm.m[0][2] + m[3][1]*vm.m[1][2] + m[3][2]*vm.m[2][2] + m[3][3]*vm.m[3][2], 585 | m[3][0]*vm.m[0][3] + m[3][1]*vm.m[1][3] + m[3][2]*vm.m[2][3] + m[3][3]*vm.m[3][3] 586 | ); 587 | } 588 | 589 | // Add two matrices. 590 | const VMatrix &operator+=(const VMatrix &other); 591 | 592 | #ifndef VECTOR_NO_SLOW_OPERATIONS 593 | // Just calls MatrixMul and returns the result. 594 | VMatrix operator*(const VMatrix &mOther) const; 595 | 596 | // Add/Subtract two matrices. 597 | VMatrix operator+(const VMatrix &other) const; 598 | VMatrix operator-(const VMatrix &other) const; 599 | 600 | // Negation. 601 | VMatrix operator-() const; 602 | 603 | // Return inverse matrix. Be careful because the results are undefined 604 | // if the matrix doesn't have an inverse (ie: InverseGeneral returns false). 605 | VMatrix operator~() const; 606 | #endif 607 | 608 | // Matrix operations. 609 | public: 610 | // Set to identity. 611 | void Identity(); 612 | 613 | bool IsIdentity() const; 614 | 615 | // Setup a matrix for origin and angles. 616 | void SetupMatrixOrgAngles(const Vector &origin, const QAngle &vAngles); 617 | 618 | // Setup a matrix for angles and no translation. 619 | void SetupMatrixAngles(const QAngle &vAngles); 620 | 621 | // General inverse. This may fail so check the return! 622 | bool InverseGeneral(VMatrix &vInverse) const; 623 | 624 | // Does a fast inverse, assuming the matrix only contains translation and rotation. 625 | void InverseTR(VMatrix &mRet) const; 626 | 627 | // Usually used for debug checks. Returns true if the upper 3x3 contains 628 | // unit vectors and they are all orthogonal. 629 | bool IsRotationMatrix() const; 630 | 631 | #ifndef VECTOR_NO_SLOW_OPERATIONS 632 | // This calls the other InverseTR and returns the result. 633 | VMatrix InverseTR() const; 634 | 635 | // Get the scale of the matrix's basis vectors. 636 | Vector GetScale() const; 637 | 638 | // (Fast) multiply by a scaling matrix setup from vScale. 639 | VMatrix Scale(const Vector &vScale); 640 | 641 | // Normalize the basis vectors. 642 | VMatrix NormalizeBasisVectors() const; 643 | 644 | // Transpose. 645 | VMatrix Transpose() const; 646 | 647 | // Transpose upper-left 3x3. 648 | VMatrix Transpose3x3() const; 649 | #endif 650 | 651 | public: 652 | // The matrix. 653 | vec_t m[4][4]; 654 | }; 655 | 656 | 657 | inline Vector Vector::operator*(float fl) const 658 | { 659 | Vector res; 660 | VectorMultiply(*this, fl, res); 661 | return res; 662 | } 663 | 664 | inline Vector operator*(const float lhs, const Vector &rhs) 665 | { 666 | Vector res; 667 | VectorMultiply(rhs, lhs, res); 668 | return res; 669 | } 670 | 671 | inline Vector Vector::operator*(const Vector &v) const 672 | { 673 | Vector res; 674 | VectorMultiply(*this, v, res); 675 | return res; 676 | } 677 | 678 | inline Vector &Vector::operator=(const Vector &vOther) 679 | { 680 | x = vOther.x; y = vOther.y; z = vOther.z; 681 | return *this; 682 | } 683 | 684 | inline Vector Vector::operator+(const Vector &v) const 685 | { 686 | Vector res; 687 | VectorAdd(*this, v, res); 688 | return res; 689 | } 690 | 691 | inline Vector Vector::operator-(void) const 692 | { 693 | return Vector(-x, -y, -z); 694 | } 695 | 696 | FORCEINLINE void VectorDivide(const Vector &a, vec_t b, Vector &c) 697 | { 698 | vec_t oob = 1.0f / b; 699 | c.x = a.x * oob; 700 | c.y = a.y * oob; 701 | c.z = a.z * oob; 702 | } 703 | 704 | inline Vector Vector::operator/(float fl) const 705 | { 706 | Vector res; 707 | VectorDivide(*this, fl, res); 708 | return res; 709 | } 710 | 711 | FORCEINLINE Vector &Vector::operator+=(const Vector &v) 712 | { 713 | x += v.x; y += v.y; z += v.z; 714 | return *this; 715 | } 716 | 717 | FORCEINLINE Vector &Vector::operator-=(const Vector &v) 718 | { 719 | x -= v.x; y -= v.y; z -= v.z; 720 | return *this; 721 | } 722 | 723 | inline Vector Vector::operator-(const Vector &v) const 724 | { 725 | Vector res; 726 | VectorSubtract(*this, v, res); 727 | return res; 728 | } 729 | 730 | FORCEINLINE Vector &Vector::operator*=(float fl) 731 | { 732 | x *= fl; 733 | y *= fl; 734 | z *= fl; 735 | return *this; 736 | } 737 | 738 | FORCEINLINE Vector &Vector::operator/=(float fl) 739 | { 740 | float oofl = 1.0f / fl; 741 | x *= oofl; 742 | y *= oofl; 743 | z *= oofl; 744 | return *this; 745 | } 746 | 747 | 748 | 749 | void inline SinCos(float radians, float *sine, float *cosine) 750 | { 751 | *sine = sin(radians); 752 | *cosine = cos(radians); 753 | } 754 | 755 | enum 756 | { 757 | PITCH = 0, // up / down 758 | YAW, // left / right 759 | ROLL // fall over 760 | }; 761 | 762 | 763 | FORCEINLINE vec_t DotProduct(const Vector &a, const Vector &b) 764 | { 765 | return(a.x * b.x + a.y * b.y + a.z * b.z); 766 | } 767 | 768 | FORCEINLINE vec_t DotProduct2D(const Vector &a, const Vector &b) 769 | { 770 | return(a.x * b.x + a.y * b.y); 771 | } 772 | 773 | inline void CrossProduct(const Vector &a, const Vector &b, Vector &result) 774 | { 775 | result.x = a.y * b.z - a.z * b.y; 776 | result.y = a.z * b.x - a.x * b.z; 777 | result.z = a.x * b.y - a.y * b.x; 778 | } 779 | 780 | inline Vector CrossProduct(const Vector &a, const Vector &b) 781 | { 782 | Vector result{}; 783 | result.x = a.y * b.z - a.z * b.y; 784 | result.y = a.z * b.x - a.x * b.z; 785 | result.z = a.x * b.y - a.y * b.x; 786 | return result; 787 | } 788 | 789 | inline vec_t VectorLength(const Vector &v) 790 | { 791 | return (vec_t)sqrt(v.x * v.x + v.y * v.y + v.z * v.z); 792 | } 793 | 794 | inline vec_t VectorNormalize(Vector &v) 795 | { 796 | vec_t l = VectorLength(v); 797 | if (l != 0.0f) 798 | { 799 | v /= l; 800 | } 801 | else 802 | { 803 | v.x = v.y = 0.0f; v.z = 1.0f; 804 | } 805 | return l; 806 | } 807 | 808 | inline Vector VectorRotate(const Vector &v, const Vector &k, float degrees) 809 | { 810 | // Rodrigues rotation 811 | float radians = degrees * 3.14159265 / 180; 812 | 813 | Vector crossProduct; 814 | CrossProduct(k, v, crossProduct); 815 | 816 | return v*cos(radians) + crossProduct * sin(radians) + k * DotProduct(k,v) * (1-cos(radians)); 817 | } 818 | 819 | inline void VectorPivotXY(Vector &point, const Vector &pivot, float degrees) 820 | { 821 | float s = sin(degrees * 3.14159265 / 180); 822 | float c = cos(degrees * 3.14159265 / 180); 823 | point.x -= pivot.x; 824 | point.y -= pivot.y; 825 | float xnew = point.x * c - point.y * s; 826 | float ynew = point.x * s + point.y * c; 827 | point.x = xnew + pivot.x; 828 | point.y = ynew + pivot.y; 829 | } 830 | 831 | class QAngleByValue; 832 | 833 | typedef float vec_t; 834 | 835 | class QAngle 836 | { 837 | public: 838 | // Members 839 | vec_t x, y, z; 840 | 841 | // Construction/destruction 842 | QAngle(); 843 | QAngle(vec_t X, vec_t Y, vec_t Z); 844 | // QAngle(RadianEuler const &angles); // evil auto type promotion!!! 845 | 846 | // Allow pass-by-value 847 | operator QAngleByValue &() { return *((QAngleByValue *)(this)); } 848 | operator const QAngleByValue &() const { return *((const QAngleByValue *)(this)); } 849 | 850 | // Initialization 851 | void Init(vec_t ix = 0.0f, vec_t iy = 0.0f, vec_t iz = 0.0f); 852 | void Random(vec_t minVal, vec_t maxVal); 853 | 854 | // Got any nasty NAN's? 855 | bool IsValid() const; 856 | void Invalidate(); 857 | 858 | // array access... 859 | vec_t operator[](int i) const; 860 | vec_t &operator[](int i); 861 | 862 | // Base address... 863 | vec_t *Base(); 864 | vec_t const *Base() const; 865 | 866 | // equality 867 | bool operator==(const QAngle &v) const; 868 | bool operator!=(const QAngle &v) const; 869 | 870 | // arithmetic operations 871 | QAngle &operator+=(const QAngle &v); 872 | QAngle &operator-=(const QAngle &v); 873 | QAngle &operator*=(float s); 874 | QAngle &operator/=(float s); 875 | 876 | // Get the vector's magnitude. 877 | vec_t Length() const; 878 | vec_t LengthSqr() const; 879 | 880 | // negate the QAngle components 881 | //void Negate(); 882 | 883 | // No assignment operators either... 884 | QAngle &operator=(const QAngle &src); 885 | 886 | #ifndef VECTOR_NO_SLOW_OPERATIONS 887 | // copy constructors 888 | 889 | // arithmetic operations 890 | QAngle operator-(void) const; 891 | 892 | QAngle operator+(const QAngle &v) const; 893 | QAngle operator-(const QAngle &v) const; 894 | QAngle operator*(float fl) const; 895 | QAngle operator/(float fl) const; 896 | #else 897 | 898 | private: 899 | // No copy constructors allowed if we're in optimal mode 900 | QAngle(const QAngle &vOther); 901 | 902 | #endif 903 | 904 | static void AngleVectors(const QAngle &angles, Vector *forward, Vector *right, Vector *up); 905 | static void VectorAngles(const Vector &forward, QAngle &angles); 906 | static void VectorAngles(const Vector &forward, const Vector &pseudoup, QAngle &angles); 907 | }; 908 | 909 | 910 | 911 | inline QAngle::QAngle() 912 | { 913 | #ifdef _DEBUG 914 | #ifdef VECTOR_PARANOIA 915 | // Initialize to NAN to catch errors 916 | x = y = z = VEC_T_NAN; 917 | #endif 918 | #endif 919 | } 920 | 921 | inline QAngle::QAngle(vec_t X, vec_t Y, vec_t Z) 922 | { 923 | x = X; y = Y; z = Z; 924 | } 925 | 926 | inline vec_t &QAngle::operator[](int i) 927 | { 928 | return ((vec_t *)this)[i]; 929 | } 930 | 931 | inline vec_t QAngle::operator[](int i) const 932 | { 933 | return ((vec_t *)this)[i]; 934 | } 935 | 936 | inline QAngle &QAngle::operator=(const QAngle &vOther) 937 | { 938 | x = vOther.x; y = vOther.y; z = vOther.z; 939 | return *this; 940 | } 941 | 942 | inline QAngle QAngle::operator-(void) const 943 | { 944 | QAngle ret(-x, -y, -z); 945 | return ret; 946 | } 947 | 948 | inline QAngle QAngle::operator+(const QAngle &v) const 949 | { 950 | QAngle res; 951 | res.x = x + v.x; 952 | res.y = y + v.y; 953 | res.z = z + v.z; 954 | return res; 955 | } 956 | 957 | inline QAngle QAngle::operator-(const QAngle &v) const 958 | { 959 | QAngle res; 960 | res.x = x - v.x; 961 | res.y = y - v.y; 962 | res.z = z - v.z; 963 | return res; 964 | } 965 | 966 | inline void QAngle::AngleVectors(const QAngle &angles, Vector *forward, Vector *right, Vector *up) 967 | { 968 | 969 | float sr, sp, sy, cr, cp, cy; 970 | 971 | SinCos(DEG2RAD(angles[YAW]), &sy, &cy); 972 | SinCos(DEG2RAD(angles[PITCH]), &sp, &cp); 973 | SinCos(DEG2RAD(angles[ROLL]), &sr, &cr); 974 | 975 | if (forward) 976 | { 977 | forward->x = cp * cy; 978 | forward->y = cp * sy; 979 | forward->z = -sp; 980 | } 981 | 982 | if (right) 983 | { 984 | right->x = (-1 * sr * sp * cy + -1 * cr * -sy); 985 | right->y = (-1 * sr * sp * sy + -1 * cr * cy); 986 | right->z = -1 * sr * cp; 987 | } 988 | 989 | if (up) 990 | { 991 | up->x = (cr * sp * cy + -sr * -sy); 992 | up->y = (cr * sp * sy + -sr * cy); 993 | up->z = cr * cp; 994 | } 995 | } 996 | 997 | //----------------------------------------------------------------------------- 998 | // Forward direction vector -> Euler angles 999 | //----------------------------------------------------------------------------- 1000 | inline void QAngle::VectorAngles(const Vector &forward, QAngle &angles) 1001 | { 1002 | float tmp, yaw, pitch; 1003 | 1004 | if (forward[1] == 0 && forward[0] == 0) 1005 | { 1006 | yaw = 0; 1007 | if (forward[2] > 0) 1008 | pitch = 270; 1009 | else 1010 | pitch = 90; 1011 | } 1012 | else 1013 | { 1014 | yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); 1015 | if (yaw < 0) 1016 | yaw += 360; 1017 | 1018 | tmp = sqrt(forward[0] * forward[0] + forward[1] * forward[1]); 1019 | pitch = (atan2(-forward[2], tmp) * 180 / M_PI); 1020 | if (pitch < 0) 1021 | pitch += 360; 1022 | } 1023 | 1024 | angles[0] = pitch; 1025 | angles[1] = yaw; 1026 | angles[2] = 0; 1027 | } 1028 | //----------------------------------------------------------------------------- 1029 | // Forward direction vector with a reference up vector -> Euler angles 1030 | //----------------------------------------------------------------------------- 1031 | inline void QAngle::VectorAngles(const Vector &forward, const Vector &pseudoup, QAngle &angles) 1032 | { 1033 | Vector left; 1034 | 1035 | CrossProduct(pseudoup, forward, left); 1036 | VectorNormalize(left); 1037 | 1038 | float xyDist = sqrtf(forward[0] * forward[0] + forward[1] * forward[1]); 1039 | 1040 | // enough here to get angles? 1041 | if (xyDist > 0.001f) 1042 | { 1043 | // (yaw) y = ATAN( forward.y, forward.x ); -- in our space, forward is the X axis 1044 | angles[1] = RAD2DEG(atan2f(forward[1], forward[0])); 1045 | 1046 | // The engine does pitch inverted from this, but we always end up negating it in the DLL 1047 | // UNDONE: Fix the engine to make it consistent 1048 | // (pitch) x = ATAN( -forward.z, sqrt(forward.x*forward.x+forward.y*forward.y) ); 1049 | angles[0] = RAD2DEG(atan2f(-forward[2], xyDist)); 1050 | 1051 | float up_z = (left[1] * forward[0]) - (left[0] * forward[1]); 1052 | 1053 | // (roll) z = ATAN( left.z, up.z ); 1054 | angles[2] = RAD2DEG(atan2f(left[2], up_z)); 1055 | } 1056 | else // forward is mostly Z, gimbal lock- 1057 | { 1058 | // (yaw) y = ATAN( -left.x, left.y ); -- forward is mostly z, so use right for yaw 1059 | angles[1] = RAD2DEG(atan2f(-left[0], left[1])); //This was originally copied from the "void MatrixAngles( const matrix3x4_t& matrix, float *angles )" code, and it's 180 degrees off, negated the values and it all works now (Dave Kircher) 1060 | 1061 | // The engine does pitch inverted from this, but we always end up negating it in the DLL 1062 | // UNDONE: Fix the engine to make it consistent 1063 | // (pitch) x = ATAN( -forward.z, sqrt(forward.x*forward.x+forward.y*forward.y) ); 1064 | angles[0] = RAD2DEG(atan2f(-forward[2], xyDist)); 1065 | 1066 | // Assume no roll in this case as one degree of freedom has been lost (i.e. yaw == roll) 1067 | angles[2] = 0; 1068 | } 1069 | } -------------------------------------------------------------------------------- /L4D2VR/sigscanner.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | class SigScanner 8 | { 9 | public: 10 | // Returns 0 if current offset matches, -1 if no matches found. 11 | // A value > 0 is the new offset. 12 | static int VerifyOffset(std::string moduleName, int currentOffset, std::string signature, int sigOffset = 0) 13 | { 14 | HMODULE hModule = GetModuleHandle(moduleName.c_str()); 15 | MODULEINFO moduleInfo; 16 | GetModuleInformation(GetCurrentProcess(), hModule, &moduleInfo, sizeof(moduleInfo)); 17 | 18 | uint8_t *bytes = (uint8_t *)moduleInfo.lpBaseOfDll; 19 | 20 | std::vector pattern; 21 | 22 | std::stringstream ss(signature); 23 | std::string sigByte; 24 | while (ss >> sigByte) 25 | { 26 | if (sigByte == "?" || sigByte == "??") 27 | pattern.push_back(-1); 28 | else 29 | pattern.push_back(strtoul(sigByte.c_str(), NULL, 16)); 30 | } 31 | 32 | int patternLen = pattern.size(); 33 | 34 | // Check if current offset is good 35 | bool offsetMatchesSig = true; 36 | for (int i = 0; i < patternLen; ++i) 37 | { 38 | if ( (bytes[currentOffset - sigOffset + i] != pattern[i]) && (pattern[i] != -1) ) 39 | { 40 | offsetMatchesSig = false; 41 | break; 42 | } 43 | } 44 | 45 | if (offsetMatchesSig) 46 | return 0; 47 | 48 | // Scan the dll for new offset 49 | for (int i = 0; i < moduleInfo.SizeOfImage; ++i) 50 | { 51 | bool found = true; 52 | for (int j = 0; j < patternLen; ++j) 53 | { 54 | if ((bytes[i + j] != pattern[j]) && (pattern[j] != -1)) 55 | { 56 | found = false; 57 | break; 58 | } 59 | } 60 | if (found) 61 | { 62 | return i + sigOffset; 63 | } 64 | } 65 | return -1; 66 | 67 | } 68 | }; -------------------------------------------------------------------------------- /L4D2VR/vr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "openvr.h" 3 | #include "vector.h" 4 | #include 5 | 6 | #define MAX_STR_LEN 256 7 | 8 | class Game; 9 | class IDirect3DTexture9; 10 | class IDirect3DSurface9; 11 | class ITexture; 12 | 13 | 14 | struct TrackedDevicePoseData 15 | { 16 | std::string TrackedDeviceName; 17 | Vector TrackedDevicePos; 18 | Vector TrackedDeviceVel; 19 | QAngle TrackedDeviceAng; 20 | QAngle TrackedDeviceAngVel; 21 | }; 22 | 23 | struct SharedTextureHolder 24 | { 25 | vr::VRVulkanTextureData_t m_VulkanData; 26 | vr::Texture_t m_VRTexture; 27 | }; 28 | 29 | 30 | class VR 31 | { 32 | public: 33 | Game *m_Game = nullptr; 34 | 35 | vr::IVRSystem *m_System = nullptr; 36 | vr::IVRInput *m_Input = nullptr; 37 | vr::IVROverlay *m_Overlay = nullptr; 38 | 39 | vr::VROverlayHandle_t m_MainMenuHandle; 40 | vr::VROverlayHandle_t m_HUDHandle; 41 | 42 | float m_HorizontalOffsetLeft; 43 | float m_VerticalOffsetLeft; 44 | float m_HorizontalOffsetRight; 45 | float m_VerticalOffsetRight; 46 | 47 | uint32_t m_RenderWidth; 48 | uint32_t m_RenderHeight; 49 | float m_Aspect; 50 | float m_Fov; 51 | 52 | vr::VRTextureBounds_t m_TextureBounds[2]; 53 | vr::TrackedDevicePose_t m_Poses[vr::k_unMaxTrackedDeviceCount]; 54 | 55 | Vector m_EyeToHeadTransformPosLeft = { 0,0,0 }; 56 | Vector m_EyeToHeadTransformPosRight = { 0,0,0 }; 57 | 58 | Vector m_HmdForward; 59 | Vector m_HmdRight; 60 | Vector m_HmdUp; 61 | 62 | Vector m_HmdPosLocalInWorld = { 0,0,0 }; 63 | 64 | Vector m_LeftControllerForward; 65 | Vector m_LeftControllerRight; 66 | Vector m_LeftControllerUp; 67 | 68 | Vector m_RightControllerForward; 69 | Vector m_RightControllerRight; 70 | Vector m_RightControllerUp; 71 | 72 | Vector m_ViewmodelForward; 73 | Vector m_ViewmodelRight; 74 | Vector m_ViewmodelUp; 75 | 76 | Vector m_HmdPosAbs = { 0,0,0 }; 77 | Vector m_HmdPosAbsPrev = { 0,0,0 }; 78 | QAngle m_HmdAngAbs; 79 | 80 | Vector m_HmdPosCorrectedPrev = { 0,0,0 }; 81 | Vector m_HmdPosLocalPrev = { 0,0,0 }; 82 | 83 | Vector m_SetupOrigin = { 0,0,0 }; 84 | Vector m_SetupOriginPrev = { 0,0,0 }; 85 | Vector m_CameraAnchor = { 0,0,0 }; 86 | Vector m_SetupOriginToHMD = { 0,0,0 }; 87 | 88 | float m_HeightOffset = 0.0; 89 | bool m_RoomscaleActive = false; 90 | 91 | Vector m_LeftControllerPosAbs; 92 | QAngle m_LeftControllerAngAbs; 93 | Vector m_RightControllerPosAbs; 94 | QAngle m_RightControllerAngAbs; 95 | 96 | Vector m_ViewmodelPosOffset; 97 | QAngle m_ViewmodelAngOffset; 98 | 99 | float m_Ipd; 100 | float m_EyeZ; 101 | 102 | Vector m_IntendedPositionOffset = { 0,0,0 }; 103 | 104 | enum TextureID 105 | { 106 | Texture_None = -1, 107 | Texture_LeftEye, 108 | Texture_RightEye, 109 | Texture_HUD, 110 | Texture_Blank 111 | }; 112 | 113 | ITexture *m_LeftEyeTexture; 114 | ITexture *m_RightEyeTexture; 115 | ITexture *m_HUDTexture; 116 | ITexture *m_BlankTexture = nullptr; 117 | 118 | IDirect3DSurface9 *m_D9LeftEyeSurface; 119 | IDirect3DSurface9 *m_D9RightEyeSurface; 120 | IDirect3DSurface9 *m_D9HUDSurface; 121 | IDirect3DSurface9 *m_D9BlankSurface; 122 | 123 | SharedTextureHolder m_VKLeftEye; 124 | SharedTextureHolder m_VKRightEye; 125 | SharedTextureHolder m_VKBackBuffer; 126 | SharedTextureHolder m_VKHUD; 127 | SharedTextureHolder m_VKBlankTexture; 128 | 129 | bool m_IsVREnabled = false; 130 | bool m_IsInitialized = false; 131 | bool m_RenderedNewFrame = false; 132 | bool m_RenderedHud = false; 133 | bool m_CreatedVRTextures = false; 134 | TextureID m_CreatingTextureID = Texture_None; 135 | 136 | bool m_PressedTurn = false; 137 | bool m_PushingThumbstick = false; 138 | 139 | // action set 140 | vr::VRActionSetHandle_t m_ActionSet; 141 | vr::VRActiveActionSet_t m_ActiveActionSet; 142 | 143 | // actions 144 | vr::VRActionHandle_t m_ActionJump; 145 | vr::VRActionHandle_t m_ActionPrimaryAttack; 146 | vr::VRActionHandle_t m_ActionSecondaryAttack; 147 | vr::VRActionHandle_t m_ActionReload; 148 | vr::VRActionHandle_t m_ActionWalk; 149 | vr::VRActionHandle_t m_ActionTurn; 150 | vr::VRActionHandle_t m_ActionUse; 151 | vr::VRActionHandle_t m_ActionNextItem; 152 | vr::VRActionHandle_t m_ActionPrevItem; 153 | vr::VRActionHandle_t m_ActionResetPosition; 154 | vr::VRActionHandle_t m_ActionCrouch; 155 | vr::VRActionHandle_t m_ActionFlashlight; 156 | vr::VRActionHandle_t m_ActionActivateVR; 157 | vr::VRActionHandle_t m_MenuSelect; 158 | vr::VRActionHandle_t m_MenuBack; 159 | vr::VRActionHandle_t m_MenuUp; 160 | vr::VRActionHandle_t m_MenuDown; 161 | vr::VRActionHandle_t m_MenuLeft; 162 | vr::VRActionHandle_t m_MenuRight; 163 | vr::VRActionHandle_t m_Spray; 164 | vr::VRActionHandle_t m_Scoreboard; 165 | vr::VRActionHandle_t m_ShowHUD; 166 | vr::VRActionHandle_t m_Pause; 167 | 168 | TrackedDevicePoseData m_HmdPose; 169 | TrackedDevicePoseData m_LeftControllerPose; 170 | TrackedDevicePoseData m_RightControllerPose; 171 | 172 | float m_RotationOffset = 0; 173 | std::chrono::steady_clock::time_point m_PrevFrameTime; 174 | 175 | float m_TurnSpeed = 0.3; 176 | bool m_SnapTurning = false; 177 | float m_SnapTurnAngle = 45.0; 178 | bool m_LeftHanded = false; 179 | float m_VRScale = 43.2; 180 | float m_IpdScale = 1.0; 181 | bool m_HideArms = false; 182 | float m_HudDistance = 1.3; 183 | float m_HudSize = 1.1; 184 | bool m_HudAlwaysVisible = false; 185 | 186 | VR() {}; 187 | VR(Game *game); 188 | int SetActionManifest(const char *fileName); 189 | void InstallApplicationManifest(const char *fileName); 190 | void Update(); 191 | void CreateVRTextures(); 192 | void SubmitVRTextures(); 193 | void RepositionOverlays(); 194 | void GetPoses(); 195 | void UpdatePosesAndActions(); 196 | void GetViewParameters(); 197 | void ProcessMenuInput(); 198 | void ProcessInput(); 199 | VMatrix VMatrixFromHmdMatrix(const vr::HmdMatrix34_t &hmdMat); 200 | vr::HmdMatrix34_t VMatrixToHmdMatrix(const VMatrix &vMat); 201 | vr::HmdMatrix34_t GetControllerTipMatrix(vr::ETrackedControllerRole controllerRole); 202 | bool CheckOverlayIntersectionForController(vr::VROverlayHandle_t overlayHandle, vr::ETrackedControllerRole controllerRole); 203 | QAngle GetRightControllerAbsAngle(); 204 | Vector GetRightControllerAbsPos(); 205 | Vector GetRecommendedViewmodelAbsPos(); 206 | QAngle GetRecommendedViewmodelAbsAngle(); 207 | void UpdateTracking(); 208 | Vector GetViewAngle(); 209 | Vector GetViewOriginLeft(); 210 | Vector GetViewOriginRight(); 211 | bool PressedDigitalAction(vr::VRActionHandle_t &actionHandle, bool checkIfActionChanged = false); 212 | bool GetAnalogActionData(vr::VRActionHandle_t &actionHandle, vr::InputAnalogActionData_t &analogDataOut); 213 | void ResetPosition(); 214 | void GetPoseData(vr::TrackedDevicePose_t &poseRaw, TrackedDevicePoseData &poseOut); 215 | void ParseConfigFile(); 216 | void WaitForConfigUpdate(); 217 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # L4D2 VR Prototype 2 | ### Use this mod at your own risk of getting VAC banned. Use the -insecure launch option to help protect yourself. (Also contains lots of flashing lights) 3 | 4 | #### [Video demo](https://www.youtube.com/watch?v=zU-8-9qe6wQ) 5 | 6 | ## Things that work 7 | * Singleplayer and multiplayer (see below) 8 | * 6DoF VR view 9 | * Motion controls for guns and melee weapons 10 | * Workshop content 11 | 12 | ## Things that need fixing 13 | 14 | * Interactions and throwables require you to aim with your face 15 | * Roomscale needs work 16 | * CPU is underutilized 17 | 18 | ## How to use 19 | 1. Download [L4D2VR.zip](https://github.com/sd805/l4d2vr/releases) and extract the files to your Left 4 Dead 2 directory (steamapps\common\Left 4 Dead 2) 20 | 2. Launch SteamVR, then launch Left 4 Dead 2 with these launch options: 21 | 22 | ``` -insecure -window -novid +mat_motion_blur_percent_of_screen_max 0 +crosshair 0 -w 1280 -h 720 +mat_queue_mode 0 +mat_vsync 0 +mat_antialias 0 +mat_grain_scale_override 0 ``` 23 | 24 | 3. At the menu, feel free to change [these video settings](https://i.imgur.com/yYQMXs6.jpg). 25 | 4. Load into a campaign. 26 | 5. To recenter the camera height, press down on the left stick. To see the HUD, aim the controller up or down. 27 | 28 | ## How to play multiplayer 29 | * The host must have the mod installed and the server must be set to local. Other players can play in VR too (if they also installed the mod). 30 | * To host a local server, click Play Campaign -> Play With Friends -> Create new campaign lobby -> Server Type: Local Server 31 | * You can make your game public if you want. 32 | * Versus works but it's barely been tested. 33 | 34 | ## Troubleshooting 35 | If the game isn't loading in VR: 36 | * Disable SteamVR theater in [Steam settings](https://external-preview.redd.it/1WdLExouo_YKhTGT6C5GGrOjeWO7qNdIdDRvIRBhw-0.png?auto=webp&s=0d4447a9d954e1ec15b2c010cf50eeabd51f4197) 37 | 38 | If the game is stuttering, try: 39 | * Steam Settings -> Shader Pre-Caching -> Allow background processing of Vulkan shaders 40 | 41 | If the game is crashing, try: 42 | * Lowering video settings 43 | * Disabling all add-ons then verifying integrity of game files 44 | * Re-installing the game 45 | 46 | ## Build instructions 47 | 1. ``` git clone --recurse-submodules https://github.com/sd805/l4d2vr.git ``` 48 | 2. Open l4d2vr.sln 49 | 3. Set to x86 Debug or Release 50 | 4. Build -> Build Solution 51 | 52 | Note: After building, it will attempt to copy the new d3d9.dll to your L4D2 directory. 53 | 54 | ## Utilizes code from 55 | * [VirtualFortress2](https://github.com/PinkMilkProductions/VirtualFortress2) 56 | * [gmcl_openvr](https://github.com/Planimeter/gmcl_openvr/) 57 | * [dxvk](https://github.com/TheIronWolfModding/dxvk/tree/vr-dx9-rel) 58 | * [source-sdk-2013](https://github.com/ValveSoftware/source-sdk-2013/) 59 | -------------------------------------------------------------------------------- /l4d2vr.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31727.386 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "L4D2VR", "L4D2VR\l4d2vr.vcxproj", "{C81EA18A-A8D0-40D2-900C-A91F736802D4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x64.ActiveCfg = Debug|x64 17 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x64.Build.0 = Debug|x64 18 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x86.ActiveCfg = Debug|Win32 19 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Debug|x86.Build.0 = Debug|Win32 20 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x64.ActiveCfg = Release|x64 21 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x64.Build.0 = Release|x64 22 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x86.ActiveCfg = Release|Win32 23 | {C81EA18A-A8D0-40D2-900C-A91F736802D4}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {9B18203D-EC63-469E-AE19-7B93F44EAF0B} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /thirdparty/minhook/include/MinHook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MinHook - The Minimalistic API Hooking Library for x64/x86 3 | * Copyright (C) 2009-2017 Tsuda Kageyu. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__) 32 | #error MinHook supports only x86 and x64 systems. 33 | #endif 34 | 35 | #include 36 | 37 | // MinHook Error Codes. 38 | typedef enum MH_STATUS 39 | { 40 | // Unknown error. Should not be returned. 41 | MH_UNKNOWN = -1, 42 | 43 | // Successful. 44 | MH_OK = 0, 45 | 46 | // MinHook is already initialized. 47 | MH_ERROR_ALREADY_INITIALIZED, 48 | 49 | // MinHook is not initialized yet, or already uninitialized. 50 | MH_ERROR_NOT_INITIALIZED, 51 | 52 | // The hook for the specified target function is already created. 53 | MH_ERROR_ALREADY_CREATED, 54 | 55 | // The hook for the specified target function is not created yet. 56 | MH_ERROR_NOT_CREATED, 57 | 58 | // The hook for the specified target function is already enabled. 59 | MH_ERROR_ENABLED, 60 | 61 | // The hook for the specified target function is not enabled yet, or already 62 | // disabled. 63 | MH_ERROR_DISABLED, 64 | 65 | // The specified pointer is invalid. It points the address of non-allocated 66 | // and/or non-executable region. 67 | MH_ERROR_NOT_EXECUTABLE, 68 | 69 | // The specified target function cannot be hooked. 70 | MH_ERROR_UNSUPPORTED_FUNCTION, 71 | 72 | // Failed to allocate memory. 73 | MH_ERROR_MEMORY_ALLOC, 74 | 75 | // Failed to change the memory protection. 76 | MH_ERROR_MEMORY_PROTECT, 77 | 78 | // The specified module is not loaded. 79 | MH_ERROR_MODULE_NOT_FOUND, 80 | 81 | // The specified function is not found. 82 | MH_ERROR_FUNCTION_NOT_FOUND 83 | } 84 | MH_STATUS; 85 | 86 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook, 87 | // MH_QueueEnableHook or MH_QueueDisableHook. 88 | #define MH_ALL_HOOKS NULL 89 | 90 | #ifdef __cplusplus 91 | extern "C" { 92 | #endif 93 | 94 | // Initialize the MinHook library. You must call this function EXACTLY ONCE 95 | // at the beginning of your program. 96 | MH_STATUS WINAPI MH_Initialize(VOID); 97 | 98 | // Uninitialize the MinHook library. You must call this function EXACTLY 99 | // ONCE at the end of your program. 100 | MH_STATUS WINAPI MH_Uninitialize(VOID); 101 | 102 | // Creates a hook for the specified target function, in disabled state. 103 | // Parameters: 104 | // pTarget [in] A pointer to the target function, which will be 105 | // overridden by the detour function. 106 | // pDetour [in] A pointer to the detour function, which will override 107 | // the target function. 108 | // ppOriginal [out] A pointer to the trampoline function, which will be 109 | // used to call the original target function. 110 | // This parameter can be NULL. 111 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal); 112 | 113 | // Creates a hook for the specified API function, in disabled state. 114 | // Parameters: 115 | // pszModule [in] A pointer to the loaded module name which contains the 116 | // target function. 117 | // pszProcName [in] A pointer to the target function name, which will be 118 | // overridden by the detour function. 119 | // pDetour [in] A pointer to the detour function, which will override 120 | // the target function. 121 | // ppOriginal [out] A pointer to the trampoline function, which will be 122 | // used to call the original target function. 123 | // This parameter can be NULL. 124 | MH_STATUS WINAPI MH_CreateHookApi( 125 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); 126 | 127 | // Creates a hook for the specified API function, in disabled state. 128 | // Parameters: 129 | // pszModule [in] A pointer to the loaded module name which contains the 130 | // target function. 131 | // pszProcName [in] A pointer to the target function name, which will be 132 | // overridden by the detour function. 133 | // pDetour [in] A pointer to the detour function, which will override 134 | // the target function. 135 | // ppOriginal [out] A pointer to the trampoline function, which will be 136 | // used to call the original target function. 137 | // This parameter can be NULL. 138 | // ppTarget [out] A pointer to the target function, which will be used 139 | // with other functions. 140 | // This parameter can be NULL. 141 | MH_STATUS WINAPI MH_CreateHookApiEx( 142 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); 143 | 144 | // Removes an already created hook. 145 | // Parameters: 146 | // pTarget [in] A pointer to the target function. 147 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget); 148 | 149 | // Enables an already created hook. 150 | // Parameters: 151 | // pTarget [in] A pointer to the target function. 152 | // If this parameter is MH_ALL_HOOKS, all created hooks are 153 | // enabled in one go. 154 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget); 155 | 156 | // Disables an already created hook. 157 | // Parameters: 158 | // pTarget [in] A pointer to the target function. 159 | // If this parameter is MH_ALL_HOOKS, all created hooks are 160 | // disabled in one go. 161 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget); 162 | 163 | // Queues to enable an already created hook. 164 | // Parameters: 165 | // pTarget [in] A pointer to the target function. 166 | // If this parameter is MH_ALL_HOOKS, all created hooks are 167 | // queued to be enabled. 168 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget); 169 | 170 | // Queues to disable an already created hook. 171 | // Parameters: 172 | // pTarget [in] A pointer to the target function. 173 | // If this parameter is MH_ALL_HOOKS, all created hooks are 174 | // queued to be disabled. 175 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget); 176 | 177 | // Applies all queued changes in one go. 178 | MH_STATUS WINAPI MH_ApplyQueued(VOID); 179 | 180 | // Translates the MH_STATUS to its name as a string. 181 | const char * WINAPI MH_StatusToString(MH_STATUS status); 182 | 183 | #ifdef __cplusplus 184 | } 185 | #endif 186 | -------------------------------------------------------------------------------- /thirdparty/minhook/lib/Debug/libMinHook.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/thirdparty/minhook/lib/Debug/libMinHook.x86.lib -------------------------------------------------------------------------------- /thirdparty/minhook/lib/Release/libMinHook.x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/thirdparty/minhook/lib/Release/libMinHook.x86.lib -------------------------------------------------------------------------------- /thirdparty/openvr/bin/win32/openvr_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/thirdparty/openvr/bin/win32/openvr_api.dll -------------------------------------------------------------------------------- /thirdparty/openvr/lib/win32/openvr_api.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sd805/l4d2vr/97b8f365b2d2e04510c81343de38c70fcec61ee7/thirdparty/openvr/lib/win32/openvr_api.lib --------------------------------------------------------------------------------