-
Автор темы
- #1
C++:
const vec3_t center = position;
const float radius = 50.f * auto_peek_radius;
const float height = 25.f * auto_peek_radius;
const float width = 100.f * auto_peek_radius;
const Color color( 255, 255, 0, nem::g_auto_peek->fired_shot ? settings.apeek.alpha( 90 ) : 90 );
const Color color_fill( 255, 255, 0, settings.apeek.alpha( 80 ) );
std::vector<Vertex> points;
const float step = ( math::pi * 2.0f ) / 120.f;
for ( float angle = math::pi / 2.f - step; angle > 0.f; angle -= step )
{
const vec2_t outer( cos( angle ), sin( angle ) );
const vec2_t inner( cos( angle ) * 0.6f, sin( angle ) * 0.6f );
points.emplace_back( center + vec3_t( outer.x * radius, outer.y * radius, 0.f ), vec2_t( 0.f, 0.f ), color );
points.emplace_back( center + vec3_t( inner.x * radius, inner.y * radius, 0.f ), vec2_t( 0.f, 0.f ), color );
}
for ( float angle = step * 60.f; angle < math::pi / 2.f; angle += step )
{
const vec2_t outer( cos( angle ), sin( angle ) );
const vec2_t inner( cos( angle ) * 0.6f, sin( angle ) * 0.6f );
points.emplace_back( center + vec3_t( outer.x * radius, outer.y * radius, 0.f ), vec2_t( 0.f, 0.f ), color );
points.emplace_back( center + vec3_t( inner.x * radius, inner.y * radius, 0.f ), vec2_t( 0.f, 0.f ), color );
}
std::vector<Vertex> wing_left_points;
std::vector<Vertex> wing_right_points;
const float half_width = width / 2.f;
const vec3_t top_left( center.x - half_width, center.y + height / 2.f, center.z );
const vec3_t top_right( center.x + half_width, center.y + height / 2.f, center.z );
const vec3_t bottom_left( center.x - half_width, center.y - height / 2.f, center.z );
const vec3_t bottom_right( center.x + half_width, center.y - height / 2.f, center.z );
const float wing_step = ( height * 0.9f ) / 6.f;
for ( float y = top_left.y - wing_step; y > bottom_left.y; y -= wing_step )
{
wing_left_points.emplace_back( vec3_t( top_left.x - ( y - top_left.y ) * 1.5f, y, top_left.z ), vec2_t( 0.f, 0.f ), color );
wing_left_points.emplace_back( vec3_t( bottom_left.x - ( y * bottom_left.y ) * 1.5f, y, bottom_left.z ), vec2_t( 0.f, 0.f ), color );
}
for ( float y = top_right.y - wing_step; y > bottom_right.y; y -= wing_step )
{
wing_right_points.emplace_back( vec3_t( top_right.x + ( y - top_right.y ) * 1.5f, y, top_right.z ), vec2_t( 0.f, 0.f ), color );
wing_right_points.emplace_back( vec3_t( bottom_right.x + ( y - bottom_right.y ) * 1.5f, y, bottom_right.z ), vec2_t( 0.f, 0.f ), color );
}
const vec3_t wing_tip_left( top_left.x - height * 0.7f, top_left.y, top_left.z );
const vec3_t wing_tip_right( top_right.x + height * 0.7f, top_right.y, top_right.z );
draw_filled_circle( wing_tip_left.x, wing_tip_left.y, radius * 0.5f, color_fill );
draw_filled_circle( wing_tip_right.x, wing_tip_right.y, radius * 0.5f, color_fill );
rect_filled_multicolor( points.data( ), points.size( ), color_fill );
rect_filled_multicolor( wing_left_points.data( ), wing_left_points.size( ), color_fill );
rect_filled_multicolor( wing_right_points.data( ), wing_right_points.size( ), color_fill );