mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added opengl primitives
This commit is contained in:
@@ -12,14 +12,10 @@
|
|||||||
|
|
||||||
namespace omath::primitives
|
namespace omath::primitives
|
||||||
{
|
{
|
||||||
using BoxMesh = Mesh<opengl_engine::Mat4X4, opengl_engine::ViewAngles, opengl_engine::MeshTrait, Vertex<>,
|
template<class BoxMeshType>
|
||||||
std::array<Vector3<float>, 8>, std::array<Vector3<std::uint32_t>, 12>>;
|
|
||||||
|
|
||||||
template<class BoxMeshType = BoxMesh>
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
BoxMeshType
|
BoxMeshType create_box(const Vector3<float>& top, const Vector3<float>& bottom, const Vector3<float>& dir_forward,
|
||||||
create_box(const Vector3<float>& top, const Vector3<float>& bottom, const Vector3<float>& dir_forward,
|
const Vector3<float>& dir_right, const float ratio = 4.f) noexcept
|
||||||
const Vector3<float>& dir_right, const float ratio = 4.f) noexcept
|
|
||||||
{
|
{
|
||||||
const auto height = top.distance_to(bottom);
|
const auto height = top.distance_to(bottom);
|
||||||
const auto side_size = height / ratio;
|
const auto side_size = height / ratio;
|
||||||
|
|||||||
@@ -13,11 +13,9 @@
|
|||||||
|
|
||||||
namespace omath::primitives
|
namespace omath::primitives
|
||||||
{
|
{
|
||||||
using PlaneMesh = Mesh<opengl_engine::Mat4X4, opengl_engine::ViewAngles, opengl_engine::MeshTrait, Vertex<>,
|
|
||||||
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
|
||||||
template<class PlaneMeshType>
|
template<class PlaneMeshType>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
PlaneMesh create_plane(const Vector3<float>& vertex_a, const Vector3<float>& vertex_b,
|
PlaneMeshType create_plane(const Vector3<float>& vertex_a, const Vector3<float>& vertex_b,
|
||||||
const Vector3<float>& direction, const float size) noexcept
|
const Vector3<float>& direction, const float size) noexcept
|
||||||
{
|
{
|
||||||
const auto second_vertex_a = vertex_a + direction * size;
|
const auto second_vertex_a = vertex_a + direction * size;
|
||||||
|
|||||||
17
include/omath/engines/opengl_engine/primitives.hpp
Normal file
17
include/omath/engines/opengl_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::opengl_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::opengl_engine
|
||||||
@@ -2,10 +2,11 @@
|
|||||||
// Created by Vladislav on 11.01.2026.
|
// Created by Vladislav on 11.01.2026.
|
||||||
//
|
//
|
||||||
#include "omath/3d_primitives/box.hpp"
|
#include "omath/3d_primitives/box.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/primitives.hpp"
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
TEST(test, test)
|
TEST(test, test)
|
||||||
{
|
{
|
||||||
auto result = omath::primitives::create_box({0.f, 30.f, 0.f}, {}, omath::opengl_engine::k_abs_forward,
|
auto result = omath::primitives::create_box<omath::opengl_engine::BoxMesh>({0.f, 30.f, 0.f}, {}, omath::opengl_engine::k_abs_forward,
|
||||||
omath::opengl_engine::k_abs_right);
|
omath::opengl_engine::k_abs_right);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user