Raised This Month: $51 Target: $400
 12% 

Half-Life Position, Velocity, and Angles (for n00bs)


Post New Thread Reply   
 
Thread Tools Display Modes
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-30-2012 , 17:27   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #31

Extremely well explained !! Thanks a lot !

Without you I will not understood
__________________
Pawn ? Useless
Aooka is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 03-18-2013 , 13:20   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #32

I'm still confused with coordinates and angles.

In your wall text plugin you have this
PHP Code:
    // lengthen vector and move it to user's origin
    
fAimVector[0] = fAimVector[0] * 9999.0 fPlayerOrigin[0]
    
fAimVector[1] = fAimVector[1] * 9999.0 fPlayerOrigin[1]
    
fAimVector[2] = fAimVector[2] * 9999.0 fPlayerOrigin[2
Why did you multipy fAimVector in 9999 and then add to it the player origin, I could not understand this even with the comment you have written, could some one explain it to me?
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-18-2013 , 13:26   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #33

It multiplies by 9999 to get a vector length as big as possible.
It adds to player's origin, since we want this "long line" starts at player's origin.
__________________
Arkshine is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 03-18-2013 , 13:59   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #34

Quote:
Originally Posted by Arkshine View Post
It multiplies by 9999 to get a vector length as big as possible.
It adds to player's origin, since we want this "long line" starts at player's origin.
Thanks for the fast reply, but if we multiply it by 9999 to get the biggest vector as possible, why would we add it to the player origin if it won't make any difference

PHP Code:
// Lets assume this
new Float:vOrigin[3] = { 234.4, -251.0100.0 }
new 
Float:vAimVector[3] = { 151.128390.15285.25 }

xs_vec_mul_scalar(vAimVector9999.0vAimVector)
xs_vec_add(vAimVectorvOriginvAimVector)

// At last, vAimVector will be
// { 1511363.272, 3900858.85, 2852314.75 }
// And that's far from what you have said about ->
// It adds to player's origin, since we want this "long line" starts at player's origin

new iTr create_tr2()
engfuncEngFunc_TraceLinevOriginvAimVectorIGNORE_MONSTERSidiTr )
free_tr2(iTr
I hope you understood my point
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.

Last edited by pokemonmaster; 03-18-2013 at 14:00.
pokemonmaster is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-18-2013 , 14:20   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #35

The purpose of a TraceLine is to trace a virtual line from point A to point B and seeing if it hits something.

To make a line, you need to know the Point A origin, and the Point B origin.

We know already player's origin, which is Point A (vOrigin).

To know the end origin, which is Point B, you need a direction and a length.

Length and direction you will want to apply from Point A.

Code:
A           B
x---------->x
|   length  |
Since we don't care about length, you multiply the direction by a big number like 9999. (You could also use 8192 which is the max length of a map)

So you have "a long line" with a defined direction.To know the Point B origin, you just need to start the line from Point A.

That's why you add the Point A origin to this "long line". You need to tell from where you want to start to draw the line.
__________________

Last edited by Arkshine; 03-18-2013 at 14:21.
Arkshine is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 03-19-2013 , 07:35   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #36

Quote:
Originally Posted by Arkshine View Post
That's why you add the Point A origin to this "long line". You need to tell from where you want to start to draw the line.
I'm still confused about this part lol
Isn't the start point of the trace line is the vOrigin?

I've got another question, multiplying the z position (hieght) for the vAimVector([2]) by 9999 would make the traceline go from point a to point c, what I'm trying to do is making a traceline between a and b



I understand why we multiplied the x and y origins.
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 04-03-2013 , 07:36   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #37

Bump...
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-10-2013 , 07:54   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #38

Quote:
Originally Posted by pokemonmaster View Post
I've got another question, multiplying the z position (hieght) for the vAimVector([2]) by 9999 would make the traceline go from point a to point c, what I'm trying to do is making a traceline between a and b
The player's aim vector will always be the hypotenuse. Having said that, explain why you would only want to trace from a to b ?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Sherazaa
Member
Join Date: Jun 2012
Old 04-10-2013 , 11:00   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #39

Hi, awesome tut ! Thanks a lot's.

I have got some questions to ask you about the last example :
PHP Code:
CreateNewMessageidszMessage[MESSAGE_LEN] )
{
    new 
Float:fAimOrigin[3]
    new 
Float:fPlayerOrigin[3]
    
    new 
Float:fAimVector[3]
    new 
Float:fNormalVector[3]
    new 
Float:fTextVector[3]
    
    
// user's view angle
    
pevidpev_v_anglefAimVector )
    
    
// vector pointing in that direction
    
angle_vectorfAimVectorANGLEVECTOR_FORWARDfAimVector )
    
    
// user's origin
    
pevidpev_originfPlayerOrigin )
    
    
// lengthen vector and move it to user's origin
    
fAimVector[0] = fAimVector[0] * 9999.0 fPlayerOrigin[0]
    
fAimVector[1] = fAimVector[1] * 9999.0 fPlayerOrigin[1]
    
fAimVector[2] = fAimVector[2] * 9999.0 fPlayerOrigin[2]
    
    
// execute traceline, grab normal vector and end position
    
new iTr create_tr2()
    
engfuncEngFunc_TraceLinefPlayerOriginfAimVectorIGNORE_MONSTERSidiTr )
    
get_tr2iTrTR_vecEndPosfAimOrigin )
    
get_tr2iTrTR_vecPlaneNormalfNormalVector )
    
free_tr2iTr )
    
    
// convert normal vector to angles
    
vector_to_anglefNormalVectorfTextVector )
    
    
// get vector pointing to the right, from the perspective of the normal vector
    
angle_vectorfTextVectorANGLEVECTOR_RIGHTfTextVector )
    
    
// lengthen by width of one character, and point towards the left (from the perspective of the normal vector)
    
fTextVector[0] *= -1.0 CHAR_WIDTH
    fTextVector
[1] *= -1.0 CHAR_WIDTH
    fTextVector
[2] *= -1.0 CHAR_WIDTH
    
    
// ...

So,

1/ I do not understand why you write that :
Code:
angle_vector( fAimVector, ANGLEVECTOR_FORWARD, fAimVector )

2/ And this part too :
Code:
new iTr = create_tr2() engfunc( EngFunc_TraceLine, fPlayerOrigin, fAimVector, IGNORE_MONSTERS, id, iTr ) get_tr2( iTr, TR_vecEndPos, fAimOrigin ) get_tr2( iTr, TR_vecPlaneNormal, fNormalVector ) free_tr2( iTr )

3/ Why we must convert a normal vector to an angle ?
Code:
vector_to_angle( fNormalVector, fTextVector )

So here, i do not understand that ... :/
Code:
angle_vector( fTextVector, ANGLEVECTOR_RIGHT, fTextVector )

4/ And to finished, why you do that ?
Code:
fTextVector[ 0 ] *= - 1.0 * CHAR_WIDTH; // CHAR_WIDTH = 12

So thanks in advance.

If someone can help me it would be really nice. I home somebody know how to explain those parts.
__________________
[B]Bhop & Kz Player
Sherazaa is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 04-13-2013 , 12:58   Re: Half-Life Position, Velocity, and Angles (for n00bs)
Reply With Quote #40

Quote:
Originally Posted by hornet View Post
The player's aim vector will always be the hypotenuse. Having said that, explain why you would only want to trace from a to b ?
I'm making an laser mine plugin, I have succeeded putting it in the wall at first, but it wasn't on the wall exactly, but now I did it correctly, I understood angles positions more, thanks for your help all.
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode