Raised This Month: $32 Target: $400
 8% 

Draw a cone - Calculate point on a circumference


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 10-15-2018 , 09:00   Draw a cone - Calculate point on a circumference
Reply With Quote #1

Hi,

I'm trying to draw a cone, but I cannot figure out how to calculate the points on a circumference, this is my code at the moment:
PHP Code:
public Action Cmd_Cone(int clientint args)
{
    
float vClientPos[3];
    
float vClientEye[3];
    
float vConePos[3];
    
    
GetClientEyePosition(clientvClientPos);
    
GetClientEyeAngles(clientvClientEye);
    
    
TR_TraceRayFilter(vClientPosvClientEyeMASK_SHOTRayType_InfiniteFilter_NoSelfclient);
    if (!
TR_DidHit())
        return 
Plugin_Handled;
    
    
TR_GetEndPosition(vConePos);
    
    
//Height from the ground.
    
vConePos[2] += 300.0;
    
    
//The circle radius.
    
float fRadius 70.0;
    
    
//Draw the cone base.
    
TE_SetupBeamRingPoint(vConePosfRadiusfRadius 0.1iBeamSpriteiHaloSprite010120.02.00.0, {255100100250}, 100);
    
TE_SendToAll();
    
    
float vStart[3];
    
float vEnd[3];
    
vStart[2] = vConePos[2];
    
    
//Copy the cone position to the new var.
    
AddVectors(vEndvConePosvEnd);
    
    
//Cone height.
    
vEnd[2] = vConePos[2] - 100.0;
    
    
//Calcule the point on the circumference.
    
vStart[0] = vConePos[0] + (fRadius Cosine(DegToRad(90.0)));
    
vStart[1] = vConePos[1] + (fRadius Sine(DegToRad(90.0)));
    
    
//Draw the first cone line.
    
TE_SetupBeamPoints(vEndvStartiBeamSpriteiHaloSprite010120.02.016.010.0, {255100100250}, 5);
    
TE_SendToAll();
    return 
Plugin_Handled;

And this is what happens when I run that code:




This is the formula that I've used:
Quote:

Code:
x = cx + r * cos(a)
y = cy + r * sin(a)
Where r is the radius, cx,cy the origin, and a the angle.
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 10-15-2018 at 09:01.
Papero is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 10-15-2018 , 11:03   Re: Draw a cone - Calculate point on a circumference
Reply With Quote #2

If i were to draw a cone i would make the cone completely out of circles that get progressively smaller towards the tip.
__________________
Pelipoika is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-16-2018 , 15:54   Re: Draw a cone - Calculate point on a circumference
Reply With Quote #3

I think you're on the wrong axis, it looks 90 degrees off - add the loop so you're drawing all the lines and it'll probably be obvious.
__________________
asherkin is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-16-2018 , 15:58   Re: Draw a cone - Calculate point on a circumference
Reply With Quote #4

Quote:
Originally Posted by asherkin View Post
I think you're on the wrong axis, it looks 90 degrees off - add the loop so you're drawing all the lines and it'll probably be obvious.
He's using a beamring point which wont go horizontal is his issue.
Mitchell 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 05:58.


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