Textdraw cROSS hair on target
#1

I want to make some kind of target cross or whatever you call it, in textdraw form,. It requires some advanced math and i suck at it. It should create textdraw on certain players head with reference to another player screen. If a player is present on my screen, a textdraw should be created on my screen at the position where the player is visible on my screen? How to do it? 3d to 2d
Reply
#2

You mean:
pawn Код:
GetScreenPosFromWorld(forplayerid, Float:WorldX, Float:WorldY, Float:WorldZ, &Float:ScreenX, &Float:ScreenY);
this?

I'm in need of this too.
I just can't figure it out. :S
Guess we need FOV, Res or something like that..

Anyone expert in Maths/Trigonometry please help?
Reply
#3

No idea, but i know you will need facing angle as well, for obvious reasons.
Reply
#4

I think this would cause lag. And why do you need it? There are other ways of making things like this... For example: Attach a 3DTextLabel above players head with a label "TARGET", or something like that...
Reply
#5

[quote=iPLEOMAX;1647599]You mean:
pawn Код:
GetScreenPosFromWorld(forplayerid, Float:WorldX, Float:WorldY, Float:WorldZ, &Float:ScreenX, &Float:ScreenY);
this?

Exactly

Quote:
Originally Posted by Universal
Посмотреть сообщение
I think this would cause lag. And why do you need it? There are other ways of making things like this... For example: Attach a 3DTextLabel above players head with a label "TARGET", or something like that...
It appears to everyone and it doesn't give the actual look like in fps games
Reply
#6

I also want this.
Reply
#7

anyone has this?
Reply
#8

CLEO Version

pawn Код:
:getScreenXYFrom3DCoords
{
 Parameters:
   Passed:
     0@ - position X
     1@ - position Y
     2@ - position Z
   Result:
     3@ - screen X
     4@ - screen Y

 Example:
   0AB1: call_scm_func @getScreenXYFrom3DCoords 3 coords_XYZ 2488.562 -1666.865 12.8757 store_to 1@ 2@
}
0AB1: call_scm_func @getLocalVarOffset 1 var 0 store_to 12@
0AB1: call_scm_func @getLocalVarOffset 1 var 3 store_to 13@
0AB1: call_scm_func @getLocalVarOffset 1 var 6 store_to 14@
0AB1: call_scm_func @getLocalVarOffset 1 var 9 store_to 15@
0AA5: call 0x70CE30 num_params 6 pop 6 bNearClip 0 bFarClip 0 pMultY 15@ pMultX 14@ pScreen 13@ pCoords 12@
0AB1: call_scm_func @getFullScreenXY 2 coords_XY 3@ 4@ store_to 3@ 4@
0AB2: ret 2 3@ 4@

:get3DCoordsFromScreenXY
{
 Parameters:
   Passed:
     0@ - screen X
     1@ - screen Y
     2@ - distance
   Result:
     14@ - position X
     15@ - position Y
     16@ - position Z

 Example:
   0AB1: call_scm_func @get3DCoordsFromScreenXY 3 coords_XY 320.0 224.0 distance 1.0 store_to 1@ 2@ 3@
}
0A8D: 3@ = read_memory 0x8D5038 size 4 virtual_protect 0 // field of view
3@ *= 0.5
02F6: 4@ = sine 3@
02F7: 5@ = cosine 3@
0073: 4@ /= 5@
6@ = 1.0
0@ /= HALF_WIDTH // half screen X
0063: 6@ -= 0@
006B: 6@ *= 4@
7@ = 1.0
1@ /= HALF_HEIGHT // half screen Y
0063: 7@ -= 1@
006B: 7@ *= 4@
0A8D: 8@ = read_memory 0xC3EFA4 size 4 virtual_protect 0 // screen aspect ratio
0073: 7@ /= 8@
006B: 6@ *= 2@
006B: 7@ *= 2@
0087: 9@ = 6@
0087: 10@ = 2@
0087: 11@ = 7@
0A8D: 12@ = read_memory 0xB6F03C size 4 virtual_protect 0 // camera matrix
0AB1: call_scm_func @getLocalVarOffset 1 var 9 store_to 13@
0AA5: call 0x59C790 num_params 3 pop 3 pOffsets 13@ pMatrix 12@ pResult 13@ // CPlaceable__getMatrixAbsOffsets
12@ += 0x30
0A8D: 14@ = read_memory 12@ size 4 virtual_protect 0 // camera X position
12@ += 0x4
0A8D: 15@ = read_memory 12@ size 4 virtual_protect 0 // camera Y position
12@ += 0x4
0A8D: 16@ = read_memory 12@ size 4 virtual_protect 0 // camera Z position
005B: 14@ += 9@
005B: 15@ += 10@
005B: 16@ += 11@
0AB2: ret 3 14@ 15@ 16@
Reply
#9

Quote:
Originally Posted by SourceCode
Посмотреть сообщение
CLEO Version

pawn Код:
:getScreenXYFrom3DCoords
{
 Parameters:
   Passed:
     0@ - position X
     1@ - position Y
     2@ - position Z
   Result:
     3@ - screen X
     4@ - screen Y

 Example:
   0AB1: call_scm_func @getScreenXYFrom3DCoords 3 coords_XYZ 2488.562 -1666.865 12.8757 store_to 1@ 2@
}
0AB1: call_scm_func @getLocalVarOffset 1 var 0 store_to 12@
0AB1: call_scm_func @getLocalVarOffset 1 var 3 store_to 13@
0AB1: call_scm_func @getLocalVarOffset 1 var 6 store_to 14@
0AB1: call_scm_func @getLocalVarOffset 1 var 9 store_to 15@
0AA5: call 0x70CE30 num_params 6 pop 6 bNearClip 0 bFarClip 0 pMultY 15@ pMultX 14@ pScreen 13@ pCoords 12@
0AB1: call_scm_func @getFullScreenXY 2 coords_XY 3@ 4@ store_to 3@ 4@
0AB2: ret 2 3@ 4@

:get3DCoordsFromScreenXY
{
 Parameters:
   Passed:
     0@ - screen X
     1@ - screen Y
     2@ - distance
   Result:
     14@ - position X
     15@ - position Y
     16@ - position Z

 Example:
   0AB1: call_scm_func @get3DCoordsFromScreenXY 3 coords_XY 320.0 224.0 distance 1.0 store_to 1@ 2@ 3@
}
0A8D: 3@ = read_memory 0x8D5038 size 4 virtual_protect 0 // field of view
3@ *= 0.5
02F6: 4@ = sine 3@
02F7: 5@ = cosine 3@
0073: 4@ /= 5@
6@ = 1.0
0@ /= HALF_WIDTH // half screen X
0063: 6@ -= 0@
006B: 6@ *= 4@
7@ = 1.0
1@ /= HALF_HEIGHT // half screen Y
0063: 7@ -= 1@
006B: 7@ *= 4@
0A8D: 8@ = read_memory 0xC3EFA4 size 4 virtual_protect 0 // screen aspect ratio
0073: 7@ /= 8@
006B: 6@ *= 2@
006B: 7@ *= 2@
0087: 9@ = 6@
0087: 10@ = 2@
0087: 11@ = 7@
0A8D: 12@ = read_memory 0xB6F03C size 4 virtual_protect 0 // camera matrix
0AB1: call_scm_func @getLocalVarOffset 1 var 9 store_to 13@
0AA5: call 0x59C790 num_params 3 pop 3 pOffsets 13@ pMatrix 12@ pResult 13@ // CPlaceable__getMatrixAbsOffsets
12@ += 0x30
0A8D: 14@ = read_memory 12@ size 4 virtual_protect 0 // camera X position
12@ += 0x4
0A8D: 15@ = read_memory 12@ size 4 virtual_protect 0 // camera Y position
12@ += 0x4
0A8D: 16@ = read_memory 12@ size 4 virtual_protect 0 // camera Z position
005B: 14@ += 9@
005B: 15@ += 10@
005B: 16@ += 11@
0AB2: ret 3 14@ 15@ 16@
I don't think it's possible to get the screen size, but it's possible to be made with GetPlayerCameraFrontVector with a timer and some basic trigonometric.
Reply
#10

Anyone made this already, i suck at maths
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)