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

Two origins, get origin of points in line


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-12-2010 , 15:18   Two origins, get origin of points in line
Reply With Quote #1

Well, I have a line, each point has different XYZ and line total width may varray.

[A]----------------------[B]

And I want to generate points of predefined distance accros the line:

[A]-.-.-.-.-.-.-.-.-.-.-.-.-[B]

Having origins for each one of them.

It's more a math problem and I really suck at maths
__________________
Hunter-Digital is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-12-2010 , 16:12   Re: Two origins, get origin of points in line
Reply With Quote #2

Let's see if I can say it right:

Subtract B by A and you will get the vector that goes from A to B.
Normalize it so it becomes with length 1.
Than multiply it by the length between points (as you defined it)

PHP Code:
xs_vec_sub(b,a,c)
xs_vec_normalize(c,c)
xs_vec_mul_scalar(c,lengthBetweenPoints,c
Now C is a vector with the direction from A to B and with length as you defined between points.

So, now to get the point N from A you will do:

PHP Code:

new 3
new Float:nOrigin[3]

xs_vec_mul_scalar(c,n,nOrigin)
xs_vec_add(nOrigin,a,nOrigin
Edit: if you want all the points in between you just have to do in the last step:

PHP Code:

for(new i=0;i<=lastPoint;i++)
{
  
// use "a" here

  
xs_vec_add(a,c,a)

__________________

Last edited by joaquimandrade; 07-12-2010 at 16:18.
joaquimandrade is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-12-2010 , 17:00   Re: Two origins, get origin of points in line
Reply With Quote #3

Hmm... thanks, I think I got the 'trick'.

PHP Code:
    new iOrigin[3]
    new 
Float:fA[3]
    new 
Float:fB[3]

    
entity_get_vector(idEV_VEC_originfA)
    
get_user_origin(idiOrigin3)
    
IVecFVec(iOriginfB)

    new 
iNum floatround(get_distance_f(fAfB) / 50.0floatround_floor)

    
xs_vec_sub(fBfAfB)
    
xs_vec_normalize(fBfB)
    
xs_vec_mul_scalar(fB50.0fB)

    for(new 
iNumi++)
    {
        
xs_vec_add(fAfBfA)

        
/* sprite @ fA */
    

And by mistake I made a nice railgun effect

[IMG]http://img295.**************/img295/8889/dedust20057.th.jpg[/IMG]

It fades out really nicely, used TE_GLOWSPRITE and ledglow.spr
__________________

Last edited by Hunter-Digital; 07-12-2010 at 17:20.
Hunter-Digital 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 10:47.


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