| View previous topic :: View next topic |
| Author |
Message |
lolOkayBailolOkayBailolOk Master Cheater
Reputation: 1
Joined: 23 Jun 2007 Posts: 307
|
Posted: Mon Aug 02, 2010 6:33 pm Post subject: Converting World Space to Screen coordinates? |
|
|
I have been playing several FPS games now, most of which I have been able to find the following information:
* Pitch, yaw, roll (of my character)
* X, Y, Z (of my character)
* X, Y, Z (of enemy)
* Name of enemy (and usually will find his health, armor, ammo, etc near the name)
With a little modifications, I usually have a simple (not accurate, but simple) aimbot use all of the above information. I never actually used anything from D3D API to display or change anything in a game (for the Direct3D games of course).
However I want to display the name of enemies with text on the enemy position. Now for 2D games I find this extremely simple ((1366 * enemyX) / gameWidth) = Screen X coordinate, 1366 is a constant for my screen width)
But 3D games have X, Y, and Z. How would I find the the required screen coordinates if I have there world space coordinates?
(Would I need "Camera FOV" or Camera coordinates, I haven't been able to find FOV for any game but camera coordinates should correspond somewhere close the player coordinates I assume)
(Sorry if this post may seem vague, or if the answer is a simple calculation)
Here is a picture of what I mean:
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Aug 02, 2010 7:33 pm Post subject: |
|
|
Object space -> World space -> View space -> Projection, (clip then homogeneous, as in normalized -1 to 1) -> Screen space
The D3DX library provides all the functions you need to build the matrices
|
|
| Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 893
|
Posted: Mon Aug 02, 2010 8:34 pm Post subject: |
|
|
Slovach's suggestion to use a projection transformation is correct, but there are many different approaches to projection. You can get an easy approximation by simply disregarding the depth and applying scalar factors to compensate for screen dimensions. Beyond that, you can do more complex projections with a little trig and an imaginary wall in front of your player on which to project the labels. You find the intersection of a ray between the player and your plane (frustrum), and that's where you draw your label. The field of view is defined by the clipping rectangle that your game's viewable screen intersects with your frustrum.
Cheers,
adude
|
|
| Back to top |
|
 |
lolOkayBailolOkayBailolOk Master Cheater
Reputation: 1
Joined: 23 Jun 2007 Posts: 307
|
Posted: Tue Aug 03, 2010 11:58 am Post subject: |
|
|
Thanks for the input guys! Really appreciate it.
First test:
http://www.youtube.com/watch?v=mCJEDY5WQ1U
(The ESP completely blanks when behind a wall, but I have an idea to prevent this occlusion)
Now I'm going to do some adjusting and find the rest of the NPCs.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Aug 03, 2010 1:30 pm Post subject: |
|
|
| Not sure what you mean by ESP getting blanked out, is the problem in the video?
|
|
| Back to top |
|
 |
lolOkayBailolOkayBailolOk Master Cheater
Reputation: 1
Joined: 23 Jun 2007 Posts: 307
|
Posted: Tue Aug 03, 2010 2:45 pm Post subject: |
|
|
Sorry for my English
I mean the models and text are hidden when I face a wall with greater depth then the surrounding walls.
Here is what I mean:
http://www.youtube.com/watch?v=JDamgtZf0N8
I'm suspecting occlusion, and my theory was to do not render depth but that doesn't solve it.
|
|
| Back to top |
|
 |
|