Complete lab 1
This commit is contained in:
parent
3a80069160
commit
21f72b21b8
@ -1,8 +1,10 @@
|
||||
add_executable(
|
||||
lab1
|
||||
|
||||
src/main.cpp
|
||||
src/sprite_data.hpp
|
||||
src/keyboard_catcher_widget.hpp
|
||||
src/variants.hpp
|
||||
|
||||
src/variants/variant1.cpp
|
||||
src/variants/variant2.cpp
|
||||
|
@ -20,6 +20,26 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
|
||||
void key_pressed_G();
|
||||
|
||||
void key_pressed_1();
|
||||
|
||||
void key_pressed_2();
|
||||
|
||||
void key_pressed_3();
|
||||
|
||||
void key_pressed_4();
|
||||
|
||||
void key_pressed_5();
|
||||
|
||||
void key_pressed_6();
|
||||
|
||||
void key_pressed_7();
|
||||
|
||||
void key_pressed_8();
|
||||
|
||||
void key_pressed_9();
|
||||
|
||||
void key_pressed_0();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override {
|
||||
switch (event->key()) {
|
||||
@ -32,6 +52,36 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
case Qt::Key_G:
|
||||
emit this->key_pressed_G();
|
||||
return;
|
||||
case Qt::Key_1:
|
||||
emit this->key_pressed_1();
|
||||
return;
|
||||
case Qt::Key_2:
|
||||
emit this->key_pressed_2();
|
||||
return;
|
||||
case Qt::Key_3:
|
||||
emit this->key_pressed_3();
|
||||
return;
|
||||
case Qt::Key_4:
|
||||
emit this->key_pressed_4();
|
||||
return;
|
||||
case Qt::Key_5:
|
||||
emit this->key_pressed_5();
|
||||
return;
|
||||
case Qt::Key_6:
|
||||
emit this->key_pressed_6();
|
||||
return;
|
||||
case Qt::Key_7:
|
||||
emit this->key_pressed_7();
|
||||
return;
|
||||
case Qt::Key_8:
|
||||
emit this->key_pressed_8();
|
||||
return;
|
||||
case Qt::Key_9:
|
||||
emit this->key_pressed_9();
|
||||
return;
|
||||
case Qt::Key_0:
|
||||
emit this->key_pressed_0();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,10 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
|
||||
Lab1SpriteData::Provider sprites_data{0.1};
|
||||
sprites_data.set_pixel_size(16);
|
||||
sprites_data.set_sub_sprites(variant1.sprites, variant1.count);
|
||||
sprites_data.set_sub_sprites(variant3.sprites, variant3.count);
|
||||
|
||||
VariantsManager vmngr{};
|
||||
QObject::connect(&vmngr, &VariantsManager::set_sprites, &sprites_data, &Lab1SpriteData::Provider::set_sub_sprites);
|
||||
|
||||
QMainWindow w{};
|
||||
|
||||
@ -44,6 +47,14 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_PageDown, &sprites_data, &Lab1SpriteData::Provider::decrease_pixel_size);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_PageUp, &sprites_data, &Lab1SpriteData::Provider::increase_pixel_size);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_G, &sprites_data, &Lab1SpriteData::Provider::invert_show_grid);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_1, &vmngr, &VariantsManager::set_variant_1);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_2, &vmngr, &VariantsManager::set_variant_2);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_3, &vmngr, &VariantsManager::set_variant_3);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_4, &vmngr, &VariantsManager::set_variant_4);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_5, &vmngr, &VariantsManager::set_variant_5);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_6, &vmngr, &VariantsManager::set_variant_6);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_8, &vmngr, &VariantsManager::set_variant_8);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_9, &vmngr, &VariantsManager::set_variant_9);
|
||||
|
||||
QtUtilities::SeparateThreadedDefaultRendererLinear<Lab1SpriteData> renderer{};
|
||||
renderer.set_sprite_data_provider(&sprites_data);
|
||||
|
@ -26,20 +26,29 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
RendererApi::PointI<2>::component_t radius;
|
||||
RendererApi::PointI<2>::component_t diameter;
|
||||
|
||||
[[nodiscard]] inline RendererApi::PointI<2> pos_rotated(RendererApi::PointI<2>::component_t custom_radius, double angle_degrees) const {
|
||||
private:
|
||||
|
||||
[[nodiscard]] inline RendererApi::PointI<2> _rotated(RendererApi::PointI<2>::component_t custom_radius, double base_angle_radians, double angle_degrees) const {
|
||||
double angle_radians = angle_degrees * (std::numbers::pi_v<double> / 180);
|
||||
return {
|
||||
(RendererApi::PointI<2>::component_t) (std::cos(this->rotation_radians + angle_radians) * custom_radius),
|
||||
(RendererApi::PointI<2>::component_t) (std::sin(this->rotation_radians + angle_radians) * custom_radius),
|
||||
(RendererApi::PointI<2>::component_t) (std::cos(base_angle_radians + angle_radians) * custom_radius),
|
||||
(RendererApi::PointI<2>::component_t) (std::sin(base_angle_radians + angle_radians) * custom_radius),
|
||||
};
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
[[nodiscard]] inline RendererApi::PointI<2> static_rotated(RendererApi::PointI<2>::component_t custom_radius, double angle_degrees) const {
|
||||
return this->_rotated(custom_radius, 0, angle_degrees);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline RendererApi::PointI<2> pos_rotated(RendererApi::PointI<2>::component_t custom_radius, double angle_degrees) const {
|
||||
return this->_rotated(custom_radius, this->rotation_radians, angle_degrees);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline RendererApi::PointI<2> neg_rotated(RendererApi::PointI<2>::component_t custom_radius, double angle_degrees) const {
|
||||
double angle_radians = angle_degrees * (std::numbers::pi_v<double> / 180);
|
||||
return {
|
||||
(RendererApi::PointI<2>::component_t) (std::cos(-this->rotation_radians + angle_radians) * custom_radius),
|
||||
(RendererApi::PointI<2>::component_t) (std::sin(-this->rotation_radians + angle_radians) * custom_radius),
|
||||
};
|
||||
return this->_rotated(custom_radius, -this->rotation_radians, angle_degrees);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -82,7 +91,7 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
.pixel_size = this->pixel_size,
|
||||
.show_grid = this->show_grid,
|
||||
.shape_data = {
|
||||
.rotation_radians = std::fmod(this->time.elapsed() / 1000.0 * radians_per_second, std::numbers::pi),
|
||||
.rotation_radians = std::fmod(this->time.elapsed() / 1000.0 * radians_per_second, std::numbers::pi * 2),
|
||||
.radius = radius,
|
||||
.diameter = radius * 2
|
||||
},
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
#include <QObject>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp>
|
||||
#include "sprite_data.hpp"
|
||||
@ -17,9 +18,10 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
std::size_t const count;
|
||||
|
||||
|
||||
constexpr variant_sprites(sprite_t *const *const _sprites, std::size_t _count) : sprites{_sprites}, count{_count}{
|
||||
constexpr variant_sprites(sprite_t **_sprites, std::size_t _count) : sprites{_sprites}, count{_count} {
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
template<class ...sprites_t>
|
||||
struct _make {
|
||||
@ -67,11 +69,62 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
static _make<sprites_t...> i{sprites...};
|
||||
static sprite_t *p[sizeof...(sprites)];
|
||||
|
||||
i.export_pointers(p, 0);
|
||||
return variant_sprites{p, sizeof...(sprites)};
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template<void (...sprites)(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
Lab1SpriteData::ShapeData const *data)>
|
||||
struct _make_light : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _make_light<> {
|
||||
public:
|
||||
constexpr _make_light() {};
|
||||
|
||||
constexpr void export_pointers(sprite_t **dst, std::size_t pos) {
|
||||
}
|
||||
};
|
||||
|
||||
template<void (s0)(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
Lab1SpriteData::ShapeData const *data),
|
||||
void (...sn)(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
Lab1SpriteData::ShapeData const *data)>
|
||||
struct _make_light<s0, sn...> : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
public:
|
||||
_make_light<sn...> next;
|
||||
|
||||
constexpr _make_light() : next{} {};
|
||||
|
||||
constexpr void export_pointers(sprite_t **dst, std::size_t pos) {
|
||||
dst[pos] = this;
|
||||
this->next.export_pointers(dst, pos + 1);
|
||||
}
|
||||
|
||||
void draw(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, const Lab1::Lab1SpriteData::ShapeData *data) const final {
|
||||
s0(frame, data);
|
||||
}
|
||||
|
||||
void clicked() final {}
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
template<void (...sprites)(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
Lab1SpriteData::ShapeData const *data)>
|
||||
constexpr static variant_sprites make_light() {
|
||||
static _make_light<sprites...> i{};
|
||||
static sprite_t *p[sizeof...(sprites)];
|
||||
|
||||
i.export_pointers(p, 0);
|
||||
return variant_sprites{p, sizeof...(sprites)};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
extern variant_sprites variant1;
|
||||
extern variant_sprites variant2;
|
||||
extern variant_sprites variant3;
|
||||
@ -80,4 +133,54 @@ namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
extern variant_sprites variant6;
|
||||
extern variant_sprites variant8;
|
||||
extern variant_sprites variant9;
|
||||
|
||||
class VariantsManager : public QObject {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
||||
void set_sprites(
|
||||
RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> *const *sprites,
|
||||
std::size_t count
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
inline void _set_sprites(variant_sprites sprites) {
|
||||
emit this->set_sprites(sprites.sprites, sprites.count);
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
inline void set_variant_1() {
|
||||
this->_set_sprites(variant1);
|
||||
};
|
||||
|
||||
inline void set_variant_2() {
|
||||
this->_set_sprites(variant2);
|
||||
};
|
||||
|
||||
inline void set_variant_3() {
|
||||
this->_set_sprites(variant3);
|
||||
};
|
||||
|
||||
inline void set_variant_4() {
|
||||
this->_set_sprites(variant4);
|
||||
};
|
||||
|
||||
inline void set_variant_5() {
|
||||
this->_set_sprites(variant5);
|
||||
};
|
||||
|
||||
inline void set_variant_6() {
|
||||
this->_set_sprites(variant6);
|
||||
};
|
||||
|
||||
inline void set_variant_8() {
|
||||
this->_set_sprites(variant8);
|
||||
};
|
||||
|
||||
inline void set_variant_9() {
|
||||
this->_set_sprites(variant9);
|
||||
};
|
||||
};
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
|
||||
}
|
96
programs/lab1/src/variants/common_sprites.hpp
Normal file
96
programs/lab1/src/variants/common_sprites.hpp
Normal file
@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/color.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/point.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/polygon.hpp>
|
||||
#include "../sprite_data.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
template<double z, RendererApi::Color::Transparent c, double radius_multiplier>
|
||||
void static_centered_circle_edge(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
Utilities::Shapes::draw_circle_edge(frame, {0, 0}, data->radius * radius_multiplier, z, c);
|
||||
}
|
||||
|
||||
template<RendererApi::PointF<2>... points_m>
|
||||
struct _iter_points {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _iter_points<> {
|
||||
public:
|
||||
static void apply_radius(RendererApi::PointI<2> *dst, std::size_t i, RendererApi::PointI<2>::component_t radius) {}
|
||||
|
||||
|
||||
static void as_radius_and_angle_pos(RendererApi::PointI<2> *dst, std::size_t i, Lab1SpriteData::ShapeData const *data) {}
|
||||
|
||||
static void as_radius_and_angle_neg(RendererApi::PointI<2> *dst, std::size_t i, Lab1SpriteData::ShapeData const *data) {}
|
||||
|
||||
static void as_radius_and_angle_static(RendererApi::PointI<2> *dst, std::size_t i, Lab1SpriteData::ShapeData const *data) {}
|
||||
};
|
||||
|
||||
template<RendererApi::PointF<2> p0, RendererApi::PointF<2>... pn>
|
||||
struct _iter_points<p0, pn...> {
|
||||
public:
|
||||
static void apply_radius(RendererApi::PointI<2> *dst, std::size_t i, RendererApi::PointI<2>::component_t radius) {
|
||||
dst[i] = {(RendererApi::PointI<2>::component_t) (p0.x * radius), (RendererApi::PointI<2>::component_t) (p0.y * radius)};
|
||||
_iter_points<pn...>::apply_radius(dst, i + 1, radius);
|
||||
}
|
||||
|
||||
static void as_radius_and_angle_pos(RendererApi::PointI<2> *dst, std::size_t i, Lab1SpriteData::ShapeData const *data) {
|
||||
dst[i] = data->pos_rotated(data->radius * p0.x, p0.y);
|
||||
_iter_points<pn...>::as_radius_and_angle_pos(dst, i + 1, data);
|
||||
}
|
||||
|
||||
static void as_radius_and_angle_neg(RendererApi::PointI<2> *dst, std::size_t i, Lab1SpriteData::ShapeData const *data) {
|
||||
dst[i] = data->neg_rotated(data->radius * p0.x, p0.y);
|
||||
_iter_points<pn...>::as_radius_and_angle_neg(dst, i + 1, data);
|
||||
}
|
||||
|
||||
static void as_radius_and_angle_static(RendererApi::PointI<2> *dst, std::size_t i, Lab1SpriteData::ShapeData const *data) {
|
||||
dst[i] = data->static_rotated(data->radius * p0.x, p0.y);
|
||||
_iter_points<pn...>::as_radius_and_angle_static(dst, i + 1, data);
|
||||
}
|
||||
};
|
||||
|
||||
template<double z, RendererApi::Color::Transparent c, RendererApi::PointF<2>... points_m>
|
||||
void static_polygon_edge(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
union {
|
||||
RendererApi::PointI<2> array[sizeof...(points_m)];
|
||||
bool nothing;
|
||||
} points{.nothing = false};
|
||||
_iter_points<points_m...>::apply_radius(points.array, 0, data->radius);
|
||||
Utilities::Shapes::draw_polygon_edge(frame, std::move(points.array), z, c);
|
||||
}
|
||||
|
||||
template<double z, RendererApi::Color::Transparent c, RendererApi::PointF<2>... points_m>
|
||||
void pos_rotated_polygon_edge(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
union {
|
||||
RendererApi::PointI<2> array[sizeof...(points_m)];
|
||||
bool nothing;
|
||||
} points{.nothing = false};
|
||||
_iter_points<points_m...>::as_radius_and_angle_pos(points.array, 0, data);
|
||||
Utilities::Shapes::draw_polygon_edge(frame, std::move(points.array), z, c);
|
||||
}
|
||||
|
||||
template<double z, RendererApi::Color::Transparent c, RendererApi::PointF<2>... points_m>
|
||||
void neg_rotated_polygon_edge(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
union {
|
||||
RendererApi::PointI<2> array[sizeof...(points_m)];
|
||||
bool nothing;
|
||||
} points{.nothing = false};
|
||||
_iter_points<points_m...>::as_radius_and_angle_neg(points.array, 0, data);
|
||||
Utilities::Shapes::draw_polygon_edge(frame, std::move(points.array), z, c);
|
||||
}
|
||||
|
||||
template<double z, RendererApi::Color::Transparent c, RendererApi::PointF<2>... points_m>
|
||||
void static_rotated_polygon_edge(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
union {
|
||||
RendererApi::PointI<2> array[sizeof...(points_m)];
|
||||
bool nothing;
|
||||
} points{.nothing = false};
|
||||
_iter_points<points_m...>::as_radius_and_angle_static(points.array, 0, data);
|
||||
Utilities::Shapes::draw_polygon_edge(frame, std::move(points.array), z, c);
|
||||
}
|
||||
}
|
@ -1,101 +1,12 @@
|
||||
#include <tuple>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/polygon.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp>
|
||||
#include "../variants.hpp"
|
||||
#include "../sprite_data.hpp"
|
||||
#include "common.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
namespace Variant1 {
|
||||
class S1 : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
public:
|
||||
void draw(
|
||||
BGTU::ComputerGraphicsLabWork::Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
const BGTU::ComputerGraphicsLabWork::Lab1::Lab1SpriteData::ShapeData *data
|
||||
) const final {
|
||||
Utilities::Shapes::draw_polygon_edge(
|
||||
frame,
|
||||
{data->neg_rotated(data->radius / 2, 0), data->neg_rotated(data->radius / 2, 90), data->neg_rotated(data->radius / 2, 180), data->neg_rotated(data->radius / 2, 270),},
|
||||
2,
|
||||
{255, 0, 0}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
class S2 : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
public:
|
||||
void draw(
|
||||
BGTU::ComputerGraphicsLabWork::Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
const BGTU::ComputerGraphicsLabWork::Lab1::Lab1SpriteData::ShapeData *data
|
||||
) const final {
|
||||
Utilities::Shapes::draw_polygon_edge(
|
||||
frame,
|
||||
{
|
||||
{data->radius, 0},
|
||||
{0, data->radius},
|
||||
{-data->radius, 0},
|
||||
{0, -data->radius}
|
||||
},
|
||||
3,
|
||||
{0, 255, 255}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
class S3 : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
public:
|
||||
void draw(
|
||||
BGTU::ComputerGraphicsLabWork::Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
const BGTU::ComputerGraphicsLabWork::Lab1::Lab1SpriteData::ShapeData *data
|
||||
) const final {
|
||||
Utilities::Shapes::draw_circle_edge(
|
||||
frame,
|
||||
{0, 0},
|
||||
data->radius,
|
||||
5,
|
||||
{0, 127, 255}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
class S4 : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
public:
|
||||
void draw(
|
||||
BGTU::ComputerGraphicsLabWork::Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
const BGTU::ComputerGraphicsLabWork::Lab1::Lab1SpriteData::ShapeData *data
|
||||
) const final {
|
||||
Utilities::Shapes::draw_circle_edge(
|
||||
frame,
|
||||
{0, 0},
|
||||
data->radius / (2.0 * std::sqrt(2)),
|
||||
1,
|
||||
{127, 127, 127}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
class S5 : public RendererApi::Sprite<Lab1SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
public:
|
||||
void draw(
|
||||
BGTU::ComputerGraphicsLabWork::Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
const BGTU::ComputerGraphicsLabWork::Lab1::Lab1SpriteData::ShapeData *data
|
||||
) const final {
|
||||
auto r2 = data->radius / 2;
|
||||
Utilities::Shapes::draw_polygon_edge(
|
||||
frame,
|
||||
{
|
||||
{-r2, -r2},
|
||||
{-r2, r2},
|
||||
{r2, r2},
|
||||
{r2, -r2}
|
||||
},
|
||||
3,
|
||||
{0, 255, 0}
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
variant_sprites variant1 = variant_sprites::make(Variant1::S1{}, Variant1::S2{}, Variant1::S3{}, Variant1::S4{}, Variant1::S5{});
|
||||
variant_sprites variant1 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<5.0, {0, 127, 255}, 1.0>,
|
||||
static_rotated_polygon_edge<4.0, {0, 255, 255}, {1, 0}, {1, 90}, {1, 180}, {1, 270}>,
|
||||
static_polygon_edge<3.0, {0, 255, 0}, {-0.5, -0.5}, {-0.5, 0.5}, {0.5, 0.5}, {0.5, -0.5}>,
|
||||
neg_rotated_polygon_edge<4.0, {255, 0, 0}, {0.5, 0}, {0.5, 90}, {0.5, 180}, {0.5, 270}>,
|
||||
static_centered_circle_edge<1.0, {127, 127, 127}, 1.0 / (2.0 * 1.4142135623730951)>
|
||||
>();
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
#include "../variants.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
variant_sprites variant2 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<5.0, {127, 127, 127}, 1.0>,
|
||||
static_rotated_polygon_edge<4.0, {127, 127, 127}, {1, 90}, {1, 90-120}, {1, 90+120}>,
|
||||
static_centered_circle_edge<3.0, {127, 127, 127}, 0.5>,
|
||||
neg_rotated_polygon_edge<4.0, {0, 255, 0}, {0.5, 90}, {0.5, 90-120}, {0.5, 90+120}>,
|
||||
static_centered_circle_edge<1.0, {127, 127, 127}, 0.25>
|
||||
>();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp>
|
||||
#include "../variants.hpp"
|
||||
#include "../sprite_data.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
template<double z, RendererApi::Color::Transparent c, double center_distance_multiplier, double center_angle_degrees, double radius_multiplier>
|
||||
static void _variant3_circle(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
Utilities::Shapes::draw_circle_edge(frame, data->pos_rotated(data->radius * center_distance_multiplier, center_angle_degrees), data->radius * radius_multiplier, z, c);
|
||||
}
|
||||
|
||||
variant_sprites variant3 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<4.0, {127, 127, 127}, 1.0>,
|
||||
pos_rotated_polygon_edge<3.0, {0, 255, 0}, {1, 0}, {1, 120}, {1, -120}>,
|
||||
_variant3_circle<2.0, {0, 255, 0}, 0.6666666666666, 0.0, 0.16666666666666666>,
|
||||
_variant3_circle<2.0, {0, 255, 0}, 0.6666666666666, 120.0, 0.16666666666666666>,
|
||||
_variant3_circle<2.0, {0, 255, 0}, 0.6666666666666, -120.0, 0.16666666666666666>,
|
||||
static_centered_circle_edge<1.0, {0, 255, 0}, 0.5>
|
||||
>();
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#include "../variants.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
variant_sprites variant4 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<2.0, {127, 127, 127}, 1.0>,
|
||||
pos_rotated_polygon_edge<1.0, {0, 0, 255},
|
||||
{1, 90 + 360 * 0 / 10}, {0.5, 90 + 360 * 1 / 10},
|
||||
{1, 90 + 360 * 2 / 10}, {0.5, 90 + 360 * 3 / 10},
|
||||
{1, 90 + 360 * 4 / 10}, {0.5, 90 + 360 * 5 / 10},
|
||||
{1, 90 + 360 * 6 / 10}, {0.5, 90 + 360 * 7 / 10},
|
||||
{1, 90 + 360 * 8 / 10}, {0.5, 90 + 360 * 9 / 10}
|
||||
>
|
||||
>();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#include "../variants.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
variant_sprites variant5 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<2.0, {127, 127, 127}, 1.0>,
|
||||
neg_rotated_polygon_edge<1.0, {0, 0, 255},
|
||||
{1, 90 + 360 * 0 / 14}, {0.7, 90 + 360 * 1 / 14},
|
||||
{1, 90 + 360 * 2 / 14}, {0.7, 90 + 360 * 3 / 14},
|
||||
{1, 90 + 360 * 4 / 14}, {0.7, 90 + 360 * 5 / 14},
|
||||
{1, 90 + 360 * 6 / 14}, {0.7, 90 + 360 * 7 / 14},
|
||||
{1, 90 + 360 * 8 / 14}, {0.7, 90 + 360 * 9 / 14},
|
||||
{1, 90 + 360 * 10 / 14}, {0.7, 90 + 360 * 11 / 14},
|
||||
{1, 90 + 360 * 12 / 14}, {0.7, 90 + 360 * 13 / 14}
|
||||
>
|
||||
>();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#include "../variants.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
variant_sprites variant6 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<4.0, {127, 127, 127}, 1.0>,
|
||||
//sqrt(5.0)*sqrt(5.0+2.0*sqrt(5.0))/10.0 * sqrt((5.0-sqrt(5.0))/2.0)
|
||||
static_rotated_polygon_edge<3.0, {0, 0, 255},
|
||||
{1, 90 + 360 * 0 / 5},
|
||||
{1, 90 + 360 * 1 / 5},
|
||||
{1, 90 + 360 * 2 / 5},
|
||||
{1, 90 + 360 * 3 / 5},
|
||||
{1, 90 + 360 * 4 / 5}
|
||||
>,
|
||||
static_centered_circle_edge<2.0, {127, 127, 127}, 0.8090169943749476>,
|
||||
neg_rotated_polygon_edge<1.0, {255, 0, 0},
|
||||
{0.8090169943749476, 45 + 0},
|
||||
{0.8090169943749476, 45 + 90},
|
||||
{0.8090169943749476, 45 + 180},
|
||||
{0.8090169943749476, 45 + 270}
|
||||
>
|
||||
>();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#include "../variants.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
variant_sprites variant8 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<4.0, {127, 127, 127}, 1.0>,
|
||||
static_rotated_polygon_edge<3.0, {0, 0, 255},
|
||||
{1, 90 + 0},
|
||||
{1, 90 + 120},
|
||||
{1, 90 - 120}
|
||||
>,
|
||||
static_centered_circle_edge<2.0, {127, 127, 127}, 0.5>,
|
||||
neg_rotated_polygon_edge<1.0, {0, 255, 0},
|
||||
{0.5, 90 + 360 * 0 / 8}, {0.15, 90 + 360 * 1 / 8},
|
||||
{0.5, 90 + 360 * 2 / 8}, {0.15, 90 + 360 * 3 / 8},
|
||||
{0.5, 90 + 360 * 4 / 8}, {0.15, 90 + 360 * 5 / 8},
|
||||
{0.5, 90 + 360 * 6 / 8}, {0.15, 90 + 360 * 7 / 8}
|
||||
>
|
||||
>();
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp>
|
||||
#include "../variants.hpp"
|
||||
#include "../sprite_data.hpp"
|
||||
#include "common_sprites.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Lab1 {
|
||||
template<double z, RendererApi::Color::Transparent c, double outer_radius, double inner_radius, double angle_degrees>
|
||||
static void _variant8_triangle(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, Lab1SpriteData::ShapeData const *data) {
|
||||
pos_rotated_polygon_edge<z, c, {outer_radius, angle_degrees}, {inner_radius, angle_degrees + 10}, {inner_radius, angle_degrees - 10}>(frame, data);
|
||||
}
|
||||
|
||||
variant_sprites variant9 = variant_sprites::make_light<
|
||||
static_centered_circle_edge<3.0, {127, 127, 127}, 1.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 0.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 45.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 90.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 135.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 180.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 225.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 270.0>,
|
||||
_variant8_triangle<2.0, {0, 0, 255}, 1.0, 0.65, 315.0>,
|
||||
static_centered_circle_edge<1.0, {0, 0, 255}, 0.5>
|
||||
>();
|
||||
}
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/point.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/color.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/voxel_painter.hpp>
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes {
|
||||
template<class receiver_t>
|
||||
|
Loading…
Reference in New Issue
Block a user