Quantcast

Jump to content

» «
Photo

Draw texture on the X,Y of 3D object

6 replies to this topic
julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#1

Posted 12 January 2013 - 03:58 AM

anyone know if there is an method to, based on an 3D object (vehicle for example), draw one texture in the 2D screen position?

i have an plane in front of the player, i wanna draw an texture (e.graphics.drawSprite) in the position of that object on the screen, like an target identifier system

AgentWD40
  • AgentWD40

    GLITCHED

  • Members
  • Joined: 02 May 2009
  • Philippines

#2

Posted 12 January 2013 - 01:06 PM Edited by hardsty1e, 12 January 2013 - 01:38 PM.

i might have a solution, check your inbox

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#3

Posted 12 January 2013 - 04:26 PM

thx man

lindsayslorach
  • lindsayslorach

    Rat

  • Members
  • Joined: 26 Dec 2006

#4

Posted 16 January 2013 - 04:14 PM

Might we be able to know hardsty1e's suggestion/solution?

AgentWD40
  • AgentWD40

    GLITCHED

  • Members
  • Joined: 02 May 2009
  • Philippines

#5

Posted 16 January 2013 - 10:47 PM Edited by hardsty1e, 16 January 2013 - 10:54 PM.

you can learn off julionib's Air Combat IV mod that he just released wink.gif open source

http://www.gta4-mods...t-iv-v10-f19199

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#6

Posted 17 January 2013 - 03:01 AM

QUOTE (lindsayslorach @ Wednesday, Jan 16 2013, 16:14)
Might we be able to know hardsty1e's suggestion/solution?

hehe, sorry

unfortunatelly i cant find a good way to establish and distance proportion calc to make this fit exactly where thee object is, the Y value works fine, but the X dont, using the idea to find the Y we can do the same to the X value, using distancet between object and camera and calculating the X variation, the problem its determine when the camera its on the left/right of the object to decide if the X offset its negative or not

this is the code:

CODE

if jetList(c).jet.isonscreen andalso (jetList(c).jet.position.distanceto(myJet.position) > 350) then
     dim float_temp_1 as double
     dim TO_RADIAN = 0.017453292519943295
     float_temp_1 = Math.Atan2((jetList(c).jet.Position.Y - Player.Character.Position.Y) , (jetList(c).jet.Position.X - Player.Character.Position.X))
     float_temp_1 = float_temp_1 - Game.CurrentCamera.Rotation.Z * TO_RADIAN
     float_temp_1 += 1.570796
     
     dim cam as camera = game.currentcamera
     dim dist as double = jetList(c).jet.position.distanceto(cam.position)
     dim compPos as vector3 = (cam.position + cam.direction * dist)
     dim y as double = (((compPos - jetList(c).jet.position).z)) / dist
     
     if jetList(c).is_hunter then
      GTA.Native.Function.Call("DRAW_RECT", 0.5f + 0.6f * (Math.Sin(float_temp_1)), y + 0.55, 0.01, 0.02, 255, 0, 0, 100)
     elseif jetList(c).is_fugitive then
      GTA.Native.Function.Call("DRAW_RECT", 0.5f + 0.6f * (Math.Sin(float_temp_1)), y + 0.55, 0.01, 0.02, 200, 200, 0, 100)      
     else
      GTA.Native.Function.Call("DRAW_RECT", 0.5f + 0.6f * (Math.Sin(float_temp_1)), y + 0.55, 0.01, 0.02, 100, 100, 100, 100)
     end if
    end if

julionib
  • julionib

    Coder

  • Feroci
  • Joined: 13 Sep 2012
  • Brazil

#7

Posted 17 January 2013 - 03:04 AM

obs: i used this to identify the enemy jets when they dont appear in the screen (thx to game limitation ^^)

the inital idea was use it as an missile lock draw on the enemy jet




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users