透視投影のやり方

Last-modified: 2015-05-03 (日) 21:31:25

2@ 3@ 4@が対象のxyz座標、5@6@が画面上に投影した時の画面上の座標。

 {$VERSION 3.1.0023}
  {$CLEO .cs}
  thread 'healthhud'
  {
  012 temp
  345
  678
  91011
  121314 temp_main
  15 the_obj
  16
  17
  18
  19
  202122
  232425
  262728 get_actor get_obj get_other...
  293031
  32
  33
  }
  :main
  wait 0
  03F0: enable_text_draw 0
  gosub @settei
  gosub @get_actor
  if
  03CA: (check) object 15@ exists
  then
      0108: destroy_object 15@
  end
  jump @main
  //////////////sub///////////////////
  :settei
  if
  8248: (check) not model 1582 available
  then
      0247: load_model 1582
      038B: load_requested_models
      while 8248:   not model 1582 available
          wait 0
      end
  end
  0107: 15@ = create_object 1582 at 0.0 0.0 0.0
  09CA: set_object 15@ immunities BP 1 FP 1 EP 1 CP 1 MP 1
  0750: set_object 15@ visibility 0
  068E: get_camera_target_point_to 2@ 3@ 4@
  068D: get_camera_position_to 5@ 6@ 7@
  0063: 2@ -= 5@ // (float)
  0063: 3@ -= 6@ // (float)
  0063: 4@ -= 7@ // (float)
  0087: 28@ = 2@ // (float)
  0087: 29@ = 3@ // (float)
  gosub @atan
  0509: 28@ = distance_between_XY 2@ 3@ and_XY 0.0 0.0
  0087: 29@ = 4@ // (float)
  0087: 4@ = 27@ // (float)
  gosub @atan
  0087: 2@ = 27@ // (float)
  000B: 2@ += -270.0
  0013: 2@ *= -1.0
  0453: set_object 15@ XY_rotation 2@ 4@ angle 0.0
  return
  :atan
  0509: 27@ = distance_between_XY 28@ 29@ and_XY 0.0 0.0
  0073: 28@ /= 27@ // (float)
  0073: 29@ /= 27@ // (float)
  0509: 27@ = distance_between_XY 28@ 29@ and_XY 0.0 1.0
  for 16@ = 0 to 11
     0017: 27@ /= 2.0
     006B: 27@ *= 27@ // (float)
     0087: 29@ = 27@ // (float)
     0013: 27@ *= -1.0
     000B: 27@ += 1.0
     01FB: 27@ = square_root 27@
     0013: 27@ *= -1.0
     000B: 27@ += 1.0
     006B: 27@ *= 27@ // (float)
     005B: 27@ += 29@ // (float)
     01FB: 27@ = square_root 27@
  end
  0013: 27@ *= 4096.0
  0017: 27@ /= 3.141592
  0013: 27@ *= 180.0
  if
  0021:   28@ > 0.0
  then
     0013: 27@ *= -1.0
     000B: 27@ += 360.0
  end
  return
  :get_actor
  0A8D: 27@ = read_memory 0xB74490 size 4 virtual_protect 0
  000A: 27@ += 0x4
  0A8D: 27@ = read_memory 27@ size 4 virtual_protect 0
  for 28@ = 0 to 35584 step 0x100
      0A8D: 26@ = read_memory 27@ size 1 virtual_protect 0
      000A: 27@ += 0x1
      if and
      0029:   26@ >= 0x00
      001B:   0x80 > 26@
      then
          005A: 26@ += 28@ // (int)
          0889: store_actor $PLAYER_ACTOR enter_of_body_position_to 5@ 6@ 7@
          0889: store_actor 26@ enter_of_body_position_to 2@ 3@ 4@
          050A: 0@ = distance_between_XYZ 5@ 6@ 7@ and_XYZ 2@ 3@ 4@
          068D: get_camera_position_to 5@ 6@ 7@
          if and
          255.0 > 0@
          8118: (check) not actor 26@ dead
          06BD: (check) no_obstacles_between 5@ 6@ 7@ and 2@ 3@ 4@ solid 1 car 0 actor 0 object 0 particle 0
          803C:   not  $PLAYER_ACTOR == 26@ // (int)
          then
              4@ += 1.0//atama
              gosub @getgamen  //56_xy
  //----------------size------------------------
              0087: 2@ = 0@ // (float)
              0@ = 10.0
              0073: 0@ /= 2@ // (float)
              0087: 2@ = 0@ // (float)
              2@ *= 0.5
              if
              0@ > 2.0
              then
                  0@ = 2.0
                  2@ = 1.0
              end
              if
              0.5 > 0@
              then
                  0@ = 0.5
                  2@ = 0.25
              end
  //-----------------color--------------------
              gosub @ped_health
          end
      end
  end
  return
  :getgamen
  068D: get_camera_position_to 5@ 6@ 7@
  0063: 5@ -= 2@ // (float)
  0063: 6@ -= 3@ // (float)
  0063: 7@ -= 4@ // (float)
  0013: 5@ *= -1.0
  0013: 6@ *= -1.0
  0400: store_coords_to 5@ 6@ 7@ from_object 15@ with_offset 5@ 7@ 6@
  0073: 5@ /= 7@ // (float)
  0073: 6@ /= 7@ // (float)
  0801: get_camera_zoom_factor_to 4@ // float
  0017: 4@ /= 2.0
  02F7: 2@ = sine 4@ // (float)
  02F6: 3@ = cosine 4@ // (float)
  0073: 2@ /= 3@ // (float)
  006B: 5@ *= 2@ // (float)
  006B: 6@ *= 2@ // (float)
  0013: 5@ *= 324.0
  0013: 6@ *= 304.0
  if
  0023: 0.0 > 7@
  then
  0007: 5@ = 640.0
  0007: 6@ = 480.0
  end
  000B: 5@ += 320.0
  000B: 6@ += 223.0
  return
  :ped_health
  03F0: enable_text_draw 1
  0A96: 12@ = actor 26@ struct
  000A: 12@ += 0x540
  0A8D: 13@ = read_memory 12@ size 4 virtual_protect 0 //now_health
  000A: 12@ += 0x4
  0A8D: 14@ = read_memory 12@ size 4 virtual_protect 0 //max_health
  0073: 13@ /= 14@ // (float)
  0@ *= 20.0
  2@ *= 5.0
  038E: draw_box position 5@ 6@ scale 0@ 2@ color 255 255 255 alpha 40    //kuro_box
  0087: 1@ = 0@ // (float)
  006B: 1@ *= 13@ // (float)
  0063: 0@ -= 1@ // (float)
  0@ *= 0.5
  0063: 5@ -= 0@ // (float)
  038E: draw_box position 5@ 6@ scale 1@ 2@ color 255 0 0 alpha 120    //aka_box
  return