Advertisement
J16D

CLEO GTA - Draw a 2D line between 3D points

Feb 21st, 2016
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.81 KB | None | 0 0
  1. //- EXAMPLE
  2. {
  3. Draw a 2D line between 3D points
  4. by J16D
  5. }
  6.  
  7. while true
  8.     if   00E1:  player 0 pressed_key 6       /// ~k~~PED_LOCK_TARGET~
  9.     then
  10.         //- here put a code to get PED
  11.         if  056D:   actor 20@ defined
  12.         then
  13.             00A0: store_actor 20@ position_to 7@ 8@ 9@
  14.             00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
  15.             0AB1: @getScreenXYFrom3DCoords 3 coords_XYZ 7@ 8@ 9@ -> store_to 7@ 8@
  16.             0AB1: @getScreenXYFrom3DCoords 3 coords_XYZ 1@ 2@ 3@ -> store_to 1@ 2@
  17.             0AB1: @DRAW_LINE 9 POS 1@ 2@ _TO_ 7@ 8@ RGBA 255 255 255 255 THICKNESS 0.5
  18.         end
  19.        
  20.         //- here put a code to get CAR
  21.         if  056E:   car 20@ defined
  22.         then
  23.             00AA: store_car 20@ position_to 7@ 8@ 9@
  24.             00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
  25.             0AB1: @getScreenXYFrom3DCoords 3 coords_XYZ 7@ 8@ 9@ -> store_to 7@ 8@
  26.             0AB1: @getScreenXYFrom3DCoords 3 coords_XYZ 1@ 2@ 3@ -> store_to 1@ 2@
  27.             0AB1: @DRAW_LINE 9 POS 1@ 2@ _TO_ 7@ 8@ RGBA 255 255 255 255 THICKNESS 0.5
  28.         end
  29.  
  30.         //- here put a code to get OBJECT
  31.         if  03CA:   object 20@ exists
  32.         then
  33.             01BB: store_object 20@ position_to 7@ 8@ 9@
  34.             00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
  35.             0AB1: @getScreenXYFrom3DCoords 3 coords_XYZ 7@ 8@ 9@ -> store_to 7@ 8@
  36.             0AB1: @getScreenXYFrom3DCoords 3 coords_XYZ 1@ 2@ 3@ -> store_to 1@ 2@
  37.             0AB1: @DRAW_LINE 9 POS 1@ 2@ _TO_ 7@ 8@ RGBA 255 255 255 255 THICKNESS 0.5
  38.         end
  39.                
  40.     end
  41.  wait 0
  42. end
  43.  
  44. //-+-- CALL SCM helpers
  45. :DRAW_LINE
  46. //0AB1: @DRAW_LINE 9 POS 10.0 10.0 _TO_ 200.0 310.0 RGBA 255 0 0 255 THICKNESS 1.0
  47. 0087: 11@ = 2@ // (float)
  48. 0087: 12@ = 3@ // (float)
  49. 0509: 10@ = distance_between_XY 0@ 1@ and_XY 2@ 3@
  50. 10@ -= 37.0 {REMOVE STRANGE OFFSET AT END}
  51. 0063: 2@ -= 0@ // (float)
  52. 0063: 3@ -= 1@ // (float)
  53. 0604: get_Z_angle_for_point 2@ 3@  store_to 9@
  54. 9@ += 84.0
  55. 005B: 0@ += 11@
  56. 0@ /= 2.0    {MITTE} // get center pos
  57. 005B: 1@ += 12@
  58. 1@ /= 2.0
  59. 03F0: enable_text_draw 1
  60. 074B: draw_texture 666 position 0@ 1@ scale 10@ 8@ angle 9@ color 4@ 5@ 6@ 7@
  61. 0AB2: ret 0
  62.  
  63. :getScreenXYFrom3DCoords
  64. ////0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
  65. 0AC7: 14@ = var 0@ offset
  66. 0AC7: 15@ = var 3@ offset
  67. 0AC7: 16@ = var 6@ offset
  68. 0AC7: 17@ = var 9@ offset
  69. 0AA5: call 0x70CE30 num_params 6 pop 6 {18@ 18@} 0 0 17@ 16@ 15@ 14@
  70. 0007: 12@ = 640.0
  71. 0007: 13@ = 448.0
  72. 0A8D: 14@ = read_memory 0xC17044 size 4 virtual_protect 0
  73. 0A8D: 15@ = read_memory 0xC17048 size 4 virtual_protect 0
  74. 0093: 14@ = integer 14@ to_float
  75. 0093: 15@ = integer 15@ to_float
  76. 0073: 12@ /= 14@
  77. 0073: 13@ /= 15@
  78. 006B: 3@ *= 12@
  79. 006B: 4@ *= 13@
  80. 0AB2: ret 2 3@ 4@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement