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

Need help with vec calculations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-01-2018 , 04:21   Need help with vec calculations
Reply With Quote #1



Code:
// flOrigin - ent position // beamend - end of beam float angl1[3]; float angl2[3]; GetVectorAngles(flOrigin, angl1); GetVectorAngles(beamend, angl2); PrintToConsole(pArent, "========== iLight: %i ==========", pActivator); PrintToConsole(pArent, "[0]: {%.2f,%.2f}, {%.2f,%.2f}", beamend[0], flOrigin[0], angl1[0], angl2[0]); PrintToConsole(pArent, "[1]: {%.2f,%.2f}, {%.2f,%.2f}", beamend[1], flOrigin[1], angl1[1], angl2[1]); PrintToConsole(pArent, "[2]: {%.2f,%.2f}, {%.2f,%.2f}", beamend[2], flOrigin[2], angl1[2], angl2[2]);

Quote:
========== iLight: 230 ==========
[0]: {-401.44,-550.31}, {351.61,325.25}
[1]: {-939.93,-1007.57}, {241.35,246.87}
[2]: {708.96,169.32}, {0.00,0.00}
wtf:
I use light_dynamic for lightning ent(mine)..
Code:
TeleportEntity(CreateEntityByName("light_dynamic"), flOrigin, NULL_VECTOR, NULL_VECTOR);
but I need little fix for its(light_dynamic) position, near 5-10 units from original mine position towards beam direction.
my brain is exploding when I tried to understand how I can make it when ent(mine) has some angle(such as on image)
ZASTRELIS is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 07-01-2018 , 05:41   Re: Need help with vec calculations
Reply With Quote #2

This should do what you want but it's untested.

PHP Code:
float distance_from_origin 10.0;
float direction[3], forwards[3], lightorigin[3]; 

for(
int i=03i++) 
    
direction[i] = beamend[i] - flOrigin[i];

GetVectorAngles(directiondirection);  
GetAngleVectors(directionforwardsNULL_VECTORNULL_VECTOR);  

for(
int i 0;3i++)  
    
lightorigin[i] = flOrigin[i] + (forwards[i] * distance_from_origin); 
Depending on the model rotation the angl1 or angl2 may already be the forwards angle you require but getting the difference between the end and start point is just as simple.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.

Last edited by backwards; 07-14-2018 at 08:39.
backwards is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-01-2018 , 07:38   Re: Need help with vec calculations
Reply With Quote #3

Quote:
Quote:
Originally Posted by 1337norway View Post
Code:
... for(int i = 0;i < 3; i++)      lightorigin[i] = flOrigin[i] + forwards[i] * distance_from_origin);
Code:
lightorigin[i] = flOrigin[i] + (forwards[i] * distance_from_origin);
Works great, thanks a lot.. bro.

Last edited by ZASTRELIS; 07-01-2018 at 07:50.
ZASTRELIS 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 09:44.


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