Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Camera modificiation - adding roll rotation

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
thunderchild
How do I cheat?
Reputation: 0

Joined: 16 Feb 2018
Posts: 3

PostPosted: Fri Feb 16, 2018 8:46 am    Post subject: Camera modificiation - adding roll rotation Reply with quote

Hello all.

I am making a free camera mod for a strategy game. I was able to find all camera related stuff - x, y, z, zoom, yaw and pitch angles - and I was able to track angle limiter functions and deactivate them. I am able to modify the values via a braindead C# console app so that's some success for messing with memory stuff for a first time.

Now, I am wondering if it is possible to introduce roll rotation. As the roll angle is not present in the game structure, I suppose I will need to somehow intercept direct3d calls and squeeze desired value there. That's where I would like to ask for an advice as my knowledge of direct3d is close to zero.

My main questions are:
1) Is described method possible/viable?
I have no idea how direct3d renders stuff, so maybe that approach will not work at all for reasons. Maybe it will work partially because some stuff will be clipped out of the frame or for whatever other reason I have no awareness of.

2) What functions should I look for and how?
It's a d3d9 game, so I suppose D3DXMatrixLookAtLH/RH is one I'm looking for? Is it possible to look for a function name using CE? Or I follow "what accesses this memory address" routine for camera coordinates? When I was looking for camera coordinates, I stumbled upon a number of look-alike values, which over time matched the camera position, maybe these are worth looking into?

3) Can I just do a redneck memory editing or I should implement wrapper/hook/injection mumbo-jumbo?
I suppose I can just go with memory editing unless there is strong reason to not do it.

Thanks for the feedback!
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8515
Location: 127.0.0.1

PostPosted: Fri Feb 16, 2018 8:23 pm    Post subject: Reply with quote

1. Possible yes, viable depends on how the game is handling the camera data. You would be best off debugging and tracing back to where the raw matrix and such is handled vs. whats stored in memory as-is. There is potentially a removal of the value either because its not needed or is never going to be something other than a set value.

2. Camera data is generally handled via projections/transforms. There is a ton of information regarding Direct3D on the web, especially for D3D9 as it was one of the longer lasting versions of it. There are tutorials and such that show how to use transforms and such to make various types of cameras (first-person, third-person, chase, static etc.) which should help you understand how the math behind them is handled and what functions are commonly involved.

3. If you can find where the functions are that handle the overall view you should be able to do a simple code-cave to introduce some altered math into the end result vs. having to do a full on hook/wrapper. Overall it is up to you which you use based on the other purposes of the project if you plan to involve more than just the camera. Such as an in-game UI to edit the camera data.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
thunderchild
How do I cheat?
Reputation: 0

Joined: 16 Feb 2018
Posts: 3

PostPosted: Sat Feb 17, 2018 11:18 am    Post subject: Reply with quote

Thanks, atom0s, that was really helpful. I was able to locate several matrices and corresponding functions. There were as well two curious float variables which were responsible for roll rotation in certain camera positions - at least some proof that it can be done.

I think I have located the crucial function named UpdateMatrices which calls following as well:
MatrixPerspectiveFovLH
MatrixLookAtLH
MatrixInversePerspectiveFovLH
MatrixInverseLookAtLH
CalculateFrustumPlanes

If I follow UpdateMatrices, MatrixLookAtLH is built before any other matrix so I guess it's the one I'm looking for. Looks like that from now on I just need to follow debugger to figure out how they are built (or read d3d specs), nullify generation in original functions and overwrite stored matrices with my own program.

Edit: picture not relevant anymore.


Last edited by thunderchild on Sun Feb 18, 2018 7:39 pm; edited 1 time in total
Back to top
View user's profile Send private message
thunderchild
How do I cheat?
Reputation: 0

Joined: 16 Feb 2018
Posts: 3

PostPosted: Sun Feb 18, 2018 7:37 pm    Post subject: Reply with quote

I managed to achieve the goal. I'll post some remarks in case someone will have similar problem.

I ended up building all the matrices myself, so a read-up on Direct3D math is indeed necessary.

The game uses LookAt camera, so from positions of object and camera LookAtLH matrix can be built. Camera position needs to be calculated from object position using pitch, yaw and zoom of the camera as game will use camera position to properly update lighting.

Camera zoom is as well used in defining near and far values, which, together with screen resolution, are used to build PerspectiveFovLH matrix.

LookAt and PerspectiveFov matrix multiplication produces matrix responsible for objects orientation, inverted LookAt and inverted PerspectiveFov multiplication - for "background" orientation.

In order to implement roll rotation, LookAt matrix should be updated by multiplying it by rotation-around-Z matrix.

Nullifying functions responsible for matrix generation and overwriting memory with self-generated matrices worked just fine - game was able to generate frustum planes from injected matrices.



result.png
 Description:
 Filesize:  84.12 KB
 Viewed:  5758 Time(s)

result.png


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites