Dandelion 2.0.0
A light-weight 3D builder for educational usage
载入中...
搜索中...
未找到
rendering.hpp
浏览该文件的文档.
1#pragma once
2
3#include <Eigen/Core>
4
5/*!
6 * \ingroup utils
7 * \file utils/rendering.hpp
8 * \~chinese
9 * \brief 这个文件定义了一些和渲染(离线渲染或场景预览)相关的常量、枚举等。
10 */
11
12/*!
13 * \ingroup utils
14 * \~chinese
15 * 将整数形式的颜色转换成浮点数,便于传入 Eigen::Vector3f 的构造函数。
16 */
17#define RGB_COLOR(r, g, b) (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f
18
19///@{
20/*!
21 * \ingroup utils
22 * \~chinese
23 * 预览场景时,GLSL shader 中各输入变量的位置。相应的变量定义参考 resources/shaders
24 * 中的 shader 代码。
25 */
26constexpr unsigned int vertex_position_location = 0;
27constexpr unsigned int vertex_normal_location = 1;
28///@}
29
30/*!
31 * \~chinese
32 * 预览场景时用 OpenGL 绘制的点大小。
33 */
34constexpr float point_size = 8.0f;
35/*!
36 * \~chinese
37 * 预览场景时用 OpenGL 绘制的线宽。
38 */
39constexpr float line_width = 2.0f;
40
41/*! \~chinese 默认线框颜色(黄色)。 */
42const Eigen::Vector3f default_wireframe_color(RGB_COLOR(255, 194, 75));
43/*! \~chinese 默认面片颜色(中灰色)。 */
44const Eigen::Vector3f default_face_color(RGB_COLOR(255, 255, 255));
45/*! \~chinese 高亮线框颜色(浅蓝色)。 */
46const Eigen::Vector3f highlight_wireframe_color(RGB_COLOR(115, 206, 244));
47/*! \~chinese 高亮面片颜色(浅蓝色)。 */
48const Eigen::Vector3f highlight_face_color(RGB_COLOR(115, 206, 244));
49
50/*!
51 * \~chinese
52 * 预览场景时使用的渲染模式,与 Dandelion 的工作模式一一对应。
53 */
54enum class WorkingMode
55{
56 LAYOUT,
57 MODEL,
58 RENDER,
59 SIMULATE
60};
61
62/*!
63 * \~chinese
64 * \brief 允许拾取物体的模式。
65 *
66 * 这个常量数组指定允许拾取物体(直接在屏幕上点击选取物体)的工作模式,
67 * 当前为布局模式(用于操纵物体)和物理模拟模式(用于修改物理属性)。
68 */
70 WorkingMode::LAYOUT, WorkingMode::MODEL, WorkingMode::SIMULATE
71};
72
73/*!
74 * \~chinese
75 * \brief 判断指定模式是否允许拾取物体。
76 *
77 * \param mode 表示当前的工作模式。
78 */
80{
81 for (auto enabled_mode: picking_enabled_modes) {
82 if (mode == enabled_mode) {
83 return true;
84 }
85 }
86 return false;
87}
88
89/*!
90 * \~chinese
91 * \brief 辅助调试的 GUI 选项。
92 */
94{
95 /*! \~chinese 显示进行拾取时生成的虚拟光线。 */
96 bool show_picking_ray = false;
97 /*! \~chinese 显示所有物体的 BVH 结构。 */
98 bool show_BVH = false;
99};
constexpr unsigned int vertex_position_location
定义 rendering.hpp:26
#define RGB_COLOR(r, g, b)
定义 rendering.hpp:17
constexpr unsigned int vertex_normal_location
定义 rendering.hpp:27
bool check_picking_enabled(WorkingMode mode)
判断指定模式是否允许拾取物体。
定义 rendering.hpp:79
WorkingMode
定义 rendering.hpp:55
constexpr WorkingMode picking_enabled_modes[]
允许拾取物体的模式。
定义 rendering.hpp:69
constexpr float line_width
定义 rendering.hpp:39
const Eigen::Vector3f default_wireframe_color(RGB_COLOR(255, 194, 75))
constexpr float point_size
定义 rendering.hpp:34
const Eigen::Vector3f default_face_color(RGB_COLOR(255, 255, 255))
const Eigen::Vector3f highlight_wireframe_color(RGB_COLOR(115, 206, 244))
const Eigen::Vector3f highlight_face_color(RGB_COLOR(115, 206, 244))
辅助调试的 GUI 选项。
定义 rendering.hpp:94
bool show_picking_ray
定义 rendering.hpp:96
bool show_BVH
定义 rendering.hpp:98