 |
|
Member
|

05-17-2022
, 03:56
Re: Calculating circular origin?
|
#2
|
Quote:
Originally Posted by AdrenalinesWrath
hello everyone,
I'm trying to get origins around an origin to create a beam between center and the end of the circle
and I'm not really good at math lol.
for example origin would be {0.0,0.0,0.0} which would be the center, and the distance would be 150.0
so I want to make it start from the top of it, and make it go in circular motion by 360°
any snippet for it?
probably by using floatsin() and floatcos()? I have no idea how to use them
thanks in advance!
Figured it out! here's a lil snippet if anyone needs it:
PHP Code:
stock get_circular_origin(Float:angle, Float:origin[3], Float:radius,Float:COrigin[3])
{
COrigin[0] = radius * floatcos(angle,degrees);
COrigin[1] = origin[1]
COrigin[2] = radius * floatsin(angle,degrees);
}
|
This Can Help u
PHP Code:
new Float:g_vec[3] = {25.0, 0.0, -20.0}
new Float:g_deg = 0;
public fxWindFX( Client )
{
set_task(0.05, "rotate", Client, _, _, "b", 1);
set_task(1.0, "fxRestore", Client, _, _, "b", 1);
}
public fxRestore( Client )
{
g_vec[0] = 25.0;
g_vec[1] = 0.0;
g_vec[2] = -20.0;
}
public rotate(Client)
{
new Float:x, Float:y
x = 25*floatcos(g_deg, degrees);
y = 25*floatsin(g_deg, degrees);
g_deg += 70;
display(Client)
g_vec[0] = x
g_vec[1] = y
g_vec[2] += 8.0;
}
public display(Client)
{
new origin[3];
get_user_origin(Client, origin)
message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
write_byte(TE_SPRITE) // TE id
write_coord(floatround(g_vec[0] + origin[0]) )
write_coord(floatround(g_vec[1] + origin[1]) )
write_coord(floatround(g_vec[2] + origin[2]) )
write_short( engfunc( EngFunc_ModelIndex, "sprites/steam1.spr") );
write_byte(3) // scale
write_byte(255) // framerate
message_end()
}
|
|
|
|