Advertisement
Guest User

QTS no. 19 - Primitive 3D shape drawing function

a guest
Aug 14th, 2010
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 19 - Primitive 3D shape drawing function
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21. //------------------------------------//
  22. void BoundingShape( FVect3 vPos, DWORD dwWidth, DWORD dwHeight, DWORD dwSides, float fRotation )
  23. {
  24.     POINT* ptBase = new POINT[ dwSides + 1 ]; // make points to draw to
  25.     POINT* ptTop  = new POINT[ dwSides + 1 ];
  26.  
  27.     FVect3 vBaseSquare  = vPos;
  28.     FVect3 vTopSquare   = vPos;
  29.  
  30.     vTopSquare.y += dwHeight; // height of box
  31.  
  32.     for( int i = 0; i < dwSides; i++ )
  33.     {
  34.         vBaseSquare.x = ( cosf( fRotation ) * dwWidth ) + vPos.x;
  35.         vBaseSquare.z = ( sinf( fRotation ) * dwWidth ) + vPos.z;
  36.  
  37.         vTopSquare.x = vBaseSquare.x;
  38.         vTopSquare.z = vBaseSquare.z;
  39.  
  40.         ptBase[ i ] = CDraw.World2Screen( vBaseSquare );
  41.         ptTop [ i ] = CDraw.World2Screen( vTopSquare );
  42.  
  43.         fRotation += PI_SQUARED/dwSides; // offset
  44.     }
  45.  
  46.     ptBase[ dwSides ] = ptBase[ 0 ]; // set finishing point
  47.     ptTop [ dwSides ] = ptTop [ 0 ];
  48.  
  49.     for( int i = 0; i < dwSides; i++ ) // Draw Bottom
  50.         CDraw.Line( ptBase[ i ].x, ptBase[ i ].y, ptBase[ i + 1 ].x, ptBase[ i + 1 ].y, 1, CDraw.m_coRed );
  51.  
  52.     for( int i = 0; i < dwSides; i++ ) // Draw top
  53.         CDraw.Line( ptTop[ i ].x, ptTop[ i ].y, ptTop[ i + 1 ].x, ptTop[ i + 1 ].y, 1, CDraw.m_coRed );
  54.  
  55.     for( int i = 0;+ i < dwSides; i++ ) // Draw lines from bottom to top
  56.         CDraw.Line( ptBase[ i ].x, ptBase[ i ].y, ptTop[ i ].x, ptTop[ i ].y, 1, CDraw.m_coRed );
  57. }
  58. //------------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement