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

Rotating points depending on players eye angle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 07-05-2011 , 18:57   Rotating points depending on players eye angle
Reply With Quote #1

I just found that Laser Letters script over at the eventscripts board and it's pretty awesome!

After porting it to sourcemod i've been trying to get the words/letters to rotate to keep them always facing in the same direction as the player, but i failed hard.

Basically the letters are a bunch of pointlasers drawn together. All points are directly on the x axis with different z coordinates. They are just offsets from the 0 0 0 middle.

E.g. the letter "A" would be
PHP Code:
new Float:fStart1[3] = {0.00.00.0};
new 
Float:fEnd1[3] = {10.00.030.0}; // left line
new Float:fStart2[3] = {20.00.00.0};
new 
Float:fEnd2[3] = {10.00.030.0}; // right line
new Float:fStart3[3] = {5.00.015.0};
new 
Float:fEnd3[3] = {15.00.015.0}; // horizontal connector 
Imagine spawning 3 BeamPoints at the eye position of a player + those offsets:

[IMG]http://img43.**************/img43/323/lasera.png[/IMG]

Now since we only modified the x axis, it's always parallel to the x axis, no matter where the player is watching at.

I tried to incorporate the eye angles, but i can't get it to rotate correctly.

PHP Code:
fInterestingAngle fAngles[1] - 90.0;

new 
Float:fReverse;
if(
fInterestingAngle >= 0.0)
    
fReverse 1.0;
else
    
fReverse = -1.0;

fDistance fStart[0] - fEnd[0];
if(
fDistance 0.0)
    
fDistance *= -1.0;
fStart[0] = fReverse * (fStart[0] + Cosine(fInterestingAngle) * fDistance);
fStart[1] = fReverse * (Sine(fInterestingAngle) * fDistance);

fEnd[0] = fReverse * (fEnd[0] + Cosine(fInterestingAngle) * (fDistance));
fEnd[1] = fReverse * (Sine(fInterestingAngle) * (fDistance)); 
Attached is the script. Type "/ll hello" in chat to see the words in lasers above your head ;)

All credits belong to bonbon for her time to get those char offsets together!

I'd release it as an own plugin as is, but i first want to have the rotation working!
Attached Files
File Type: sp Get Plugin or Get Source (laserletters.sp - 551 views - 44.5 KB)
__________________
Peace-Maker is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 07-05-2011 , 20:00   Re: Rotating points depending on players eye angle
Reply With Quote #2

you need a rotation matrix, i'd read up on it first, if you're not very good at maths it will be difficult creating one.
blodia is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 07-07-2011 , 22:59   Re: Rotating points depending on players eye angle
Reply With Quote #3

u can use my matrix.inc file that i made for gravity gun plugin.
__________________
javalia is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 07-07-2011 , 23:01   Re: Rotating points depending on players eye angle
Reply With Quote #4

well..i cannot say it is perfect but..well...k.
__________________
javalia is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-07-2011 , 23:59   Re: Rotating points depending on players eye angle
Reply With Quote #5

https://forums.alliedmods.net/showthread.php?t=68809
psychonic 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:17.


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