OpenNFS / NFSHSX

Need for Speed: High Stakes Disassembly translated to C source code.
38 stars 4 forks source link

For someone who knows the code well, would you be able to show me the cockpit camera code and help me code mouselook in? #3

Open psychedelify opened 2 years ago

psychedelify commented 2 years ago

I am currently trying to run NFS4 in VR, It won't work in full VR mode due to the fact that VorpX's head tracking is tied to a mouselook in cockpit kind of like GTA5's first person mode. I know it will be jank as hell, but i want to add mouselook to NFS4's cockpit mode so that I can achieve proper head tracking. If compiled, will NFSHSX even run? i made my first github account right now just to ask this question, I'm not the most experienced programmer but I have quite alot of programming problems i need to solve, this being the most basic one, i feel like it would be a good introduction into programming world, before i start making VST plugins LOL

AmrikSadhra commented 2 years ago

Howdy! I'd definitely consider starting with the VST plugins 😅 This project doesn't compile in its current form, and would need quite a beating to do so.

To achieve something like this, you'd need to do it above the 3rash API layer, as the renderer accepts transformed vertices - there isn't a view matrix you could easily manipulate via a hook. Rather, follow any tutorial on how to find this matrix, and then you can go about manipulating it using the headset data provided by VorpX.

psychedelify commented 2 years ago

Have you heard of people being able to manipulate it with headset data?

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Amrik Sadhra @.> Sent: Wednesday, May 25, 2022 6:44:13 PM To: OpenNFS/NFSHSX @.> Cc: psychedelify @.>; Author @.> Subject: Re: [OpenNFS/NFSHSX] For someone who knows the code well, would you be able to show me the cockpit camera code and help me code mouselook in? (Issue #3)

Howdy! I'd definitely consider starting with the VST plugins 😅 This project doesn't compile in its current form, and would need quite a beating to do so.

To achieve something like this, you'd need to do it above the 3rash API layer, as the renderer accepts transformed vertices - there isn't a view matrix you could easily manipulate via a hook. Rather, follow anyhttps://youtu.be/-WL1Gpe9VRo tutorial on how to find this matrix, and then you can go about manipulating it using the headset data provided by VorpX.

— Reply to this email directly, view it on GitHubhttps://github.com/OpenNFS/NFSHSX/issues/3#issuecomment-1137919352, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZK3QSIYQVKQW2ZZGDVOOSDVL2UL3ANCNFSM5W6SKBVQ. You are receiving this because you authored the thread.Message ID: @.***>

psychedelify commented 2 years ago

Thank you dearly! So this would run over an already compiled nfs version i would assume? What do you mean specifically by 3rash api layer? I don't know what an api is even yet, i will look into them. If you wouldn't mind explaining it to me i would really appreciate it, i am pretty solid with tech just not so much with under the hood stuff. If you tell me the concept and the application of it in this manner, it'll click.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Jesse Cook @.> Sent: Wednesday, May 25, 2022 7:29:22 PM To: OpenNFS/NFSHSX @.>; OpenNFS/NFSHSX @.> Cc: Author @.> Subject: Re: [OpenNFS/NFSHSX] For someone who knows the code well, would you be able to show me the cockpit camera code and help me code mouselook in? (Issue #3)

Have you heard of people being able to manipulate it with headset data?

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Amrik Sadhra @.> Sent: Wednesday, May 25, 2022 6:44:13 PM To: OpenNFS/NFSHSX @.> Cc: psychedelify @.>; Author @.> Subject: Re: [OpenNFS/NFSHSX] For someone who knows the code well, would you be able to show me the cockpit camera code and help me code mouselook in? (Issue #3)

Howdy! I'd definitely consider starting with the VST plugins 😅 This project doesn't compile in its current form, and would need quite a beating to do so.

To achieve something like this, you'd need to do it above the 3rash API layer, as the renderer accepts transformed vertices - there isn't a view matrix you could easily manipulate via a hook. Rather, follow anyhttps://youtu.be/-WL1Gpe9VRo tutorial on how to find this matrix, and then you can go about manipulating it using the headset data provided by VorpX.

— Reply to this email directly, view it on GitHubhttps://github.com/OpenNFS/NFSHSX/issues/3#issuecomment-1137919352, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZK3QSIYQVKQW2ZZGDVOOSDVL2UL3ANCNFSM5W6SKBVQ. You are receiving this because you authored the thread.Message ID: @.***>

AmrikSadhra commented 2 years ago

I'll provide a brief overview for your purposes, but would recommend you do some further reading around elsewhere around the concepts of dynamic linking, shared libraries, APIs and 3D graphics programming .

Oftentimes you'll find '.dll' files in a games installation folder, that provide a way of updating libraries (functionality provided to help the programmer) without recompiling the games executable. The interface to those libraries is defined by an "application programming interface" or API, and the NFS executable only needs to understand that interface, not the implementation within the lib. The implementation within the library is mapped into the virtual address space of the process. Modern examples include OpenSSL, DirectX and PhysX, but the list goes on.

3rash was a dynamically linked library designed to ease interaction with the many video cards of the late 90's. Vendors each had their own APIs, rather than the unified DirectX/Vulkan/OpenGL of today. 3rash abstracts those individual vendor APIs to a common interface to ease development, and NFS3/4/5 interact purely with 3rash to draw to the screen. Think of functions along the lines of drawRectangle/drawTriangle/clear.

It is trivial to compile a dummy DLL to capture the calls to the 3rash library, modify the passed parameters (or ignore them entirely), and then call the true DLL for that function. This approach will not help you here, as the game's world is transformed to triangles in screen space internally, and hence the view matrix does not cross this 'interceptable' barrier as it would for some earlier immediate mode graphics APIs (OpenGL1, <=DX9). Manipulation of the view matrix enables movement of the games camera, from a rendering perspective. The game would still perform culling and game logic based on it's internal representation of the view matrix.

You'll therefore have to search for it within the memory of the running NFS process, and patch it there at the appropriate time in the frame! So yes, this is running on an "already compiled" NFS version. Good luck!

psychedelify commented 2 years ago

Thank you dearly! Will look into how to search for and patch within memory now! Appreciate the time and care given to this predicament of mine :)

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Amrik Sadhra @.> Sent: Thursday, May 26, 2022 5:37:24 AM To: OpenNFS/NFSHSX @.> Cc: psychedelify @.>; Author @.> Subject: Re: [OpenNFS/NFSHSX] For someone who knows the code well, would you be able to show me the cockpit camera code and help me code mouselook in? (Issue #3)

I'll provide a brief overview for your purposes, but would recommend you do some further reading around elsewhere around the concepts of dynamic linking, shared libraries, APIs and 3D graphics programming .

Oftentimes you'll find '.dll' files in a games installation folder, that provide a way of updating libraries (functionality provided to help the programmer) without recompiling the games executable. The interface to those libraries is defined by an "application programming interface" or API, and the NFS executable only needs to understand that interface, not the implementation within the lib. The implementation within the library is mapped into the virtual address space of the process. Modern examples include OpenSSL, DirectX and PhysX, but the list goes on.

3rash was a dynamically linked library designed to ease interaction with the many video cards of the late 90's. Vendors each had their own APIs, rather than the unified DirectX/Vulkan/OpenGL of today. 3rash abstracts those individual vendor APIs to a common interface to ease development, and NFS3/4/5 interact purely with 3rash to draw to the screen. Think of functions along the lines of drawRectangle/drawTriangle/clear.

It is trivial to compile a dummy DLL to capture the calls to the 3rash library, modify the passed parameters (or ignore them entirely), and then call the true DLL for that function. This approach will not help you here, as the game's world is transformed to triangles in screen space internally, and hence the view matrix does not cross this 'interceptable' barrier as it would for some earlier immediate mode graphics APIs (OpenGL1, <=DX9). Manipulation of the view matrix enables movement of the games camera, from a rendering perspective. The game would still perform culling and game logic based on it's internal representation of the view matrix.

You'll therefore have to search for it within the memory of the running NFS process, and patch it there at the appropriate time in the frame! So yes, this is running on an "already compiled" NFS version. Good luck!

— Reply to this email directly, view it on GitHubhttps://github.com/OpenNFS/NFSHSX/issues/3#issuecomment-1138348349, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AZK3QSJ74OHKRSMVQT6GE73VL5A5JANCNFSM5W6SKBVQ. You are receiving this because you authored the thread.Message ID: @.***>