• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Page 1 of 2 12 LastLast
    Results 1 to 10 of 17
    1. #1
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      VDV777's Avatar
      Join Date
      Mar 2013
      Posts
      92
      Thanks (-->)
      38
      Thanks (<--)
      0

      Please help\Tutorial World 2 Screen

      John Kittz
      Help create a class of "right."

      The source code of the tutorial below.
      Code:
      bool WorldToScreen(Vector3D World, float *ScreenX, float *ScreenY)
      {
          //Get the enemy position
          Vector3D Position = VectorSubtract(World, RefDef->Origin);
          Vector3D Transform;
      
          //Get the Dot Products from the View Angles of the player
          Transform.x = DotProduct(Position, RefDef->viewAxis[1]);
          Transform.y = DotProduct(Position, RefDef->viewAxis[2]);
          Transform.z = DotProduct(Position, RefDef->viewAxis[0]);
      
          //Make sure the enemy is in front of the player. If not, return.
          if (Transform.z < 0.1f)
              return false;
          
          //Calculate the center of the screen
          Vector2D Center = Vector2D((float)RefDef->Width * 0.5f, (float)RefDef->Height * 0.5f);
      
          //Calculates the screen coordinates
          *ScreenX = Center.x * (1 - (Transform.x / RefDef->fov.x / Transform.z));
          *ScreenY = Center.y * (1 - (Transform.y / RefDef->fov.y / Transform.z));
          
          return true;
      
      }
      RefDef - whatever address you have that stores your origin, view angles and view axis - how to do this ????
      DotProduct - What do you mean?





      Maybe someone will come in handy tutorial, but I can not figure out how to do this, please help with the source code.

      Spoiler: Tutorial World To Screen
      The source code is made on the basis of this article
      Before I start, I would like to put forth that I would count Math amoungst my worst subjects - and Geometry amoungst my worst fields in Math. This partially has to do with the fact I took Geometry back when I was in eight-grade, and that, like every thirteen year-old, I was an idiot who did not care about learning. As such, there might be mistakes in the method I am about to put forth; all I know is that it works, and that to my mind, it seems correct. Feel free to mention any mistakes you find.

      Consider the following scene; you are the entity marked "P," there is another entity marked "E," and there is the origin named "O:"
      Click image for larger version. 

Name:	1.jpg 
Views:	19 
Size:	116.4 KB 
ID:	1805


      Strip away the buildings and all the fancy graphical effects, and this boils down to:
      Click image for larger version. 

Name:	2.jpg 
Views:	5 
Size:	4.5 KB 
ID:	1806


      Now knowing this, how are we to translate the entity E's position into a 2D coordinate? Well the first measure is to understand what we actually mean. There is no way to directly translate a 3D coordinate into a 2D coordinate, just as there is no way to directly translate a cube into a square; however, notice the word "directly." Let us continue with the example of a cube - there obviously has to be a way to translate a cube into a square, or at least into a 2D space, otherwise something like:

      Click image for larger version. 

Name:	3.png 
Views:	142 
Size:	19.7 KB 
ID:	1807

      would simply not be possible. So how do we go about this? Whenever we choose to draw a 3D object on a 2D plane (such as paper), we must first pick a view-port, which is exactly what it sounds like - a static view of the scene with a fixed source. To turn a cube into a square, we simply pick the view-port to be directly facing one of the sides of the cube, as so:

      Click image for larger version. 

Name:	4.jpg 
Views:	3 
Size:	11.1 KB 
ID:	1808

      To model the earlier model (the common drawing that is used to represent a cube), we simply place the view-port so that it looks directly at one of the angles:

      Attachment 1809

      This same idea applies to any F.P.S.'s - in fact, it is central to the notion of them. Most modern F.P.S.'s conceive the illusion that as you move, you move your character around the map; this is simply not true. When "moving," all one is doing is adjusting their view-port in relation to the world. To track entity location then, most games make use of a series of 3D vectors that give the location of an entity relative to the origin of the map.

      Knowing this, let us now go back to original representation of our scene and make it more accurate:
      Click image for larger version. 

Name:	6.jpg 
Views:	4 
Size:	8.9 KB 
ID:	1810

      If we eliminate the Y-axis in our problem (we will assume the map is constantly flat), we can take a top down view of the above image, and greatly simplify our task:

      Attachment 1811

      Given that these two entities could be at any location on the map (even though we assume they are always in Quadrant I), it makes sense to stop trying to focus the scene around the map's origin, and instead makes sense to allow our entity P to be the origin - we can do this by subtracting our origin vector and the enemy's origin vector. The result will be the absolute distance of the entity E from the entity P.

      Assume vAbsDistance is a three dimensional vector. Let vAbsDistance be equal to:


      In relation to operations on vectors, let:

      The vector vAsbDistance will now be a vector from the origin to an object we will call E' (E prime):
      Click image for larger version. 

Name:	8.jpg 
Views:	2 
Size:	6.9 KB 
ID:	1812

      Now let us incorporate our view-port. Most games make use of either trio of angles that represent the yaw, pitch, and roll of a player's view-port relative to some origin (usually facing directly North or South, East or West, directly above or directly below) or a trio of 3D vectors that represent the same thing, but in vector format. For us, working with vectors is the easiest way for us to complete our task - luckily, these view-angles can be translated to vectors with some math.

      * Call of Duty 4 uses both of these methods; they are held in refdef->ViewAngles (a vec3_t) and refdef->ViewAxis (an array of vec3_t's) respectively. *

      * A vec3_t is nothing more than float[ 3 ]. *

      Imposing the vectors that represent the view-port, and assuming we are looking at the origins, we receive:

      Attachment 1813

      By eliminating the fluff, and separating the vectors, we are left with two vector compliments:

      Attachment 1814

      Enter the Dot Product. If we let A and B be two vectors, than the Dot Product is nothing more than ( A.x * B.x ) + ( A.y * B.y ) + ( A.z * B.z ). However, this value has some interesting attributes:

      Let A and B be two vectors, and let |A| and |B| be the length of A and B respectively, and let |A| and |B| not equal 0. Then:



      Where theta is the angle represented by the image below:
      https://s16.radikal.ru/i190/1305/4d/3f6bf8fb5176.png


      In our current example, this will give us the value that will represent the distance E' is away from our view-vector. As such, we will take the Dot Product of both sets of vectors, and store them appropriately.

      Assume vRightTransform and vForwardTransform are two floats. Let these equal:

      Code:
      vRightTransform = vAbsDistance . vRightView 
      vForwardTransform = vAbsDistance . vForwardView
      Now we quickly need to take a diversion to account for something - the Dot Product is signed operation, meaning it will work regardless of whether or not the vector is negative. Consider the case:
      https://s45.radikal.ru/i109/1305/d5/7d9cd0f02000.jpg


      In our following equation to transform our values to a 2D coordinate, we assume vForwardTransform is positive; as such, if the enemy is behind us, then our equation will give us the same value as if he was in front of us. To account for this fact, we will need to ensure that vForwardTransform is positive before continuing! Keep this in mind for later, when we code this!

      We are on to the final steps - let us now consider our problem focusing on our view-port:
      https://s56.radikal.ru/i154/1305/0f/f84af2ed6046.jpg


      In a picture I have now lost the link to, it was explained that X is equal to the result of:

      https://i024.radikal.ru/1305/b5/b2028aab2530.jpg

      This of course can be reduced to:
      Code:
      X = C + [ (C * X') / (Z'* FOV) ]
      We, of course, have X' and Z' as result of our operations with the Dot Product - in addition, C and FOV are held in refdef->Width / 2 and refdef->FOVx respectively. Letting centerX equal refdef->Width / 2, this becomes:
      Code:
      X = centerX +(( centerX * vRightTransform )/( vForwardTransform * refdef->FOVx))
      As such, we have concluded our series of steps to get our 2D coordinate (in the X-Axis, at least):

      Code:
      vAbsDistance = vEnemy - vPlayer
      
      vRightTransform   = vAbsDistance . vRightView 
      vForwardTransform = vAbsDistance . vForwardView 
      
      if( vForwardTransform < 0)
              return
      
      Let centerX = refdef->Width/2
      
      X = centerX +(( centerX * vRightTransform )/( vForwardTransform * refdef->FOVx))

      tutorial is copy \ past


      p.s. You tell Improve knowledge c + +, but this is not taught anywhere else. Hacks into love. want to make hacks. Please help with the source code.
      Last edited by VDV777; 05-07-2013 at 02:36 PM.

    2. #2
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      VDV777's Avatar
      Join Date
      Mar 2013
      Posts
      92
      Thanks (-->)
      38
      Thanks (<--)
      0
      Vector 3d - not understand it, hike x, y, z enemy - x, y, z my
      VectorSubtract - do not understand the difference between a campaign 2x vectors: the enemy of my
      DotProduct - x * y * z or something like that, too, it is not clear
      RefDef - it is a separate class that contains the coordinates, angle and so forth, but also fully understand that as a yes
      viewAxis - view along the axis - how to properly calculate not understand, can anyone help
      Vector2D - I do not know how to calculate

    3. #3
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      How about you go and get your linear algebra straight, this ain't no math class here mate. Should've paid more attention in school

      PS: Most of the functions purposes used here are very well explained on the web, just a little effort of google and you've got them all. Don't expect to get your W2S working straight off the bat, start with radars or something more simple if you are not that used to math.
      Please help\Tutorial World 2 Screen

    4. #4
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      VDV777's Avatar
      Join Date
      Mar 2013
      Posts
      92
      Thanks (-->)
      38
      Thanks (<--)
      0
      Quote Originally Posted by c5 View Post
      How about you go and get your linear algebra straight, this ain't no math class here mate. Should've paid more attention in school

      PS: Most of the functions purposes used here are very well explained on the web, just a little effort of google and you've got them all. Don't expect to get your W2S working straight off the bat, start with radars or something more simple if you are not that used to math.
      Mathematics nothing to do with, you know what to expect ...

    5. #5
      Kim Kong Trasher
      I don't have status.
       
      Raging
       
      c5's Avatar
      Join Date
      Jul 2012
      Location
      Mankei Iland
      Posts
      1,221
      Thanks (-->)
      97
      Thanks (<--)
      491
      Quote Originally Posted by VDV777 View Post
      Mathematics nothing to do with, you know what to expect ...
      It's all about mathematics.. And as said, there's no 100% universal method for doing this, it's up to you to adapt these different methods onto your games.
      Last edited by c5; 05-08-2013 at 03:25 PM.
      Please help\Tutorial World 2 Screen

    6. #6
      Jr.Coder
      Learning to hack games!
       
      Feeling Normal
       
      VDV777's Avatar
      Join Date
      Mar 2013
      Posts
      92
      Thanks (-->)
      38
      Thanks (<--)
      0
      Quote Originally Posted by c5 View Post
      It's all about mathematics.. And as said, there's no 100% universal method for doing this, it's up to you to adapt these different methods onto your games.
      what is the Vector? it is a distance from of point A to Point B (A*B) - is right?
      what is the Vector 3d?? It is a distance of (from point X to point X1(X*X1)) + (from point Y to point Y1(Y*Y1)) + (from point Z to point Z1(Z*Z1)) - is right?

    7. #7
      RTFM
      Shootin Pool!
       
      Coding
       
      Syperus's Avatar
      Join Date
      Oct 2012
      Location
      127.0.0.1
      Posts
      436
      Thanks (-->)
      101
      Thanks (<--)
      131
      Quote Originally Posted by VDV777 View Post
      Mathematics nothing to do with, you know what to expect ...
      c5 is right. It's all mathematics. Even PocketMonster told you it was mathematics here. Read up on some Algebra. Not to beat a dead horse here, but pretty much everything in this world can be narrowed down to mathematics. Math is very important, especially if you're going to be programming. Good Luck!
      Blacks Ops Zombies, BioShock Infinite Array of Bytes
      "People say I'm a bad influence. I say the world's already fucked, I'm just adding to it" -Eminem

    8. #8
      Coder
      Learning to hack games!
       
      Feeling Normal
       
      xploiitz's Avatar
      Join Date
      Jul 2012
      Posts
      125
      Thanks (-->)
      4
      Thanks (<--)
      15
      This part of an aimbot or ESP is ALL about math... this is actually very neat stuff if youre interested in mathematics, I just finished my Calculus 3 course this past semester and its really fascinating how it all ties into this! Ofcourse the stuff in this tutorial is very very very basic compared to what we went over in class (infact its not very applicable , very theoretical and kinda useless, but nonetheless I feel knowledgeable enough to give a small little primer below)

      Anyway: the dot product of two vectors gives you a scalar number (always) its just sum of the components multiplied together
      example Vector 1 <1, 2, 3> Vector 2 <3, 2, 1>
      so V1 • V2 is X1*X2 + Y1 * Y2 + Z1 * Z2 = 1 * 3 + 2 * 2 + 3 * 1 = 3 + 4 + 3 = 10!

      But what does this 10 mean?

      The scalar result you get from the dot product of two vectors basically tells you if they are perpendicular or not, so if V1 • V2 = 0 , then you know they are perpendicular to each other (at right angles)
      If the Angle between V1 and V2 are less than 90 degress the dot product will be positive (greater than zero) like in the example I gave.
      if the Angle between V1 and V2 are greater than 90 degrees the dot product will be negative( less than zero).

      another way to rewrite this V1 • V2 = |A| * |B| * Cos(Θ)
      in other words, the dot product of two vectors will be equal to the cosine of the angle between the vectors, times the length of each of the vectors
      the |A| means the magnitude of the Vector A. its the square root of the sum of the components squared... |A| = sqrt( X^2 + Y^2 + Z^2)

      Incase anyone forgot their trigonometry...

      Sin = Opposite / Hypotenuse ........ Y/R
      Cos = Adjacent / Hypotenuse........ X/R
      Tan = Opposite / Adjacent ............ Y/X

      R is radius (from the famous unit circle)

      The 3D distance formula is the same exact formula as the 2D distance formula, with a Z component since we are dealing with games in 3D space.

      if you have 2 3D vectors A and B <1,2,3> and <4,5,6> then the distance between these two vectors will be
      sqrt( (X2-X1)^2 + (Y2-Y1)^2 + (Z2- Z1)^2)) = sqrt(3^2 + 3^2 + 3^2) = sqrt (9 + 9 + 9) = sqrt(27) = about 5.196

      Another interesting thing that isnt mentioned in this tutorial is the cross product (only applicable to 3D coordinate systems)
      essentially what happens when you cross two vectors is you get a 3rd vector that is normal to both of the vectors you just crossed
      by normal I mean perpendicular ( at 90 degrees)

      A B = [(a2b3 – a3b2) (a3b1 – a1b3) (a1b2 – a2b1)]

      You can use the dot product to calculate how much to rotate, and the cross product to determine which way to rotate.
      Additionally, the cross product is often used for finding an objects forward, up or right facing sides (vector)

      I love Mathematics, its been my favorite subject in college so far....

      I could draw up some triangles for yall sometime to help make more sense of it if needed. But I hoped this cleared some things up!
      or maybe even a youtube recording or something? Dunno.... would have to show enough interest!

      Either way I hope this helped you guys understand it a little better
      Last edited by xploiitz; 05-12-2013 at 03:26 AM.

    9. Thanks Fleep, VDV777 thanked for this post
    10. #9
      Hacker
      Learning to hack games!
       
      Pawning
       
      Fleep's Avatar
      Join Date
      May 2012
      Posts
      626
      Thanks (-->)
      208
      Thanks (<--)
      727
      Excellent post @xploiitz I think if you went over that information and how it could be applied many people(including me) would greatly appreciate it.
      Some graphics or a Youtube video would be awesome.

      Fleep

    11. #10
      Coder
      Learning to hack games!
       
      Feeling Normal
       
      xploiitz's Avatar
      Join Date
      Jul 2012
      Posts
      125
      Thanks (-->)
      4
      Thanks (<--)
      15
      Cheats'n'Trainers
      awesome. I'll see if I can borrow my friends bamboo board this week, ill make a video of he lets me borrow it for a day or two.
      Should be fun, I love teaching Math to people haha.

    Page 1 of 2 12 LastLast

    Similar Game Hacker Threads

    1. [Tutorial] Alternate for external World to screen
      By kaz in forum ESP - WorldToScreen - ViewMatrix
      Replies: 6
      Last Post: 03-19-2017, 07:45 PM
    2. [Source Code] [OpenGL] World To Screen
      By [GH]Rake in forum Direct-X, OpenGL
      Replies: 4
      Last Post: 07-04-2015, 02:30 PM
    3. World To Screen.
      By simonpaa in forum Hacking Help
      Replies: 6
      Last Post: 01-22-2015, 03:43 PM
    4. World to screen coordinates?
      By acss in forum Hacking Help
      Replies: 6
      Last Post: 11-09-2013, 07:43 AM

    Tags for this Thread