xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
xcal
mobject
objects
line.hpp
浏览该文件的文档.
1
#pragma once
2
3
#include <
xcal/public.h
>
4
5
#include <
xcal/mobject/core/composedmobject.hpp
>
6
#include <
xcal/mobject/core/mobject.hpp
>
7
#include <
xcal/property/vec.hpp
>
8
9
namespace
xcal::mobject
{
10
11
class
XCAL_API
Line
:
public
ComposedMObject
<Line, BaseTransformableMobject,
12
StrokeableMObject> {
13
XCAL_MOBJECT_TYPE
(
Line
)
14
public
:
15
using
vec
=
xcmath::vec<float_t, 3>
;
16
using
vec4
=
xcmath::vec<float_t, 4>
;
17
18
private
:
19
property::Vec<float_t, 3>
direct_;
20
21
public
:
22
Line
(
float_t
x1,
float_t
y1,
float_t
z1,
float_t
x2,
float_t
y2,
float_t
z2)
23
:
Line
({x1, y1, z1}, {x2, y2, z2}) {}
24
Line
(
const
vec
& start,
const
vec
& end)
25
:
ComposedMObject
{}, direct_(end - start) {
26
set_pos({(start.
x
() + end.
x
()) / 2, (start.
y
() + end.
y
()) / 2, 0});
27
}
28
explicit
Line
(
float_t
length) : direct_(
vec
{length, 0.0f}) {}
29
30
const
vec4
start
()
const
{
31
return
vec4
{pos().value() - (direct_.
value
() / 2.f), 1.0f};
32
}
33
const
vec4
end
()
const
{
34
return
vec4
{pos().value() + (direct_.
value
() / 2.f), 1.0f};
35
}
36
const
vec
&
direct
()
const
{
return
direct_.
value
(); }
37
property::Vec<float_t, 3>
&
direct
() {
return
direct_; }
38
vec4
center
()
const
{
return
vec4
{pos().value(), 1.0f}; }
39
40
~Line
()
override
=
default
;
41
};
42
43
}
// namespace xcal::mobject
xcal::mobject::ComposedMObject
Definition
composedmobject.hpp:122
xcal::mobject::Line
Definition
line.hpp:12
xcal::mobject::Line::direct
const vec & direct() const
Definition
line.hpp:36
xcal::mobject::Line::end
const vec4 end() const
Definition
line.hpp:33
xcal::mobject::Line::center
vec4 center() const
Definition
line.hpp:38
xcal::mobject::Line::direct
property::Vec< float_t, 3 > & direct()
Definition
line.hpp:37
xcal::mobject::Line::start
const vec4 start() const
Definition
line.hpp:30
xcal::mobject::Line::Line
Line(const vec &start, const vec &end)
Definition
line.hpp:24
xcal::mobject::Line::~Line
~Line() override=default
xcal::mobject::Line::Line
Line(float_t x1, float_t y1, float_t z1, float_t x2, float_t y2, float_t z2)
Definition
line.hpp:22
xcal::mobject::Line::Line
Line(float_t length)
Definition
line.hpp:28
xcal::property::Vec
Definition
vec.hpp:9
xcal::property::Vec::value
data_t & value()
Definition
vec.hpp:26
xcmath::vec
Vector class template
Definition
vec.hpp:206
xcmath::vec::x
constexpr _Tp & x()
Get the item at index 0
Definition
vec.hpp:454
xcmath::vec::y
constexpr _Tp & y()
Get the item at index 1
Definition
vec.hpp:465
composedmobject.hpp
mobject.hpp
基础图形对象类
XCAL_MOBJECT_TYPE
#define XCAL_MOBJECT_TYPE(type)
Definition
mobject_types.hpp:25
xcal::mobject
Definition
abs_mgroup.hpp:14
xcal::float_t
float float_t
Definition
public.h:27
public.h
XCAL_API
#define XCAL_API
Definition
public.h:69
vec.hpp
生成于 2025年 九月 19日 星期五 21:12:12 , 为 xcal使用
1.9.8