xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
axis.cc
浏览该文件的文档.
1#include <cmath>
2#include <cstddef>
8
9int main() {
10 auto scene = std::make_unique<xcal::scene::Scene>();
11 using namespace xcal::mobject;
12 using namespace xcal::property;
13
14 Path::data_t p(10);
15
16 for (size_t i = 0; i < p.size(); ++i) {
17 auto d = xcmath::radians((float_t)i * 360.0 / (float_t)p.size());
18 p[i] = xcmath::vec2<float_t>{(float_t)cos(d), (float_t)sin(d)} *
19 (float_t(i % 2) * 0.5f + 0.5f);
20 }
21
22 // auto path = scene->add<Path>(Path::data_t{p}, false)
23 // ->set_stroke_color({0, 1, 0, 1})
24 // ->set_fill_color({0, 1, 1, 0.1});
25
26 auto axis =
27 scene->add(new Axis3D{})->x_axis()->set_stroke_color({1, 0, 0, 1});
28
29 auto render = xcal::render::opengl::OpenGLRender{scene.get()};
30 render.default_camera()
31 ->set_background_color(0.2, 0.2, 0.2, 1.0)
32 ->set_position(-3, 3, 3);
33
34 render.show(1200, 675);
35 return 0;
36}
AbsCamera * set_position(Args &&... args)
设置相机位置
AbsCamera * set_background_color(Args &&... args)
设置背景颜色
std::vector< vec > data_t
Definition path.hpp:16
xcal::camera::AbsCamera * default_camera() const
Vector class template
Definition vec.hpp:206
int main()
Definition axis.cc:9
Header file for mathematical functions
float float_t
Definition public.h:27
constexpr T radians(T degrees)
Convert degrees to radians
Definition function.hpp:25