-
Автор темы
- #1
C++:
void render::draw_dynamic_filled_star( const vec3_t& center, float outer_radius, float inner_radius, int points, Color color, Color color_fill ) {
auto screen = ZERO;
if ( !render::WorldToScreen3D( center, screen ) )
return;
float angle = math::pi / points;
float start_angle = -math::pi / 2.0f;
std::vector<Vertex> point;
for ( int i = 0; i < 2 * points; i++ ) {
float radius = ( i % 2 == 0 ) ? outer_radius : inner_radius;
float current_angle = start_angle + i * angle;
const auto& point3d = vec3_t( cos( current_angle ), sin( current_angle ), 0.f ) * radius;
vec2_t point2d;
if ( render::WorldToScreen( center + point3d, point2d ) )
point.push_back( vec2_t( point2d.x, point2d.y ) );
}
textured_polygon( point.size( ), point, color_fill );
textured_polyline( point.size( ), point, color );
}