forgotten commit
This commit is contained in:
parent
1d208c73e3
commit
8b9f15a566
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
0
CMakeLists.txt
Executable file → Normal file
0
CMakeLists.txt
Executable file → Normal file
0
cmake/external/glad.cmake
vendored
Executable file → Normal file
0
cmake/external/glad.cmake
vendored
Executable file → Normal file
0
cmake/external/glfw.cmake
vendored
Executable file → Normal file
0
cmake/external/glfw.cmake
vendored
Executable file → Normal file
0
cmake/external/glm.cmake
vendored
Executable file → Normal file
0
cmake/external/glm.cmake
vendored
Executable file → Normal file
0
cmake/external/googletest.cmake
vendored
Executable file → Normal file
0
cmake/external/googletest.cmake
vendored
Executable file → Normal file
0
cmake/external/imgui.cmake
vendored
Executable file → Normal file
0
cmake/external/imgui.cmake
vendored
Executable file → Normal file
0
cmake/external/implot.cmake
vendored
Executable file → Normal file
0
cmake/external/implot.cmake
vendored
Executable file → Normal file
0
cmake/external/occt.cmake
vendored
Executable file → Normal file
0
cmake/external/occt.cmake
vendored
Executable file → Normal file
0
cmake/external/onetbb.cmake
vendored
Executable file → Normal file
0
cmake/external/onetbb.cmake
vendored
Executable file → Normal file
0
cmake/external/openxlsx.cmake
vendored
Executable file → Normal file
0
cmake/external/openxlsx.cmake
vendored
Executable file → Normal file
0
cmake/external/stb.cmake
vendored
Executable file → Normal file
0
cmake/external/stb.cmake
vendored
Executable file → Normal file
0
cmake/hpr-macros.cmake
Executable file → Normal file
0
cmake/hpr-macros.cmake
Executable file → Normal file
0
cmake/templates/Config.cmake.in
Executable file → Normal file
0
cmake/templates/Config.cmake.in
Executable file → Normal file
0
cmake/templates/cmake_uninstall.cmake.in
Executable file → Normal file
0
cmake/templates/cmake_uninstall.cmake.in
Executable file → Normal file
0
cmake/toolchains/linux-gcc.cmake
Executable file → Normal file
0
cmake/toolchains/linux-gcc.cmake
Executable file → Normal file
0
cmake/toolchains/mingw-gcc.cmake
Executable file → Normal file
0
cmake/toolchains/mingw-gcc.cmake
Executable file → Normal file
0
cmake/tools/CPM.cmake
Executable file → Normal file
0
cmake/tools/CPM.cmake
Executable file → Normal file
0
docs/CMakeLists.txt
Executable file → Normal file
0
docs/CMakeLists.txt
Executable file → Normal file
0
docs/api/Doxyfile.in
Executable file → Normal file
0
docs/api/Doxyfile.in
Executable file → Normal file
2
source/applications/CMakeLists.txt
Executable file → Normal file
2
source/applications/CMakeLists.txt
Executable file → Normal file
@ -1,2 +1,2 @@
|
|||||||
#add_subdirectory(periodic)
|
|
||||||
add_subdirectory(fes)
|
add_subdirectory(fes)
|
||||||
|
add_subdirectory(periodic)
|
||||||
|
0
source/applications/fes/CMakeLists.txt
Executable file → Normal file
0
source/applications/fes/CMakeLists.txt
Executable file → Normal file
0
source/applications/fes/fes.cpp
Executable file → Normal file
0
source/applications/fes/fes.cpp
Executable file → Normal file
0
source/applications/fes/fes.xlsx
Executable file → Normal file
0
source/applications/fes/fes.xlsx
Executable file → Normal file
4
source/applications/periodic/CMakeLists.txt
Executable file → Normal file
4
source/applications/periodic/CMakeLists.txt
Executable file → Normal file
@ -1,11 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(periodic
|
project(periodic
|
||||||
VERSION "0.1.0"
|
VERSION 0.1.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
add_executable(periodic
|
add_executable(periodic
|
||||||
periodic.cpp
|
periodic.cpp
|
||||||
)
|
)
|
||||||
@ -14,3 +15,4 @@ target_link_libraries(periodic
|
|||||||
hpr::csg
|
hpr::csg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} -static gcc stdc++ winpthread -dynamic)
|
||||||
|
48
source/applications/periodic/cell.hpp
Normal file
48
source/applications/periodic/cell.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "lattice.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace hpr::csg
|
||||||
|
{
|
||||||
|
|
||||||
|
class Cell //: public csg::Shape
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Lattice p_lattice;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Cell() = delete;
|
||||||
|
|
||||||
|
Cell(const Lattice& lattice) :
|
||||||
|
p_lattice {lattice}
|
||||||
|
{}
|
||||||
|
|
||||||
|
Shape operator()(const vec3& size, const vec3& scale = {1, 1, 1}, const vec3& translation = {0, 0, 0}, const vec3& rotation = {0, 0, 0})
|
||||||
|
{
|
||||||
|
// scale should be equal for both of cell and lattice
|
||||||
|
|
||||||
|
/*Shape box = lattice.box();
|
||||||
|
box = box.translate(lattice.os1() * p_shift[0]);
|
||||||
|
box = box.translate(lattice.os2() * p_shift[1]);
|
||||||
|
box = box.translate(lattice.os3() * p_shift[2]);*/
|
||||||
|
Shape cellBox = csg::box({0, 0, 0}, scale);
|
||||||
|
vec3 dir = -cellBox.center();
|
||||||
|
cellBox = csg::translate(cellBox, dir);
|
||||||
|
cellBox = csg::rotate(cellBox, cellBox.center(), {1, 0, 0}, rotation[0]);
|
||||||
|
cellBox = csg::rotate(cellBox, cellBox.center(), {0, 1, 0}, rotation[1]);
|
||||||
|
cellBox = csg::rotate(cellBox, cellBox.center(), {0, 0, 1}, rotation[2]);
|
||||||
|
cellBox = csg::translate(cellBox, translation);
|
||||||
|
cellBox = csg::scale(cellBox, size);
|
||||||
|
|
||||||
|
Shape lattice = p_lattice(size, {90, 90, 90}, 1.1);
|
||||||
|
lattice = csg::translate(lattice, -size * 0.5);
|
||||||
|
|
||||||
|
return csg::cut(cellBox, lattice).tshape();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
47
source/applications/periodic/cluster.hpp
Normal file
47
source/applications/periodic/cluster.hpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cell.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace hpr::csg
|
||||||
|
{
|
||||||
|
|
||||||
|
class Cluster //: public csg::Shape
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
vec3 p_cluster;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Cluster() = delete;
|
||||||
|
|
||||||
|
Cluster(vec3 cluster, const Lattice& lattice, const vec3& shift) :
|
||||||
|
p_cluster {cluster}
|
||||||
|
{}
|
||||||
|
|
||||||
|
Shape operator()()
|
||||||
|
{
|
||||||
|
auto cell = Cell(lattice, shift);
|
||||||
|
darray<Shape> args {cell};
|
||||||
|
darray<Shape> xcells {cell};
|
||||||
|
darray<Shape> ycells ;
|
||||||
|
darray<Shape> zcells ;
|
||||||
|
|
||||||
|
for (auto n = 0; n <= cluster[0]; ++n)
|
||||||
|
xcells.push(cell.translate(lattice.os1() * lattice.lengths()[0] * n));
|
||||||
|
|
||||||
|
for (auto n = 0; n <= cluster[1]; ++n)
|
||||||
|
for (const auto& cell_ : xcells)
|
||||||
|
ycells.push(cell_.translate(lattice.os2() * lattice.lengths()[1] * n));
|
||||||
|
|
||||||
|
for (auto n = 0; n <= cluster[2]; ++n)
|
||||||
|
for (const auto& cell_ : ycells)
|
||||||
|
zcells.push(cell_.translate(lattice.os3() * lattice.lengths()[2] * n));
|
||||||
|
|
||||||
|
p_shape = csg::fuse({zcells.pop()}, zcells).tshape();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
242
source/applications/periodic/lattice.hpp
Executable file → Normal file
242
source/applications/periodic/lattice.hpp
Executable file → Normal file
@ -10,12 +10,12 @@ void prints(scalar point)
|
|||||||
{
|
{
|
||||||
std::cout << point << std::endl;
|
std::cout << point << std::endl;
|
||||||
}
|
}
|
||||||
class Lattice : public csg::Shape
|
class Lattice //: public csg::Shape
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum class System
|
enum LatticeSystem
|
||||||
{
|
{
|
||||||
Triclinic,
|
Triclinic,
|
||||||
Monoclinic,
|
Monoclinic,
|
||||||
@ -27,47 +27,44 @@ public:
|
|||||||
Unknown
|
Unknown
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Type
|
enum LatticeType
|
||||||
{
|
{
|
||||||
Primitive,
|
Primitive,
|
||||||
BaseCentered,
|
BaseCentered,
|
||||||
BodyCentered,
|
BodyCentered,
|
||||||
FaceCentered,
|
FaceCentered
|
||||||
Unknown
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
vec3 p_lengths;
|
vec3 p_lengths;
|
||||||
vec3 p_angles;
|
vec3 p_angles;
|
||||||
Type p_type;
|
LatticeType p_type;
|
||||||
scalar p_radius;
|
scalar p_radius;
|
||||||
darray<vec3> p_controlPoints;
|
Vector<unsigned int, 3> p_cluster;
|
||||||
|
darray<vec3> p_cornerPoints;
|
||||||
|
darray<vec3> p_faceBodyPoints;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Lattice() = delete;
|
Lattice() = delete;
|
||||||
|
|
||||||
Lattice(const vec3& lengths, const vec3& angles, scalar radius, Type type) :
|
Lattice(LatticeType ltype) : //const vec3& lengths, const vec3& angles, scalar radius, LatticeType ltype) :
|
||||||
csg::Shape {},
|
//csg::Shape {},
|
||||||
p_lengths {lengths},
|
p_lengths {},//{lengths},
|
||||||
p_angles {angles},
|
p_angles {},//{angles},
|
||||||
p_radius {radius},
|
p_radius {},//{radius},
|
||||||
p_type {type}
|
p_type {ltype}
|
||||||
|
{}
|
||||||
|
|
||||||
|
darray<vec3> cornerPoints() const
|
||||||
{
|
{
|
||||||
generateControlPoints();
|
return p_cornerPoints;
|
||||||
darray<csg::Shape> spheres;
|
|
||||||
for (const auto& point : controlPoints()) {
|
|
||||||
spheres.push(csg::sphere(point, p_radius));
|
|
||||||
print(point);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p_shape = csg::Compound(spheres).tshape();//csg::fuse({spheres.front()}, spheres.slice(spheres.begin() + 1, spheres.end())).tshape();
|
darray<vec3> faceBodyPoints() const
|
||||||
}
|
|
||||||
|
|
||||||
darray<vec3> controlPoints() const
|
|
||||||
{
|
{
|
||||||
return p_controlPoints;
|
return p_faceBodyPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 lengths() const
|
vec3 lengths() const
|
||||||
@ -80,125 +77,142 @@ public:
|
|||||||
return p_angles;
|
return p_angles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateControlPoints()
|
darray<scalar> faceIndices() const
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
2, 6, 4, 0, // x0
|
||||||
|
1, 5, 7, 3, // x+ 1
|
||||||
|
0, 4, 5, 1, // y0
|
||||||
|
3, 7, 6, 2, // y+ 3
|
||||||
|
2, 0, 1, 3, // z0
|
||||||
|
4, 6, 7, 5 // z+ 5
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
vec3 os1() const
|
||||||
|
{
|
||||||
|
return {1, 0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
vec3 os2() const
|
||||||
|
{
|
||||||
|
return hpr::rotate(os1(), {0, 0, 1}, rad(p_angles[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
vec3 os3() const
|
||||||
{
|
{
|
||||||
if (p_type == Type::Unknown)
|
|
||||||
throw std::runtime_error("Unknown type of lattice");
|
|
||||||
p_controlPoints.resize(14);
|
|
||||||
//
|
|
||||||
vec3 ox {1, 0, 0};
|
|
||||||
vec3 oy {0, 1, 0};
|
|
||||||
vec3 oz {0, 0, 1};
|
vec3 oz {0, 0, 1};
|
||||||
vec3 ox1 = hpr::rotate(ox, oz, rad(-p_angles[2]));
|
vec3 os3_ = hpr::rotate(os1(), oz, rad(0.5 * p_angles[2]));
|
||||||
p_controlPoints.push(vec3{0, 0, 0});
|
scalar gamma = asin(sqrt(1 - 3 * pow(cos(rad(p_angles[0])), 2) + 2 * pow(cos(rad(p_angles[0])), 3)) / sin(rad(p_angles[0])));
|
||||||
p_controlPoints.push(vec3{0, p_lengths[0], 0});
|
|
||||||
vec3 t1 = hpr::translate(p_controlPoints.back(), ox1 * p_lengths[1]);
|
return hpr::rotate(os3_, hpr::rotate(os3_, oz, rad(90)), -gamma);
|
||||||
p_controlPoints.push(t1);
|
}
|
||||||
p_controlPoints.push(hpr::translate(p_controlPoints.front(), ox1 * p_lengths[1]));
|
|
||||||
print(t1);
|
void generateControlPoints(const vec3& lengths, const vec3& angles)
|
||||||
print(ox1);
|
{
|
||||||
scalar c1 = cos(rad(p_angles[2])), c2 = cos(rad(p_angles[1])), c3 = cos(rad(p_angles[0]));
|
p_angles = angles;
|
||||||
scalar D1 = sqrt(det(mat3(
|
p_lengths = lengths;
|
||||||
1, cos(rad(p_angles[2])), cos(rad(p_angles[1])),
|
|
||||||
cos(rad(p_angles[2])), 1, cos(rad(p_angles[0])),
|
auto translatePoint = [](const hpr::vec3& v1, const hpr::vec3& v2)
|
||||||
cos(rad(p_angles[1])), cos(rad(p_angles[0])), 1)));
|
{
|
||||||
scalar volume = 1. / 6. * p_lengths[0] * p_lengths[1] * p_lengths[2] *
|
return hpr::vec3(hpr::translate(hpr::mat4::identity(), v2) * hpr::vec4(v1, 1.0f));
|
||||||
D1;
|
};
|
||||||
scalar s1 = sqrt(pow(p_lengths[0], 2) + pow(p_lengths[1], 2) - 2 *
|
|
||||||
p_lengths[0] * p_lengths[1] * cos(rad(p_angles[2])));
|
if (!p_cornerPoints.is_empty())
|
||||||
scalar s2 = sqrt(pow(p_lengths[1], 2) + pow(p_lengths[2], 2) - 2 *
|
p_cornerPoints.clear();
|
||||||
p_lengths[1] * p_lengths[2] * cos(rad(p_angles[1])));
|
if (!p_faceBodyPoints.is_empty())
|
||||||
scalar s3 = sqrt(pow(p_lengths[0], 2) + pow(p_lengths[2], 2) - 2 *
|
p_faceBodyPoints.clear();
|
||||||
p_lengths[0] * p_lengths[2] * cos(rad(p_angles[0])));
|
|
||||||
scalar area = 1. / 2. * p_lengths[0] * p_lengths[1] *
|
p_cornerPoints.resize(8);
|
||||||
sqrt(det(mat2{1, cos(rad(p_angles[2])), cos(rad(p_angles[2])), 1}));
|
p_faceBodyPoints.resize(7);
|
||||||
scalar h1 = 3 * volume / area;
|
|
||||||
scalar a1 = asin(h1 / p_lengths[2]);
|
// p_corner points
|
||||||
scalar sh1 = sqrt(pow(p_lengths[2], 2) - pow(h1, 2));
|
p_cornerPoints.push(vec3{0, 0, 0});
|
||||||
scalar sh2 = p_lengths[2] * cos(rad(p_angles[0]));
|
p_cornerPoints.push(vec3(lengths[0], 0, 0));
|
||||||
scalar a2 = acos(sh2 / sh1);
|
p_cornerPoints.push(translatePoint(p_cornerPoints[0], os2() * lengths[1]));
|
||||||
|
p_cornerPoints.push(translatePoint(p_cornerPoints[1], os2() * lengths[1]));
|
||||||
|
|
||||||
vec3 ox2 = hpr::rotate(ox, oy, a1);
|
|
||||||
if (!isnan(a2))
|
|
||||||
ox2 = hpr::rotate(ox2, oz, a2);
|
|
||||||
print(ox2);
|
|
||||||
for (auto n = 0; n < 4; ++n)
|
for (auto n = 0; n < 4; ++n)
|
||||||
p_controlPoints.push(hpr::translate(p_controlPoints[n], ox2 * p_lengths[2]));
|
p_cornerPoints.push(translatePoint(p_cornerPoints[n], os3() * lengths[2]));
|
||||||
|
|
||||||
/*p_controlPoints.push(vec3{p_lengths[0], p_lengths[1], 0});
|
|
||||||
p_controlPoints.push(vec3{p_lengths[0], 0, 0});
|
|
||||||
|
|
||||||
p_controlPoints.push(vec3{0, 0, p_lengths[2]});
|
|
||||||
p_controlPoints.push(vec3{0, p_lengths[1], p_lengths[2]});
|
|
||||||
p_controlPoints.push(vec3{p_lengths[0], p_lengths[1], p_lengths[2]});
|
|
||||||
p_controlPoints.push(vec3{p_lengths[0], 0, p_lengths[2]});
|
|
||||||
|
|
||||||
|
// face/body points
|
||||||
// central points on base faces
|
// central points on base faces
|
||||||
if (p_type == Type::BaseCentered || p_type == Type::FaceCentered)
|
if (p_type == BaseCentered || p_type == FaceCentered)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < 2; ++n)
|
for (int n = 0; n < 2; ++n)
|
||||||
{
|
{
|
||||||
vec3 center;
|
vec3 center;
|
||||||
for (int k = 0; k < 4; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
center += p_controlPoints[k + 4 * n];
|
center += p_cornerPoints[static_cast<Size>(faceIndices()[k + 4 * (n + 4)])];
|
||||||
p_controlPoints.push(center * 0.25);
|
p_faceBodyPoints.push(center * 0.25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// central point (center of mass)
|
// central point (center of mass)
|
||||||
if (p_type == Type::BodyCentered)
|
if (p_type == BodyCentered)
|
||||||
{
|
{
|
||||||
vec3 center;
|
p_faceBodyPoints.push(sum(p_cornerPoints) / p_cornerPoints.size());
|
||||||
for (const auto& point : p_controlPoints)
|
|
||||||
center += point;
|
|
||||||
p_controlPoints.push(center / p_controlPoints.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// central points on side faces
|
// central points on side faces
|
||||||
if (p_type == Type::FaceCentered)
|
if (p_type == FaceCentered)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < 3; ++n)
|
for (int n = 0; n < 4; ++n)
|
||||||
{
|
{
|
||||||
vec3 center;
|
vec3 center;
|
||||||
for (int k = 0; k < 2; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
{
|
center += p_cornerPoints[static_cast<Size>(faceIndices()[k + n * 4])];
|
||||||
center += p_controlPoints[n + k];
|
p_faceBodyPoints.push(center * 0.25);
|
||||||
center += p_controlPoints[n + k + 4];
|
|
||||||
}
|
}
|
||||||
p_controlPoints.push(center * 0.25);
|
|
||||||
}
|
}
|
||||||
vec3 center;
|
|
||||||
for (int n = 0; n < 2; ++n)
|
|
||||||
{
|
|
||||||
center += p_controlPoints[n * 3];
|
|
||||||
center += p_controlPoints[4 + n * 3];
|
|
||||||
}
|
|
||||||
p_controlPoints.push(center * 0.25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mat4 trans = mat4::identity();
|
Shape operator()(const vec3& lengths, const vec3& angles, scalar radius)
|
||||||
vec3 ox {1, 0, 0};
|
|
||||||
vec3 oy {0, 1, 0};
|
|
||||||
vec3 oz {0, 0, 1};
|
|
||||||
int n = 0;
|
|
||||||
for (auto& point : p_controlPoints)
|
|
||||||
{
|
{
|
||||||
if (n == 0 || n == 3)
|
generateControlPoints(lengths, angles);
|
||||||
{
|
|
||||||
++n;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
trans.row(3, vec4(point, 0));
|
|
||||||
trans = hpr::rotate(trans, oz, -radians(90 - p_angles[2]));
|
|
||||||
if (n >= 4 && n <= 7)
|
|
||||||
{
|
|
||||||
trans = hpr::rotate(trans, ox, -radians(90 - p_angles[1]));
|
|
||||||
trans = hpr::rotate(trans, oy, -radians(90 - p_angles[0]));
|
|
||||||
}
|
|
||||||
point = vec3(trans.row(3)[0], trans.row(3)[1], trans.row(3)[2]);
|
|
||||||
++n;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
darray<csg::Shape> args;
|
||||||
|
darray<csg::Shape> tools;
|
||||||
|
bool skip = false;
|
||||||
|
|
||||||
|
for (const auto& point : cornerPoints())
|
||||||
|
{
|
||||||
|
if (!skip) {
|
||||||
|
args.push(csg::sphere(point, radius));
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tools.push(csg::sphere(point, radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& point : faceBodyPoints()) {
|
||||||
|
tools.push(csg::sphere(point, radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
return csg::fuse(args, tools).tshape();
|
||||||
|
//args.push(tools);
|
||||||
|
//return Compound(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape box() const
|
||||||
|
{
|
||||||
|
darray<Face> faces;
|
||||||
|
|
||||||
|
for (auto n = 0; n < 6; ++n)
|
||||||
|
{
|
||||||
|
darray<Edge> edges;
|
||||||
|
|
||||||
|
edges.push(Edge(cornerPoints()[faceIndices()[0 + n * 4]], cornerPoints()[faceIndices()[1 + n * 4]]));
|
||||||
|
edges.push(Edge(cornerPoints()[faceIndices()[1 + n * 4]], cornerPoints()[faceIndices()[2 + n * 4]]));
|
||||||
|
edges.push(Edge(cornerPoints()[faceIndices()[2 + n * 4]], cornerPoints()[faceIndices()[3 + n * 4]]));
|
||||||
|
edges.push(Edge(cornerPoints()[faceIndices()[3 + n * 4]], cornerPoints()[faceIndices()[0 + n * 4]]));
|
||||||
|
faces.push(Face(edges));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Solid(Shell::sew(faces));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
242
source/applications/periodic/periodic.cpp
Executable file → Normal file
242
source/applications/periodic/periodic.cpp
Executable file → Normal file
@ -13,222 +13,9 @@ void print(vec3 vs)
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Periodic
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
scalar p_alpha;
|
|
||||||
scalar p_initialRadius;
|
|
||||||
scalar p_sideLength;
|
|
||||||
scalar p_filletScale;
|
|
||||||
vec3 p_direction;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Periodic() :
|
|
||||||
p_alpha {0.1},
|
|
||||||
p_initialRadius {1},
|
|
||||||
p_filletScale {0.8},
|
|
||||||
p_direction {}
|
|
||||||
{}
|
|
||||||
|
|
||||||
Periodic(scalar alpha, scalar initialRadius, scalar filletScale, const vec3& direction) :
|
|
||||||
p_alpha {alpha},
|
|
||||||
p_initialRadius {initialRadius},
|
|
||||||
p_filletScale {filletScale},
|
|
||||||
p_direction {direction}
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~Periodic() = default;
|
|
||||||
|
|
||||||
scalar& alpha()
|
|
||||||
{
|
|
||||||
return p_alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar& initialRadius()
|
|
||||||
{
|
|
||||||
return p_initialRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
scalar sideLength() = 0;
|
|
||||||
|
|
||||||
virtual
|
|
||||||
scalar gamma() = 0;
|
|
||||||
|
|
||||||
scalar& filletScale()
|
|
||||||
{
|
|
||||||
return p_filletScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar radius() const
|
|
||||||
{
|
|
||||||
return p_initialRadius / (1. - p_alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar filletRadius()
|
|
||||||
{
|
|
||||||
scalar analytical = p_initialRadius * sqrt(2) / sqrt(1 - cos(gamma())) - radius();
|
|
||||||
return analytical * p_filletScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3& direction()
|
|
||||||
{
|
|
||||||
return p_direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
void build() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Simple : public Periodic, public csg::Shape
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Simple() :
|
|
||||||
csg::Shape {},
|
|
||||||
Periodic {0.01, 1, 0.8, vec3(1., 0., 0.)}
|
|
||||||
{}
|
|
||||||
|
|
||||||
Simple(scalar alpha, const vec3& direction, scalar filletScale = 0.8) :
|
|
||||||
Simple {}
|
|
||||||
{
|
|
||||||
p_alpha = alpha;
|
|
||||||
p_direction = direction;
|
|
||||||
p_filletScale = filletScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
Simple(scalar alpha, scalar initialRadius, scalar filletScale, const vec3& direction) :
|
|
||||||
Periodic {alpha, initialRadius, filletScale, direction}
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Simple() override = default;
|
|
||||||
|
|
||||||
scalar sideLength() override
|
|
||||||
{
|
|
||||||
return 2 * initialRadius();
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar gamma() override
|
|
||||||
{
|
|
||||||
return hpr::PI - 2 * 0.5 * 0.5 * hpr::PI;
|
|
||||||
}
|
|
||||||
|
|
||||||
csg::Shape lattice()
|
|
||||||
{
|
|
||||||
csg::Shape lattice;
|
|
||||||
darray<csg::Shape> spheres;
|
|
||||||
|
|
||||||
for (int zn = 0; zn < 3; ++zn)
|
|
||||||
{
|
|
||||||
scalar z = zn * sideLength();
|
|
||||||
for (int yn = 0; yn < 3; ++yn)
|
|
||||||
{
|
|
||||||
scalar y = yn * sideLength();
|
|
||||||
for (int xn = 0; xn < 3; ++xn)
|
|
||||||
{
|
|
||||||
scalar x = xn * sideLength();
|
|
||||||
spheres.push(csg::sphere(vec3(x, y, z), radius()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lattice = csg::fuse({spheres.front()}, spheres.slice(spheres.begin() + 1, spheres.end()));
|
|
||||||
|
|
||||||
if (filletScale() > 0)
|
|
||||||
{
|
|
||||||
lattice = lattice.scale({0, 0, 0}, 1e+2);
|
|
||||||
lattice = lattice.fillet(lattice.edges(), filletRadius() * 1e+2);
|
|
||||||
lattice = lattice.scale({0, 0, 0}, 1e-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << (int)lattice.type() << std::endl;
|
|
||||||
return lattice;
|
|
||||||
}
|
|
||||||
|
|
||||||
csg::Shape boxCell()
|
|
||||||
{
|
|
||||||
scalar length = sideLength() * sqrt(2);
|
|
||||||
scalar width = sideLength() * sqrt(2);
|
|
||||||
scalar height = sideLength();
|
|
||||||
scalar xl = sqrt(pow(length, 2) * 0.5);
|
|
||||||
scalar yw = xl;
|
|
||||||
scalar zh = height;
|
|
||||||
darray<Shape> edges {
|
|
||||||
csg::Edge({xl, 0, 0}, {0, yw, 0}),
|
|
||||||
csg::Edge({0, yw, 0}, {0, yw, zh}),
|
|
||||||
csg::Edge({0, yw, zh}, {xl, 0, zh}),
|
|
||||||
csg::Edge({xl, 0, zh}, {xl, 0, 0})
|
|
||||||
};
|
|
||||||
csg::Face plgm {edges};
|
|
||||||
|
|
||||||
vec3 localX {csg::Surface(plgm).normal(0, 0)};
|
|
||||||
vec3 localZ = vec3(0, 0, 1);
|
|
||||||
vec3 localY = cross(localX, localZ);
|
|
||||||
csg::Shape cell = plgm.extrude(localX, width);
|
|
||||||
|
|
||||||
scalar angle;
|
|
||||||
hpr::vec3 normal;
|
|
||||||
|
|
||||||
for (auto& face : cell.faces())
|
|
||||||
{
|
|
||||||
normal = csg::Surface(csg::Face(face)).normal(0, 0);
|
|
||||||
angle = hpr::angle(localX, normal);
|
|
||||||
|
|
||||||
if (face.tshape().Orientation() == TopAbs_FORWARD)
|
|
||||||
{
|
|
||||||
normal = -normal;
|
|
||||||
angle = hpr::angle(localX, normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (equal(angle, 0.))
|
|
||||||
face.label("periodic-south");
|
|
||||||
else if (equal(angle, hpr::PI))
|
|
||||||
face.label("periodic-north");
|
|
||||||
|
|
||||||
angle = hpr::angle(localY, normal);
|
|
||||||
if (equal(angle, 0.))
|
|
||||||
face.label("periodic-east");
|
|
||||||
else if (equal(angle, hpr::PI))
|
|
||||||
face.label("periodic-west");
|
|
||||||
|
|
||||||
angle = hpr::angle(localZ, normal);
|
|
||||||
if (equal(angle, hpr::PI))
|
|
||||||
face.label("periodic-down");
|
|
||||||
else if (equal(angle, 0.))
|
|
||||||
face.label("periodic-up");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << (int)cell.type() << std::endl;
|
|
||||||
return cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
csg::Shape hexagonalPrismCell()
|
|
||||||
{
|
|
||||||
return csg::Shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
void build() override
|
|
||||||
{
|
|
||||||
if (direction() == vec3(1., 0., 0.) || direction() == vec3(1., 0., 0.) || direction() == vec3(0., 0., 1.))
|
|
||||||
p_shape = csg::cut(boxCell(), lattice()).tshape();
|
|
||||||
else if (direction() == vec3(1., 1., 1.))
|
|
||||||
p_shape = csg::cut(hexagonalPrismCell(), lattice()).tshape();
|
|
||||||
else
|
|
||||||
throw std::runtime_error("Undefined cell for passed direction");
|
|
||||||
|
|
||||||
|
|
||||||
p_shape = this->translate(-this->center()).tshape();
|
|
||||||
p_shape = this->rotate(this->center(), {0, 0, 1}, 45).tshape();
|
|
||||||
|
|
||||||
for (auto& face : faces())
|
|
||||||
if (face.label() == "default")
|
|
||||||
face.label("wall");
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "lattice.hpp"
|
#include "lattice.hpp"
|
||||||
|
#include "cell.hpp"
|
||||||
|
//#include "cluster.hpp"
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
@ -238,7 +25,28 @@ int main(int argc, char** argv)
|
|||||||
std::cout << (int)simple.type() << std::endl;
|
std::cout << (int)simple.type() << std::endl;
|
||||||
std::cout << simple.volume() << std::endl;
|
std::cout << simple.volume() << std::endl;
|
||||||
*/
|
*/
|
||||||
csg::Lattice lattice {{2, 2, 2}, {90, 90, 90}, 1, csg::Lattice::Type::Primitive};
|
auto translatePoint = [](const hpr::vec3& v1, const hpr::vec3& v2)
|
||||||
lattice.dump("latticeTest.step", csg::Shape::Format::STEP);
|
{
|
||||||
|
return hpr::vec3(hpr::translate(hpr::mat4::identity(), v2) * hpr::vec4(v1, 1.0f));
|
||||||
|
};
|
||||||
|
csg::Lattice lattice {csg::Lattice::Primitive};//{{2, 2, 2}, {90, 90, 90}, 1.1, csg::Lattice::Primitive};
|
||||||
|
//lattice.dump("latticeTest.step", csg::Shape::Format::STEP);
|
||||||
|
//lattice.box().dump("latticeBoxTest.step", csg::Shape::Format::STEP);
|
||||||
|
csg::Shape cell = csg::Cell(lattice)({2, 2, 2}, {1.414213, 1.414213, 1}, {1.41421, 1.41421, 0}, {0, 0, 45});
|
||||||
|
//std::cout << (int)cell.type() << std::endl;
|
||||||
|
//csg::Cluster cluster {{2, 2, 2}, lattice, {0, 0, 0}};
|
||||||
|
cell.dump("cellTest.step", csg::Shape::Format::STEP);
|
||||||
|
|
||||||
|
//darray<csg::Shape> clusterShapes = csg::array(cell, lattice.os1(), 3, lattice.os2(), 3, lattice.os3(), 3).subShapes(csg::Shape::Type::Solid);
|
||||||
|
//std::cout << clusterShapes.size() << std::endl;
|
||||||
|
//csg::Shape cluster = csg::fuse({clusterShapes.pop()}, clusterShapes);
|
||||||
|
//cluster.dump("clusterTest.step", csg::Shape::Format::STEP);
|
||||||
|
|
||||||
|
|
||||||
|
/*csg::Lattice lattice2 {{4 / sqrt(3), 4 / sqrt(3), 4 / sqrt(3)}, {90, 90, 90}, 1.1, csg::Lattice::BodyCentered};
|
||||||
|
csg::Cluster cluster2 {{2, 2, 2}, lattice2, {0, 0, 0}};
|
||||||
|
csg::Lattice lattice3 {{4 / sqrt(2), 4 / sqrt(2), 4 / sqrt(2)}, {90, 90, 90}, 1.1, csg::Lattice::FaceCentered};
|
||||||
|
csg::Cluster cluster3 {{2, 2, 2}, lattice3, {0, 0, 0}};
|
||||||
|
cluster3.dump("cluster3Test.step", csg::Shape::Format::STEP);*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
4
source/creator/CMakeLists.txt
Executable file → Normal file
4
source/creator/CMakeLists.txt
Executable file → Normal file
@ -33,7 +33,7 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
add_executable(hyporo-creator
|
add_executable(hyporo-creator
|
||||||
test2.cpp
|
test3.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(hyporo-creator
|
target_link_libraries(hyporo-creator
|
||||||
@ -41,6 +41,8 @@ target_link_libraries(hyporo-creator
|
|||||||
imgui::imgui
|
imgui::imgui
|
||||||
implot::implot
|
implot::implot
|
||||||
glm::glm
|
glm::glm
|
||||||
|
hpr::csg
|
||||||
|
hpr::mesh
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(hyporo-creator -static gcc stdc++ winpthread -dynamic)
|
target_link_libraries(hyporo-creator -static gcc stdc++ winpthread -dynamic)
|
||||||
|
1401
source/creator/FontAwesome6.hpp
Normal file
1401
source/creator/FontAwesome6.hpp
Normal file
File diff suppressed because it is too large
Load Diff
786
source/creator/application.hpp
Normal file
786
source/creator/application.hpp
Normal file
@ -0,0 +1,786 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hpr/gpu.hpp>
|
||||||
|
#include "shaders.hpp"
|
||||||
|
#include "camera.hpp"
|
||||||
|
#include "entity.hpp"
|
||||||
|
#include "ui.hpp"
|
||||||
|
|
||||||
|
using namespace hpr;
|
||||||
|
|
||||||
|
Entity testEntity(gpu::ShaderProgram* shaderProgram)
|
||||||
|
{
|
||||||
|
darray<vec3> vertices {
|
||||||
|
/*vec2(-0.5f, 0.5f),
|
||||||
|
vec2(0.5f, 0.5f),
|
||||||
|
vec2(0.5f, -0.5f),
|
||||||
|
vec2(-0.5f, -0.5f)*/
|
||||||
|
vec3(-0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(-0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, -0.5f),
|
||||||
|
|
||||||
|
vec3(-0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, 0.5f),
|
||||||
|
|
||||||
|
vec3(-0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, 0.5f, 0.5f),
|
||||||
|
|
||||||
|
vec3(0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(0.5f, 0.5f, 0.5f),
|
||||||
|
|
||||||
|
vec3(-0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(0.5f, -0.5f, -0.5f),
|
||||||
|
vec3(0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, -0.5f, -0.5f),
|
||||||
|
|
||||||
|
vec3(-0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(0.5f, 0.5f, -0.5f),
|
||||||
|
vec3(0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, 0.5f, 0.5f),
|
||||||
|
vec3(-0.5f, 0.5f, -0.5f)
|
||||||
|
};
|
||||||
|
darray<vec3> normals {
|
||||||
|
vec3(0.0f, 0.0f, -1.0f),
|
||||||
|
vec3(0.0f, 0.0f, -1.0f),
|
||||||
|
vec3(0.0f, 0.0f, -1.0f),
|
||||||
|
vec3(0.0f, 0.0f, -1.0f),
|
||||||
|
vec3(0.0f, 0.0f, -1.0f),
|
||||||
|
vec3(0.0f, 0.0f, -1.0f),
|
||||||
|
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
|
||||||
|
vec3(-1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(-1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(-1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(-1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(-1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(-1.0f, 0.0f, 0.0f),
|
||||||
|
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
|
||||||
|
vec3(0.0f, -1.0f, 0.0f),
|
||||||
|
vec3(0.0f, -1.0f, 0.0f),
|
||||||
|
vec3(0.0f, -1.0f, 0.0f),
|
||||||
|
vec3(0.0f, -1.0f, 0.0f),
|
||||||
|
vec3(0.0f, -1.0f, 0.0f),
|
||||||
|
vec3(0.0f, -1.0f, 0.0f),
|
||||||
|
|
||||||
|
vec3(0.0f, 1.0f, 0.0f),
|
||||||
|
vec3(0.0f, 1.0f, 0.0f),
|
||||||
|
vec3(0.0f, 1.0f, 0.0f),
|
||||||
|
vec3(0.0f, 1.0f, 0.0f),
|
||||||
|
vec3(0.0f, 1.0f, 0.0f),
|
||||||
|
vec3(0.0f, 1.0f, 0.0f)
|
||||||
|
};
|
||||||
|
darray<vec3> colors {
|
||||||
|
vec3(1.0f, 0.0f, 0.0f),
|
||||||
|
vec3(0.0f, 1.0f, 0.0f),
|
||||||
|
vec3(0.0f, 0.0f, 1.0f),
|
||||||
|
vec3(1.0f, 1.0f, 1.0f)
|
||||||
|
};
|
||||||
|
darray<Vector<unsigned int, 3>> indices {
|
||||||
|
Vector<unsigned int, 3>(0, 1, 2),
|
||||||
|
Vector<unsigned int, 3>(2, 3, 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
Entity entity;
|
||||||
|
entity.addVertices(vertices);
|
||||||
|
entity.addNormals(normals);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct WindowDockUI
|
||||||
|
{
|
||||||
|
//virtual
|
||||||
|
//void render() = 0;
|
||||||
|
virtual
|
||||||
|
void ui() = 0;
|
||||||
|
};
|
||||||
|
struct Viewport3D //: WindowDockUI
|
||||||
|
{
|
||||||
|
gpu::ShaderProgram shaderProgram;
|
||||||
|
gpu::ColorBuffer colorBuffer;
|
||||||
|
gpu::DepthBuffer depthBuffer;
|
||||||
|
gpu::Framebuffer framebuffer;
|
||||||
|
OrbitCamera camera;
|
||||||
|
vec4 backgroundColor;
|
||||||
|
|
||||||
|
Viewport3D() :
|
||||||
|
shaderProgram {},
|
||||||
|
colorBuffer {},
|
||||||
|
depthBuffer {},
|
||||||
|
framebuffer {},
|
||||||
|
camera {},
|
||||||
|
backgroundColor {0.2f, 0.2f, 0.2f, 1.0f}
|
||||||
|
{
|
||||||
|
gpu::Shader vertexShader {gpu::Shader::Type::Vertex, vertexSource};
|
||||||
|
vertexShader.create();
|
||||||
|
|
||||||
|
gpu::Shader fragmentShader {gpu::Shader::Type::Fragment, fragmentSource};
|
||||||
|
fragmentShader.create();
|
||||||
|
|
||||||
|
shaderProgram.create();
|
||||||
|
shaderProgram.attach(vertexShader);
|
||||||
|
shaderProgram.attach(fragmentShader);
|
||||||
|
shaderProgram.link();
|
||||||
|
|
||||||
|
|
||||||
|
vertexShader.destroy();
|
||||||
|
fragmentShader.destroy();
|
||||||
|
|
||||||
|
framebuffer.create();
|
||||||
|
}
|
||||||
|
~Viewport3D()
|
||||||
|
{
|
||||||
|
|
||||||
|
//delete camera;
|
||||||
|
}
|
||||||
|
void destroy()
|
||||||
|
{
|
||||||
|
shaderProgram.destroy();
|
||||||
|
framebuffer.destroy();
|
||||||
|
}
|
||||||
|
float width() const
|
||||||
|
{
|
||||||
|
return static_cast<float>(framebuffer.width());
|
||||||
|
}
|
||||||
|
void width(float w)
|
||||||
|
{
|
||||||
|
framebuffer.width() = static_cast<int>(w);
|
||||||
|
}
|
||||||
|
float height() const
|
||||||
|
{
|
||||||
|
return static_cast<float>(framebuffer.height());
|
||||||
|
}
|
||||||
|
void height(float h)
|
||||||
|
{
|
||||||
|
framebuffer.height() = static_cast<int>(h);
|
||||||
|
}
|
||||||
|
void render(Entity* entity)
|
||||||
|
{
|
||||||
|
framebuffer.bind();
|
||||||
|
framebuffer.rescale();
|
||||||
|
|
||||||
|
colorBuffer.clear(backgroundColor);
|
||||||
|
depthBuffer.clear();
|
||||||
|
|
||||||
|
camera.aspect() = width() / height();
|
||||||
|
|
||||||
|
if (entity)
|
||||||
|
entity->render(&shaderProgram);
|
||||||
|
|
||||||
|
shaderProgram.bind();
|
||||||
|
|
||||||
|
// camera
|
||||||
|
shaderProgram.uniformMatrix<4, 4>("view", 1, true, camera.view().data());
|
||||||
|
shaderProgram.uniformMatrix<4, 4>("projection", 1, true, camera.projection().data());
|
||||||
|
shaderProgram.uniformVector<float, 3>("viewPos", 1, camera.position().data());
|
||||||
|
|
||||||
|
// light
|
||||||
|
hpr::vec3 lightColor {1.0f, 1.0f, 1.0f};
|
||||||
|
shaderProgram.uniformVector<float, 3>("lightColor", 1, lightColor.data());
|
||||||
|
hpr::vec3 lightPos {1.0f, 1.0f, 1.0f};
|
||||||
|
shaderProgram.uniformVector<float, 3>("lightPos", 1, lightPos.data());
|
||||||
|
|
||||||
|
shaderProgram.unbind();
|
||||||
|
|
||||||
|
framebuffer.unbind();
|
||||||
|
}
|
||||||
|
void ui() //override
|
||||||
|
{
|
||||||
|
if (!ImGui::IsWindowCollapsed())
|
||||||
|
{
|
||||||
|
width(ImGui::GetContentRegionAvail().x);
|
||||||
|
height(ImGui::GetContentRegionAvail().y);
|
||||||
|
|
||||||
|
ImGui::Image(reinterpret_cast<void *>(framebuffer.texture().index()),
|
||||||
|
ImGui::GetContentRegionAvail(),ImVec2{0, 1}, ImVec2{1, 0});
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
if (ImGui::IsWindowHovered())
|
||||||
|
{
|
||||||
|
if (io.WantCaptureMouse)
|
||||||
|
{
|
||||||
|
camera.scrollEvent(0, io.MouseWheel);
|
||||||
|
|
||||||
|
if (ImGui::IsMouseDown(ImGuiMouseButton_Middle))
|
||||||
|
{
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_LeftShift))
|
||||||
|
{
|
||||||
|
camera.moveEvent(io.MouseDelta.x, io.MouseDelta.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
camera.rotateEvent(io.MouseDelta.x, io.MouseDelta.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*struct Viewport3DUI : public WindowDockUI
|
||||||
|
{
|
||||||
|
Viewport3D* viewport3D;
|
||||||
|
explicit
|
||||||
|
Viewport3DUI(Viewport3D* viewport3D) :
|
||||||
|
viewport3D {viewport3D}
|
||||||
|
{}
|
||||||
|
void render() override
|
||||||
|
{
|
||||||
|
if (!ImGui::IsWindowCollapsed())
|
||||||
|
{
|
||||||
|
viewport3D->width(ImGui::GetContentRegionAvail().x);
|
||||||
|
viewport3D->height(ImGui::GetContentRegionAvail().y);
|
||||||
|
|
||||||
|
ImGui::Image(reinterpret_cast<void *>(viewport3D->framebuffer.texture().index()),
|
||||||
|
ImGui::GetContentRegionAvail(),ImVec2{0, 1}, ImVec2{1, 0});
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
if (ImGui::IsWindowHovered())
|
||||||
|
{
|
||||||
|
if (io.WantCaptureMouse)
|
||||||
|
{
|
||||||
|
OrbitCamera* orbitCamera = dynamic_cast<OrbitCamera*>(viewport3D->camera);
|
||||||
|
orbitCamera->scrollEvent(0, io.MouseWheel);
|
||||||
|
|
||||||
|
if (ImGui::IsMouseDown(ImGuiMouseButton_Middle))
|
||||||
|
{
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_LeftShift))
|
||||||
|
{
|
||||||
|
orbitCamera->moveEvent(io.MouseDelta.x, io.MouseDelta.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
orbitCamera->rotateEvent(io.MouseDelta.x, io.MouseDelta.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};*/
|
||||||
|
|
||||||
|
struct Outliner //: WindowDockUI
|
||||||
|
{
|
||||||
|
darray<Entity*> entities;
|
||||||
|
|
||||||
|
Outliner() :
|
||||||
|
entities {}
|
||||||
|
{}
|
||||||
|
|
||||||
|
~Outliner()
|
||||||
|
{
|
||||||
|
for (auto entity : entities)
|
||||||
|
delete entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui()
|
||||||
|
{
|
||||||
|
static ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick |
|
||||||
|
ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_FramePadding;
|
||||||
|
|
||||||
|
static int selection_mask = (1 << 2);
|
||||||
|
int node_clicked = -1;
|
||||||
|
|
||||||
|
for (int n = 0; n < entities.size(); ++n)
|
||||||
|
{
|
||||||
|
ImGuiTreeNodeFlags node_flags = base_flags;
|
||||||
|
const bool is_selected = (selection_mask & (1 << n)) != 0;
|
||||||
|
if (is_selected)
|
||||||
|
node_flags |= ImGuiTreeNodeFlags_Selected;
|
||||||
|
|
||||||
|
auto label = entities[n]->label() == "" ? std::string("Entity") : entities[n]->label();
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(5.f, 5.f));
|
||||||
|
bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)n, node_flags, "%s %s", ICON_FA_CUBE, label.data());
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
if (ImGui::IsItemClicked() && !ImGui::IsItemToggledOpen())
|
||||||
|
node_clicked = n;
|
||||||
|
|
||||||
|
if (ImGui::BeginDragDropSource())
|
||||||
|
{
|
||||||
|
ImGui::SetDragDropPayload("_TREENODE", nullptr, 0);
|
||||||
|
ImGui::Text("This is a drag and drop source");
|
||||||
|
ImGui::EndDragDropSource();
|
||||||
|
}
|
||||||
|
if (node_open)
|
||||||
|
{
|
||||||
|
ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
|
||||||
|
ImGui::Text(label.data());
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (node_clicked != -1)
|
||||||
|
{
|
||||||
|
if (ImGui::GetIO().KeyShift)
|
||||||
|
selection_mask ^= (1 << node_clicked);
|
||||||
|
else
|
||||||
|
selection_mask = (1 << node_clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//static bool selection[entities.size()] ;//= { false, false, false, false, false };
|
||||||
|
/*for (int n = 0; n < entities.size(); ++n)
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
|
sprintf(buf, "Object %d", n);
|
||||||
|
if (ImGui::Selectable(buf, entities[n]->selected))
|
||||||
|
{
|
||||||
|
if (!ImGui::GetIO().KeyShift)
|
||||||
|
for (auto& entity : entities)
|
||||||
|
entity->selected = false;
|
||||||
|
entities[n]->selected ^= 1;
|
||||||
|
}
|
||||||
|
auto label = entities[n]->label() == "" ? std::string("Entity") : entities[n]->label();
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(5.f, 5.f));
|
||||||
|
if (ImGui::TreeNodeEx((std::string(ICON_FA_CUBE " ") + label + "##" + std::to_string(n)).c_str(), ImGuiTreeNodeFlags_FramePadding | ImGuiTreeNodeFlags_SpanFullWidth))
|
||||||
|
{
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
//ImGui::SameLine();
|
||||||
|
//ImGui::Button("asd");
|
||||||
|
}*/
|
||||||
|
/*static int selected_object = -1;
|
||||||
|
if (ImGui::BeginTable("##table", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_BordersOuterV)) // | ImGuiTableFlags_Resizable
|
||||||
|
{
|
||||||
|
ImGui::TableSetupColumn("Object", ImGuiTableColumnFlags_NoHide);
|
||||||
|
//ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 20.0f);
|
||||||
|
//ImGui::TableHeadersRow();
|
||||||
|
|
||||||
|
for (int n = 0; n < entities.size(); n++) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
//ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
auto label = entities[n]->label() == "" ? std::string("Entity") : entities[n]->label();
|
||||||
|
|
||||||
|
bool tnex_open = ImGui::TreeNodeEx((label + "##" + std::to_string(n)).c_str(),
|
||||||
|
ImGuiTreeNodeFlags_SpanFullWidth);
|
||||||
|
|
||||||
|
if (ImGui::IsItemClicked()) {
|
||||||
|
selected_object = n;
|
||||||
|
}
|
||||||
|
if (ImGui::BeginPopupContextItem()) {
|
||||||
|
selected_object = n;
|
||||||
|
|
||||||
|
if (ImGui::Selectable("Remove")) {
|
||||||
|
//scene.remove_object(n);
|
||||||
|
selected_object = -1;
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
//ImGui::TableNextColumn();
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled("#%d", n);
|
||||||
|
|
||||||
|
if (tnex_open) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
//ImGui::TableNextColumn();
|
||||||
|
ImGui::TreeNodeEx("asdasd",//std::to_string(scene.object(n).get_id()).c_str(),
|
||||||
|
ImGuiTreeNodeFlags_Leaf | //ImGuiTreeNodeFlags_Bullet |
|
||||||
|
ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||||
|
//ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
};
|
||||||
|
struct WindowDock
|
||||||
|
{
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
Viewport3d,
|
||||||
|
Outliner,
|
||||||
|
Properties
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Component
|
||||||
|
{
|
||||||
|
unsigned int id;
|
||||||
|
unsigned int nodeId;
|
||||||
|
Type type;
|
||||||
|
Viewport3D viewport3D;
|
||||||
|
Outliner *outliner;
|
||||||
|
};
|
||||||
|
|
||||||
|
darray<Component*> components;
|
||||||
|
|
||||||
|
WindowDock() :
|
||||||
|
components {}
|
||||||
|
{}
|
||||||
|
|
||||||
|
~WindowDock() = default;
|
||||||
|
|
||||||
|
void destroy()
|
||||||
|
{
|
||||||
|
for (auto& component : components)
|
||||||
|
{
|
||||||
|
component->viewport3D.destroy();
|
||||||
|
delete component;
|
||||||
|
component = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int lastID()
|
||||||
|
{
|
||||||
|
unsigned int last = 0;
|
||||||
|
for (auto c : components)
|
||||||
|
if (c->id > last)
|
||||||
|
last = c->id;
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
std::string icon;
|
||||||
|
|
||||||
|
bool splitHorizontal;
|
||||||
|
bool splitVertical;
|
||||||
|
bool close;
|
||||||
|
|
||||||
|
for (auto& component : components)
|
||||||
|
{
|
||||||
|
switch (component->type)
|
||||||
|
{
|
||||||
|
case Type::Viewport3d: icon = ICON_FA_CHART_AREA ICON_FA_ANGLE_DOWN; break;
|
||||||
|
case Type::Outliner: icon = ICON_FA_LIST ICON_FA_ANGLE_DOWN; break;
|
||||||
|
case Type::Properties: icon = ICON_FA_PAPERCLIP ICON_FA_ANGLE_DOWN; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
|
|
||||||
|
if (ImGui::Begin((std::string("Component#") + std::to_string(component->id)).data(), nullptr, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoTitleBar))
|
||||||
|
{
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
bool hovered = ImGui::IsWindowHovered();
|
||||||
|
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
//if (hovered)
|
||||||
|
// ImGui::PopStyleColor();
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu(icon.data()))
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled("General");
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::MenuItem(ICON_FA_CHART_AREA " 3D Viewport"))
|
||||||
|
component->type = Type::Viewport3d;
|
||||||
|
|
||||||
|
ImGui::TextDisabled("Data");
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::MenuItem(ICON_FA_LIST " Outliner"))
|
||||||
|
component->type = Type::Outliner;
|
||||||
|
if (ImGui::MenuItem(ICON_FA_PAPERCLIP " Properties"))
|
||||||
|
component->type = Type::Properties;
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
float rightAlignedWidth = ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(ICON_FA_GEAR).x + style.FramePadding.x * 2.f + style.ItemSpacing.x);
|
||||||
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + rightAlignedWidth);
|
||||||
|
if (ImGui::BeginMenu(ICON_FA_GEAR))
|
||||||
|
{
|
||||||
|
splitHorizontal = ImGui::MenuItem("Split horizontal");
|
||||||
|
splitVertical = ImGui::MenuItem("Split vertical");
|
||||||
|
close = ImGui::MenuItem("Close");
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (component->type)
|
||||||
|
{
|
||||||
|
case Type::Viewport3d:
|
||||||
|
//if (viewport3D != nullptr)
|
||||||
|
component->viewport3D.ui();
|
||||||
|
break;
|
||||||
|
case Type::Outliner: component->outliner->ui(); break;
|
||||||
|
case Type::Properties: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto split = [](ImGuiID& parentNode, ImGuiDir direction, unsigned int currentID, unsigned int lastID)
|
||||||
|
{
|
||||||
|
//ImGui::DockBuilderSetNodePos(parent_node, ImGui::GetWindowPos());
|
||||||
|
//ImGui::DockBuilderSetNodeSize(parent_node, ImGui::GetWindowSize());
|
||||||
|
ImGuiID nodeA;
|
||||||
|
ImGuiID nodeB;
|
||||||
|
ImGui::DockBuilderSplitNode(parentNode, direction, 0.5f, &nodeB, &nodeA);
|
||||||
|
|
||||||
|
ImGui::DockBuilderDockWindow((std::string("Component#") + std::to_string(currentID)).data(), nodeA);
|
||||||
|
ImGui::DockBuilderDockWindow((std::string("Component#") + std::to_string(lastID + 1)).data(), nodeB);
|
||||||
|
|
||||||
|
ImGuiDockNode* node = ImGui::DockBuilderGetNode(nodeB);
|
||||||
|
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoTabBar;
|
||||||
|
|
||||||
|
ImGui::DockBuilderFinish(parentNode);
|
||||||
|
parentNode = nodeA;
|
||||||
|
|
||||||
|
return nodeB;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (splitHorizontal)
|
||||||
|
{
|
||||||
|
auto newNode = split(component->nodeId, ImGuiDir_Right, component->id, lastID());
|
||||||
|
components.push(new Component{lastID() + 1, newNode, component->type, {}, component->outliner});
|
||||||
|
splitHorizontal = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (splitVertical)
|
||||||
|
{
|
||||||
|
auto newNode = split(component->nodeId, ImGuiDir_Down, component->id, lastID());
|
||||||
|
components.push(new Component{lastID() + 1, newNode, component->type, {}, component->outliner});
|
||||||
|
splitVertical = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close)
|
||||||
|
{
|
||||||
|
component = nullptr;
|
||||||
|
close = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
components.remove([](Component* component)
|
||||||
|
{
|
||||||
|
return component == nullptr;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*struct OutlinerUI : public WindowDockUI
|
||||||
|
{
|
||||||
|
Outliner* outliner;
|
||||||
|
explicit
|
||||||
|
OutlinerUI(Outliner* outliner) :
|
||||||
|
outliner {outliner}
|
||||||
|
{}
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};*/
|
||||||
|
struct Properties
|
||||||
|
{
|
||||||
|
Properties()
|
||||||
|
{}
|
||||||
|
|
||||||
|
~Properties()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void ui()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Application
|
||||||
|
{
|
||||||
|
|
||||||
|
gpu::Window window;
|
||||||
|
gpu::Viewport viewport;
|
||||||
|
gpu::ColorBuffer colorBuffer;
|
||||||
|
gpu::DepthBuffer depthBuffer;
|
||||||
|
//Viewport3D viewport3D;
|
||||||
|
Outliner outliner;
|
||||||
|
Properties properties;
|
||||||
|
vec4 backgroundColor;
|
||||||
|
UI ui;
|
||||||
|
|
||||||
|
Application() :
|
||||||
|
window {100, 100, 1200, 900, "Hyporo", gpu::Window::Windowed, nullptr, nullptr},
|
||||||
|
viewport {},
|
||||||
|
colorBuffer {},
|
||||||
|
depthBuffer {},
|
||||||
|
//viewport3D {},
|
||||||
|
outliner {},
|
||||||
|
properties {},
|
||||||
|
backgroundColor {0.2f, 0.2f, 0.2f, 1.0f},
|
||||||
|
ui {&window}
|
||||||
|
{
|
||||||
|
window.framebufferResizeCallback([](gpu::Window* w, int width, int height)
|
||||||
|
{
|
||||||
|
w->size(width, height);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
~Application()
|
||||||
|
{
|
||||||
|
window.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
window.context().debug();
|
||||||
|
window.icon("icon.png");
|
||||||
|
|
||||||
|
depthBuffer.bind();
|
||||||
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
|
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||||
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
|
/*darray<WindowDock> windowDocks {
|
||||||
|
{1, WindowDock::Type::Viewport3d, &outliner},
|
||||||
|
{2, WindowDock::Type::Outliner, &outliner},
|
||||||
|
{3, WindowDock::Type::Properties, &outliner}
|
||||||
|
};*/
|
||||||
|
WindowDock windowDock;
|
||||||
|
windowDock.components.push(new WindowDock::Component{1, 1, WindowDock::Type::Viewport3d, {}, &outliner});
|
||||||
|
windowDock.components.push(new WindowDock::Component{2, 3, WindowDock::Type::Outliner, {}, &outliner});
|
||||||
|
windowDock.components.push(new WindowDock::Component{3, 4, WindowDock::Type::Properties, {}, &outliner});
|
||||||
|
|
||||||
|
auto sp = Viewport3D().shaderProgram;
|
||||||
|
//auto ent = testEntity(&sp);
|
||||||
|
outliner.entities.push(new Entity(testEntity(&sp)));
|
||||||
|
|
||||||
|
|
||||||
|
while (window.state() != gpu::Window::Closed)
|
||||||
|
{
|
||||||
|
if (window.shouldClose())
|
||||||
|
window.state(gpu::Window::Closed);
|
||||||
|
|
||||||
|
// Clean up buffers
|
||||||
|
colorBuffer.clear(backgroundColor);
|
||||||
|
depthBuffer.clear();
|
||||||
|
|
||||||
|
for (auto& component : windowDock.components)
|
||||||
|
{
|
||||||
|
// Viewport3D
|
||||||
|
if (component->type != WindowDock::Type::Viewport3d)
|
||||||
|
continue;
|
||||||
|
viewport.size() = vec2(component->viewport3D.width(), component->viewport3D.height());
|
||||||
|
viewport.set();
|
||||||
|
component->viewport3D.render(nullptr);
|
||||||
|
for (auto entity: outliner.entities)
|
||||||
|
component->viewport3D.render(entity);
|
||||||
|
}
|
||||||
|
// Main window
|
||||||
|
viewport.size() = vec2(window.width(), window.height());
|
||||||
|
viewport.set();
|
||||||
|
|
||||||
|
// UI
|
||||||
|
ui.createFrame();
|
||||||
|
|
||||||
|
ui.mainMenu();
|
||||||
|
ui.mainDockspace();
|
||||||
|
windowDock.render();
|
||||||
|
/*for (auto& windowDock : windowDocks)
|
||||||
|
{
|
||||||
|
switch (windowDock.type)
|
||||||
|
{
|
||||||
|
case (WindowDock::Type::Viewport3d):
|
||||||
|
{
|
||||||
|
windowDock.render();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (WindowDock::Type::Outliner):
|
||||||
|
{
|
||||||
|
//auto outlinerUI = OutlinerUI(&outliner);
|
||||||
|
windowDock.render();//&outliner);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (WindowDock::Type::Properties): break;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
/*windowDocks.remove([](WindowDock wd){
|
||||||
|
return wd.close;
|
||||||
|
});*/
|
||||||
|
/*unsigned int lastID = 0;
|
||||||
|
for (auto wd : windowDocks)
|
||||||
|
if (wd.id > lastID)
|
||||||
|
lastID = wd.id;
|
||||||
|
for (auto n = 0; n < windowDocks.size(); ++n)
|
||||||
|
{
|
||||||
|
if (windowDocks[n].splitHorizontal)
|
||||||
|
{
|
||||||
|
if (ImGui::Begin("#Dockspace"))
|
||||||
|
{
|
||||||
|
auto nodeID = ImGui::GetID((std::string("WindowDock#") + std::to_string(windowDocks[n].id)).data());
|
||||||
|
//auto* node = ImGui::DockBuilderGetNode(nodeID);
|
||||||
|
if (ImGui::DockBuilderGetNode(nodeID) == nullptr)
|
||||||
|
{
|
||||||
|
//ImGui::DockBuilderRemoveNode(nodeID);
|
||||||
|
ImGui::DockBuilderAddNode(nodeID, ImGuiDockNodeFlags_DockSpace);
|
||||||
|
ImGui::DockBuilderSetNodeSize(nodeID, ImVec2(350.f, 350.f));
|
||||||
|
ImGuiID newDock = ImGui::DockBuilderSplitNode(nodeID, ImGuiDir_Right, 0.2f, nullptr,
|
||||||
|
&nodeID);
|
||||||
|
//ImGui::DockBuilderDockWindow((std::string("WindowDock#") + std::to_string(nodeID)).data(),
|
||||||
|
// nodeID);
|
||||||
|
ImGui::DockBuilderDockWindow(
|
||||||
|
(std::string("WindowDock#") + std::to_string(lastID + 1)).data(), newDock);
|
||||||
|
windowDocks.push({lastID + 1, windowDocks[n].type, &outliner});
|
||||||
|
}
|
||||||
|
windowDocks[n].splitHorizontal = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
ui.statusBar();
|
||||||
|
|
||||||
|
ui.renderFrame();
|
||||||
|
//
|
||||||
|
window.swapBuffers();
|
||||||
|
window.pollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
windowDock.destroy();
|
||||||
|
}
|
||||||
|
};
|
1
source/creator/camera.hpp
Executable file → Normal file
1
source/creator/camera.hpp
Executable file → Normal file
@ -83,6 +83,7 @@ public:
|
|||||||
{
|
{
|
||||||
return p_position;
|
return p_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OrbitCamera : public Camera
|
class OrbitCamera : public Camera
|
||||||
|
0
source/creator/cmake/mingw-pre-pack.cmake.in
Executable file → Normal file
0
source/creator/cmake/mingw-pre-pack.cmake.in
Executable file → Normal file
0
source/creator/creator.cpp
Executable file → Normal file
0
source/creator/creator.cpp
Executable file → Normal file
36
source/creator/drawable.hpp
Executable file → Normal file
36
source/creator/drawable.hpp
Executable file → Normal file
@ -3,7 +3,7 @@
|
|||||||
#include <hpr/gpu.hpp>
|
#include <hpr/gpu.hpp>
|
||||||
#include <hpr/math.hpp>
|
#include <hpr/math.hpp>
|
||||||
|
|
||||||
using hpr::darray;
|
using namespace hpr;
|
||||||
|
|
||||||
class Drawable
|
class Drawable
|
||||||
{
|
{
|
||||||
@ -17,8 +17,6 @@ protected:
|
|||||||
gpu::BufferObject p_colorBuffer;
|
gpu::BufferObject p_colorBuffer;
|
||||||
gpu::BufferObject p_indexBuffer;
|
gpu::BufferObject p_indexBuffer;
|
||||||
|
|
||||||
gpu::ShaderProgram* p_shaderProgram;
|
|
||||||
|
|
||||||
gpu::ArrayObject::Mode p_renderMode;
|
gpu::ArrayObject::Mode p_renderMode;
|
||||||
|
|
||||||
hpr::vec4 p_color;
|
hpr::vec4 p_color;
|
||||||
@ -41,19 +39,6 @@ public:
|
|||||||
p_normalBuffer {gpu::BufferObject::Vertex},
|
p_normalBuffer {gpu::BufferObject::Vertex},
|
||||||
p_colorBuffer {gpu::BufferObject::Vertex},
|
p_colorBuffer {gpu::BufferObject::Vertex},
|
||||||
p_indexBuffer {gpu::BufferObject::Index},
|
p_indexBuffer {gpu::BufferObject::Index},
|
||||||
p_shaderProgram {nullptr},
|
|
||||||
p_renderMode {gpu::ArrayObject::Triangles},
|
|
||||||
p_color {0.7, 0.7, 0.7}
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline explicit
|
|
||||||
Drawable(gpu::ShaderProgram* shaderProgram) :
|
|
||||||
p_arrayObject {},
|
|
||||||
p_vertexBuffer {gpu::BufferObject::Vertex},
|
|
||||||
p_normalBuffer {gpu::BufferObject::Vertex},
|
|
||||||
p_colorBuffer {gpu::BufferObject::Vertex},
|
|
||||||
p_indexBuffer {gpu::BufferObject::Index},
|
|
||||||
p_shaderProgram {shaderProgram},
|
|
||||||
p_renderMode {gpu::ArrayObject::Triangles},
|
p_renderMode {gpu::ArrayObject::Triangles},
|
||||||
p_color {0.7, 0.7, 0.7}
|
p_color {0.7, 0.7, 0.7}
|
||||||
{}
|
{}
|
||||||
@ -73,13 +58,6 @@ public:
|
|||||||
p_indexBuffer.destroy();
|
p_indexBuffer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr
|
|
||||||
gpu::ShaderProgram* shaderProgram() const
|
|
||||||
{
|
|
||||||
return p_shaderProgram;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr virtual
|
constexpr virtual
|
||||||
void renderMode(gpu::ArrayObject::Mode mode)
|
void renderMode(gpu::ArrayObject::Mode mode)
|
||||||
{
|
{
|
||||||
@ -195,15 +173,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline virtual
|
inline virtual
|
||||||
void render(gpu::ArrayObject::Mode mode)
|
void render(gpu::ShaderProgram* shaderProgram, gpu::ArrayObject::Mode mode)
|
||||||
{
|
{
|
||||||
p_shaderProgram->bind();
|
shaderProgram->bind();
|
||||||
//std::cout << p_shaderProgram->index() << std::endl;
|
//std::cout << p_shaderProgram->index() << std::endl;
|
||||||
p_arrayObject.bind();
|
p_arrayObject.bind();
|
||||||
|
|
||||||
if (!p_colorBuffer.valid()) {
|
if (!p_colorBuffer.valid()) {
|
||||||
|
|
||||||
shaderProgram()->uniformVector<float, 4>("objectColor", 1, p_color.data());
|
shaderProgram->uniformVector<float, 4>("objectColor", 1, p_color.data());
|
||||||
}
|
}
|
||||||
if (p_indexBuffer.valid())
|
if (p_indexBuffer.valid())
|
||||||
{
|
{
|
||||||
@ -215,13 +193,13 @@ public:
|
|||||||
p_arrayObject.drawArrays(mode, p_vertexBuffer.size());
|
p_arrayObject.drawArrays(mode, p_vertexBuffer.size());
|
||||||
}
|
}
|
||||||
p_arrayObject.unbind();
|
p_arrayObject.unbind();
|
||||||
p_shaderProgram->unbind();
|
shaderProgram->unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline virtual
|
inline virtual
|
||||||
void render()
|
void render(gpu::ShaderProgram* shaderProgram)
|
||||||
{
|
{
|
||||||
render(p_renderMode);
|
render(shaderProgram, p_renderMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline virtual
|
inline virtual
|
||||||
|
30
source/creator/entity.hpp
Executable file → Normal file
30
source/creator/entity.hpp
Executable file → Normal file
@ -14,18 +14,16 @@ protected:
|
|||||||
hpr::vec3 p_position;
|
hpr::vec3 p_position;
|
||||||
hpr::quat p_rotation;
|
hpr::quat p_rotation;
|
||||||
hpr::vec3 p_scale;
|
hpr::vec3 p_scale;
|
||||||
|
std::string p_label;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
bool selected;
|
||||||
|
|
||||||
Entity() :
|
Entity() :
|
||||||
Drawable {}
|
Drawable {}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline explicit
|
|
||||||
Entity(gpu::ShaderProgram* shaderProgram) :
|
|
||||||
Drawable {shaderProgram}
|
|
||||||
{}
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
Entity(const Entity& entity) = default;
|
Entity(const Entity& entity) = default;
|
||||||
/*{
|
/*{
|
||||||
@ -52,6 +50,18 @@ public:
|
|||||||
p_rotation *= hpr::quat(axis, angle);
|
p_rotation *= hpr::quat(axis, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline virtual
|
||||||
|
std::string label() const
|
||||||
|
{
|
||||||
|
return p_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline virtual
|
||||||
|
void label(const std::string& label)
|
||||||
|
{
|
||||||
|
p_label = label;
|
||||||
|
}
|
||||||
|
|
||||||
hpr::mat4 model()
|
hpr::mat4 model()
|
||||||
{
|
{
|
||||||
hpr::mat4 model = hpr::mat4::identity();
|
hpr::mat4 model = hpr::mat4::identity();
|
||||||
@ -62,19 +72,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void render() override
|
void render(gpu::ShaderProgram* shaderProgram) override
|
||||||
{
|
{
|
||||||
shaderProgram()->bind();
|
shaderProgram->bind();
|
||||||
//std::cout << shaderProgram()->index() << std::endl;
|
//std::cout << shaderProgram()->index() << std::endl;
|
||||||
|
|
||||||
//for (auto v : model)
|
//for (auto v : model)
|
||||||
// std::cout << v << " ";
|
// std::cout << v << " ";
|
||||||
//std::cout << std::endl;
|
//std::cout << std::endl;
|
||||||
shaderProgram()->uniformMatrix<4, 4>("model", 1, true, model().data());
|
shaderProgram->uniformMatrix<4, 4>("model", 1, true, model().data());
|
||||||
|
|
||||||
Drawable::render();
|
Drawable::render(shaderProgram);
|
||||||
|
|
||||||
shaderProgram()->unbind();
|
shaderProgram->unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
0
source/creator/grid.hpp
Executable file → Normal file
0
source/creator/grid.hpp
Executable file → Normal file
6
source/creator/ray.hpp
Executable file → Normal file
6
source/creator/ray.hpp
Executable file → Normal file
@ -37,17 +37,17 @@ public:
|
|||||||
|
|
||||||
void fromScreen(int x, int y, int width, int height, Camera* camera, Entity* entity)
|
void fromScreen(int x, int y, int width, int height, Camera* camera, Entity* entity)
|
||||||
{
|
{
|
||||||
/*vec4 start {2.f * (float)x / (float)width - 1.f, 2.f * (float)y / (float)height - 1.f, 0.f, 1.f};
|
vec4 start {2.f * (float)x / (float)width - 1.f, 2.f * (float)y / (float)height - 1.f, 0.f, 1.f};
|
||||||
vec4 end {2.f * (float)x / (float)width - 1.f, 2.f * (float)y / (float)height - 1.f, 1.f, 1.f};
|
vec4 end {2.f * (float)x / (float)width - 1.f, 2.f * (float)y / (float)height - 1.f, 1.f, 1.f};
|
||||||
|
|
||||||
mat4 invPV = inv(transpose(camera->projection()) * transpose(camera->view()));
|
mat4 invPV = inv(transpose(camera->projection()) * transpose(camera->view()));
|
||||||
vec4 startWorld = invPV * start;
|
vec4 startWorld = invPV * start;
|
||||||
startWorld /= startWorld[3];
|
startWorld /= startWorld[3];
|
||||||
vec4 endWorld = invPV * end;
|
vec4 endWorld = invPV * end;
|
||||||
endWorld /= endWorld[3];*/
|
endWorld /= endWorld[3];
|
||||||
|
|
||||||
|
|
||||||
vec3 end = unproject(vec3(x, y, 0), entity->model(), camera->projection(), vec4(0, 0, width, height));
|
//vec3 end = unproject(vec3(x, y, 0), entity->model(), camera->projection(), vec4(0, 0, width, height));
|
||||||
|
|
||||||
p_position = vec3(startWorld);
|
p_position = vec3(startWorld);
|
||||||
p_direction = normalize(vec3(endWorld - startWorld));
|
p_direction = normalize(vec3(endWorld - startWorld));
|
||||||
|
0
source/creator/scene.hpp
Executable file → Normal file
0
source/creator/scene.hpp
Executable file → Normal file
0
source/creator/shaders.hpp
Executable file → Normal file
0
source/creator/shaders.hpp
Executable file → Normal file
0
source/creator/test.cpp
Executable file → Normal file
0
source/creator/test.cpp
Executable file → Normal file
0
source/creator/test2-back.cpp
Executable file → Normal file
0
source/creator/test2-back.cpp
Executable file → Normal file
193
source/creator/test2.cpp
Executable file → Normal file
193
source/creator/test2.cpp
Executable file → Normal file
@ -8,9 +8,84 @@
|
|||||||
#include "camera.hpp"
|
#include "camera.hpp"
|
||||||
#include "scene.hpp"
|
#include "scene.hpp"
|
||||||
#include "grid.hpp"
|
#include "grid.hpp"
|
||||||
#include <implot.h>
|
|
||||||
#include "ray.hpp"
|
#include "ray.hpp"
|
||||||
|
#include <hpr/csg.hpp>
|
||||||
|
#include <hpr/mesh.hpp>
|
||||||
|
|
||||||
|
#include "../applications/periodic/cell.hpp"
|
||||||
|
|
||||||
|
using namespace hpr::csg;
|
||||||
|
|
||||||
|
struct UITarget
|
||||||
|
{
|
||||||
|
unsigned int id;
|
||||||
|
std::function<void(unsigned int)> frender;
|
||||||
|
bool* show;
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
if (*show)
|
||||||
|
frender(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mesh::Mesh build_mesh(const csg::Shape& shape_)
|
||||||
|
{
|
||||||
|
mesh::Mesh mesh;
|
||||||
|
csg::Shape shape {shape_};
|
||||||
|
shape.incrementalMesh(1e-3);
|
||||||
|
|
||||||
|
for (TopExp_Explorer exp(shape.tshape(), TopAbs_EDGE); exp.More(); exp.Next())
|
||||||
|
{
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(exp.Current());
|
||||||
|
|
||||||
|
if (BRep_Tool::Degenerated(edge))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Handle(Poly_PolygonOnTriangulation) edgePoly;
|
||||||
|
Handle(Poly_Triangulation) triangulation;
|
||||||
|
TopLoc_Location edgeLoc;
|
||||||
|
BRep_Tool::PolygonOnTriangulation(edge, edgePoly, triangulation, edgeLoc);
|
||||||
|
|
||||||
|
int nbnodes = edgePoly->NbNodes();
|
||||||
|
gp_Pnt point1 = triangulation->Node(edgePoly->Nodes()(1)).Transformed(edgeLoc);
|
||||||
|
gp_Pnt point2 = triangulation->Node(edgePoly->Nodes()(nbnodes)).Transformed(edgeLoc);
|
||||||
|
|
||||||
|
mesh.addVertex(point1.X(), point1.Y(), point1.Z());
|
||||||
|
mesh.addVertex(point2.X(), point2.Y(), point2.Z());
|
||||||
|
mesh.addEdge(mesh.vertex(mesh.vertices().size() - 2), mesh.vertex(mesh.vertices().size() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (TopExp_Explorer exp(shape.tshape(), TopAbs_FACE); exp.More(); exp.Next())
|
||||||
|
{
|
||||||
|
TopoDS_Face face = TopoDS::Face(exp.Current());
|
||||||
|
|
||||||
|
TopLoc_Location faceLoc;
|
||||||
|
Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
|
||||||
|
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(face, faceLoc);
|
||||||
|
|
||||||
|
for (int n {1}; n <= triangulation->NbTriangles(); n++)
|
||||||
|
{
|
||||||
|
Poly_Triangle triangle = triangulation->Triangle(n);
|
||||||
|
gp_Pnt point[3];
|
||||||
|
|
||||||
|
for (int k {1}; k <= 3; k++)
|
||||||
|
point[k - 1] = (triangulation->Node(triangle(k))).Transformed(faceLoc);
|
||||||
|
|
||||||
|
mesh.addVertex(point[0].X(), point[0].Y(), point[0].Z());
|
||||||
|
mesh.addVertex(point[1].X(), point[1].Y(), point[1].Z());
|
||||||
|
mesh.addVertex(point[2].X(), point[2].Y(), point[2].Z());
|
||||||
|
auto last = mesh.vertices().size() - 1;
|
||||||
|
mesh.addEdge(mesh.vertex(last - 2), mesh.vertex(last - 1));
|
||||||
|
mesh.addEdge(mesh.vertex(last - 1), mesh.vertex(last));
|
||||||
|
mesh.addEdge(mesh.vertex(last), mesh.vertex(last - 2));
|
||||||
|
last = mesh.edges().size() - 1;
|
||||||
|
mesh.addFace(mesh.edge(last - 2), mesh.edge(last - 1), mesh.edge(last));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -192,7 +267,6 @@ int main()
|
|||||||
ao.unbind();
|
ao.unbind();
|
||||||
bo.unbind();*/
|
bo.unbind();*/
|
||||||
glfwWindowHint(GLFW_SAMPLES, 4);
|
glfwWindowHint(GLFW_SAMPLES, 4);
|
||||||
ImPlot::CreateContext();
|
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
/*gpu::Texture tex;
|
/*gpu::Texture tex;
|
||||||
tex.create();
|
tex.create();
|
||||||
@ -206,6 +280,14 @@ int main()
|
|||||||
framebuffer.attach(rb);
|
framebuffer.attach(rb);
|
||||||
framebuffer.unbind();*/
|
framebuffer.unbind();*/
|
||||||
const vec4 background = vec4(0.2f, 0.2f, 0.2f, 1.0f);
|
const vec4 background = vec4(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
|
|
||||||
|
darray<UITarget*> renderQueue;
|
||||||
|
unsigned int renderID = 0;
|
||||||
|
static bool constructionWindow = false;
|
||||||
|
|
||||||
|
visual.window()->icon("icon.png");
|
||||||
|
// in an imgui window somewhere...
|
||||||
|
|
||||||
while (visual.window()->state() != gpu::Window::Closed)
|
while (visual.window()->state() != gpu::Window::Closed)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -228,29 +310,109 @@ int main()
|
|||||||
scene.camera()->aspect() = (float)framebuffer.width() / (float)framebuffer.height();
|
scene.camera()->aspect() = (float)framebuffer.width() / (float)framebuffer.height();
|
||||||
scene.render();
|
scene.render();
|
||||||
framebuffer.unbind();
|
framebuffer.unbind();
|
||||||
|
|
||||||
viewport.size() = vec2((float)visual.window()->width(), (float)visual.window()->height());
|
viewport.size() = vec2((float)visual.window()->width(), (float)visual.window()->height());
|
||||||
viewport.set();
|
viewport.set();
|
||||||
//shaderProgram.bind();
|
//shaderProgram.bind();
|
||||||
|
|
||||||
ui.createFrame();
|
ui.createFrame();
|
||||||
bool yes = true;
|
|
||||||
ImGui::ShowDemoWindow(&yes);
|
|
||||||
ImPlot::ShowDemoWindow(&yes);
|
|
||||||
|
|
||||||
ImGui::Begin("Hello, world!");
|
//if (constructionWindow && ImGui::Begin("Construction"))
|
||||||
|
// ImGui::End();
|
||||||
|
|
||||||
|
if (ui.menuClose)
|
||||||
|
visual.window()->state(gpu::Window::Closed);
|
||||||
|
|
||||||
|
ui.render();
|
||||||
|
if (ImGui::BeginMainMenuBar())
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Geometry"))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Cell")) {
|
||||||
|
constructionWindow = true;
|
||||||
|
renderQueue.push(new UITarget {
|
||||||
|
++renderID,
|
||||||
|
[&renderQueue](unsigned int id){
|
||||||
|
if (ImGui::Begin("Construction", nullptr, ImGuiWindowFlags_NoCollapse))
|
||||||
|
{
|
||||||
|
vec3 size {1, 1, 1}, scale {1, 1, 1}, translation {0, 0, 0}, rotation {0, 0, 0};
|
||||||
|
ImGui::DragFloat3("Size", size.data());
|
||||||
|
ImGui::DragFloat3("Scale", scale.data());
|
||||||
|
ImGui::DragFloat3("Translation", translation.data());
|
||||||
|
ImGui::DragFloat3("Rotation", rotation.data());
|
||||||
|
if (ImGui::Button("Create"))
|
||||||
|
{
|
||||||
|
/*csg::Lattice lattice {csg::Lattice::Primitive};
|
||||||
|
csg::Shape cell = csg::Cell(lattice)(size, scale, translation, rotation);
|
||||||
|
mesh::Mesh mesh = build_mesh(cell);
|
||||||
|
Entity ent {visual.shaderProgram()};
|
||||||
|
darray<vec3> vert;
|
||||||
|
vert.resize(mesh.vertices().size());
|
||||||
|
for (auto v : mesh.vertices())
|
||||||
|
vert.push(static_cast<vec3>(*v));
|
||||||
|
ent.addVertices(vert);
|
||||||
|
scene.add(TreeNode<Entity>(ent));*/
|
||||||
|
constructionWindow = false;
|
||||||
|
renderQueue.remove([id](UITarget* target){
|
||||||
|
if (target != nullptr)
|
||||||
|
if (target->id == id)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&constructionWindow
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/*else {
|
||||||
|
constructionWindow = false;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndMainMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto renderItem : renderQueue)
|
||||||
|
{
|
||||||
|
if (renderItem != nullptr)
|
||||||
|
renderItem->render();
|
||||||
|
}
|
||||||
|
ImGui::Begin("Hello, world!");
|
||||||
|
{
|
||||||
|
ImGui::Text( ICON_FA_ATOM " Paint" );
|
||||||
if (ImGui::Button("Exit"))
|
if (ImGui::Button("Exit"))
|
||||||
visual.window()->state(gpu::Window::Closed);
|
visual.window()->state(gpu::Window::Closed);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.render();
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
if (ImGui::Begin("Scene"))
|
if (ImGui::Begin("WindowDock#1", nullptr, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoTitleBar))
|
||||||
{
|
{
|
||||||
|
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
|
if (ImGui::BeginMenu(ICON_FA_LIST))
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled("General");
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::MenuItem("3D Viewport");
|
||||||
|
ImGui::Text("Data");
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::MenuItem("Outliner");
|
||||||
|
ImGui::MenuItem("Properties");
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
if (!ImGui::IsWindowCollapsed())
|
if (!ImGui::IsWindowCollapsed())
|
||||||
{
|
{
|
||||||
framebuffer.width() = static_cast<int>(ImGui::GetContentRegionAvail().x);
|
framebuffer.width() = static_cast<int>(ImGui::GetContentRegionAvail().x);
|
||||||
@ -260,7 +422,8 @@ int main()
|
|||||||
ImVec2{0, 1}, ImVec2{1, 0});
|
ImVec2{0, 1}, ImVec2{1, 0});
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
Ray ray;
|
|
||||||
|
/*Ray ray;
|
||||||
ray.fromScreen(io.MousePos.x, io.MousePos.y, framebuffer.width(), framebuffer.height(), scene.camera());
|
ray.fromScreen(io.MousePos.x, io.MousePos.y, framebuffer.width(), framebuffer.height(), scene.camera());
|
||||||
float tMin, tMax;
|
float tMin, tMax;
|
||||||
Entity* ent = scene.nodes()[0].data();
|
Entity* ent = scene.nodes()[0].data();
|
||||||
@ -269,16 +432,17 @@ int main()
|
|||||||
if (rayOBB)
|
if (rayOBB)
|
||||||
ent->color(vec4(1.f, 0.f, 0.f, 1.f));
|
ent->color(vec4(1.f, 0.f, 0.f, 1.f));
|
||||||
else
|
else
|
||||||
ent->color(vec4(0.f, 1.f, 0.f, 1.f));
|
ent->color(vec4(0.f, 1.f, 0.f, 1.f));*/
|
||||||
|
|
||||||
if (ImGui::Begin("Properties"))
|
if (ImGui::Begin("Properties"))
|
||||||
{
|
{
|
||||||
ImGui::DragFloat3("position", ray.p_position.data());
|
/*ImGui::DragFloat3("position", ray.p_position.data());
|
||||||
ImGui::DragFloat3("direction", ray.p_direction.data());
|
ImGui::DragFloat3("direction", ray.p_direction.data());*/
|
||||||
vec2 mouse {io.MousePos.x, io.MousePos.y};
|
vec2 mouse {io.MousePos.x, io.MousePos.y};
|
||||||
ImGui::DragFloat2("mouse", mouse.data());
|
ImGui::DragFloat2("mouse", mouse.data());
|
||||||
ImGui::Checkbox("ray", &rayOBB);
|
/*ImGui::Checkbox("ray", &rayOBB);
|
||||||
ImGui::DragFloat("dist", &tMin);
|
ImGui::DragFloat("dist", &tMin);
|
||||||
ImGui::DragFloat("dist", &tMax);
|
ImGui::DragFloat("dist", &tMax);*/
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
if (ImGui::IsWindowHovered())
|
if (ImGui::IsWindowHovered())
|
||||||
@ -313,7 +477,6 @@ int main()
|
|||||||
visual.render();
|
visual.render();
|
||||||
|
|
||||||
}
|
}
|
||||||
ImPlot::DestroyContext();
|
|
||||||
framebuffer.destroy();
|
framebuffer.destroy();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
9
source/creator/test3.cpp
Normal file
9
source/creator/test3.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "application.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Application app;
|
||||||
|
app.run();
|
||||||
|
return 0;
|
||||||
|
}
|
0
source/creator/transform.hpp
Executable file → Normal file
0
source/creator/transform.hpp
Executable file → Normal file
246
source/creator/ui.hpp
Executable file → Normal file
246
source/creator/ui.hpp
Executable file → Normal file
@ -6,8 +6,12 @@
|
|||||||
#include <imgui_impl_glfw.h>
|
#include <imgui_impl_glfw.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
#include <imgui_impl_opengl3.h>
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
//#include <imgui_stdlib.h>
|
#include <imgui_freetype.h>
|
||||||
|
|
||||||
|
//#include <imgui_stdlib.h>
|
||||||
|
#include "FontAwesome6.hpp"
|
||||||
|
|
||||||
|
#include <implot.h>
|
||||||
|
|
||||||
using namespace hpr;
|
using namespace hpr;
|
||||||
|
|
||||||
@ -24,19 +28,123 @@ public:
|
|||||||
|
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window->instance(), true);
|
ImGui_ImplGlfw_InitForOpenGL(window->instance(), true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 430");
|
ImGui_ImplOpenGL3_Init("#version 430");
|
||||||
io().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
|
||||||
io().ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
ImPlot::CreateContext();
|
||||||
|
|
||||||
|
configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
~UI()
|
~UI()
|
||||||
{
|
{
|
||||||
|
ImPlot::DestroyContext();
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void configure()
|
||||||
|
{
|
||||||
|
auto& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
// features
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
|
||||||
|
// fonts
|
||||||
|
//io.Fonts->AddFontDefault();
|
||||||
|
float baseFontSize = 16.0f; // 13.0f is the size of the default font. Change to the font size you use.
|
||||||
|
float iconFontSize = baseFontSize * 2.0f / 3.0f; // FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly
|
||||||
|
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_16_FA, 0 };
|
||||||
|
ImFontConfig icons_config;
|
||||||
|
icons_config.MergeMode = true;
|
||||||
|
icons_config.PixelSnapH = true;
|
||||||
|
icons_config.GlyphMinAdvanceX = iconFontSize;
|
||||||
|
|
||||||
|
io.Fonts->AddFontFromFileTTF("droidsans.ttf", 14.f);
|
||||||
|
io.Fonts->AddFontFromFileTTF( FONT_ICON_FILE_NAME_FAS, iconFontSize, &icons_config, icons_ranges );
|
||||||
|
io.Fonts->Build();
|
||||||
|
|
||||||
|
// style
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style.Colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ChildBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_PopupBg] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_Border] = ImVec4(0.05f, 0.05f, 0.05f, 0.50f);
|
||||||
|
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
|
style.Colors[ImGuiCol_FrameBg] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f);
|
||||||
|
style.Colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
|
||||||
|
style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
|
style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
|
||||||
|
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_CheckMark] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.08f, 0.50f, 0.72f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_Button] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f);
|
||||||
|
style.Colors[ImGuiCol_Header] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.67f, 0.67f, 0.67f, 0.39f);
|
||||||
|
style.Colors[ImGuiCol_Separator] = style.Colors[ImGuiCol_Border];
|
||||||
|
style.Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.41f, 0.42f, 0.44f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_SeparatorActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||||
|
style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
|
style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.29f, 0.30f, 0.31f, 0.67f);
|
||||||
|
style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||||
|
style.Colors[ImGuiCol_Tab] = ImVec4(0.08f, 0.08f, 0.09f, 0.83f);
|
||||||
|
style.Colors[ImGuiCol_TabHovered] = ImVec4(0.33f, 0.34f, 0.36f, 0.83f);
|
||||||
|
style.Colors[ImGuiCol_TabActive] = ImVec4(0.23f, 0.23f, 0.24f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_TabUnfocused] = ImVec4(0.08f, 0.08f, 0.09f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.13f, 0.14f, 0.15f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_DockingPreview] = ImVec4(0.26f, 0.59f, 0.98f, 0.70f);
|
||||||
|
style.Colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||||
|
style.Colors[ImGuiCol_DragDropTarget] = ImVec4(0.11f, 0.64f, 0.92f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||||
|
style.Colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
|
||||||
|
style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
|
||||||
|
style.GrabRounding = style.FrameRounding = 2.3f;
|
||||||
|
style.WindowRounding = 10.f;
|
||||||
|
style.WindowPadding = ImVec2(2.f, 2.f);
|
||||||
|
style.ScrollbarSize = 12.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void createFrame()
|
void createFrame()
|
||||||
{
|
{
|
||||||
|
float RasterizerMultiply = 1.0f;
|
||||||
|
unsigned int FreeTypeBuilderFlags = 0;
|
||||||
|
|
||||||
|
ImFontAtlas* atlas = ImGui::GetIO().Fonts;
|
||||||
|
for (int n = 0; n < atlas->ConfigData.Size; n++)
|
||||||
|
((ImFontConfig*)&atlas->ConfigData[n])->RasterizerMultiply = RasterizerMultiply;
|
||||||
|
|
||||||
|
atlas->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType();
|
||||||
|
atlas->FontBuilderFlags = FreeTypeBuilderFlags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
atlas->FontBuilderIO = ImFontAtlasGetBuilderForStbTruetype();
|
||||||
|
atlas->FontBuilderFlags = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
|
atlas->Build();
|
||||||
|
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
|
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
@ -54,35 +162,84 @@ public:
|
|||||||
return ImGui::GetIO();
|
return ImGui::GetIO();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
bool menuFileNew;
|
||||||
void render()
|
bool menuFileOpen;
|
||||||
|
bool menuClose;
|
||||||
|
bool helpImguiDemo;
|
||||||
|
bool helpImplotDemo;
|
||||||
|
|
||||||
|
void mainMenu()
|
||||||
{
|
{
|
||||||
static auto first_time = true;
|
ImGui::PushStyleColor(ImGuiCol_MenuBarBg, ImVec4(0.12f, 0.12f, 0.12f, 1.f));
|
||||||
static bool show_object_explorer = true;
|
|
||||||
static bool show_properties = true;
|
|
||||||
static bool show_demo = false;
|
|
||||||
|
|
||||||
if (ImGui::BeginMainMenuBar())
|
if (ImGui::BeginMainMenuBar())
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("Options"))
|
ImGui::PopStyleColor(1);
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("File"))
|
||||||
{
|
{
|
||||||
ImGui::MenuItem("Undo", "CTRL+Z");
|
menuFileNew = ImGui::MenuItem(ICON_FA_FILE " New");
|
||||||
|
menuFileOpen = ImGui::MenuItem(ICON_FA_FOLDER_OPEN " Open...");
|
||||||
|
ImGui::Separator();
|
||||||
|
menuClose = ImGui::MenuItem(ICON_FA_POWER_OFF " Quit");
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
if (ImGui::BeginMenu("View"))
|
|
||||||
|
if (ImGui::BeginMenu("Edit"))
|
||||||
{
|
{
|
||||||
ImGui::MenuItem("Object explorer", nullptr, &show_object_explorer);
|
ImGui::MenuItem("Undo", "Ctrl Z");
|
||||||
ImGui::MenuItem("Properties", nullptr, &show_properties);
|
ImGui::MenuItem("Redo", "Shift Ctrl Z");
|
||||||
ImGui::MenuItem("Demo", nullptr, &show_demo);
|
ImGui::Separator();
|
||||||
|
ImGui::MenuItem(ICON_FA_GEAR " Preferences...");
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginMenu("Help"))
|
||||||
|
{
|
||||||
|
ImGui::MenuItem(ICON_FA_GLOBE " Documentation");
|
||||||
|
ImGui::MenuItem(ICON_FA_GLOBE " Issues");
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::MenuItem("ImGui demo", nullptr, &helpImguiDemo);
|
||||||
|
ImGui::MenuItem("ImPlot demo", nullptr, &helpImplotDemo);
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMainMenuBar();
|
ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_demo)
|
if (helpImguiDemo)
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
|
|
||||||
|
if (helpImplotDemo)
|
||||||
|
ImPlot::ShowDemoWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainDockspace()
|
||||||
|
{
|
||||||
|
auto split = [](ImGuiID& parentNode, ImGuiDir direction, unsigned int currentID, unsigned int lastID)
|
||||||
|
{
|
||||||
|
//ImGui::DockBuilderSetNodePos(parent_node, ImGui::GetWindowPos());
|
||||||
|
//ImGui::DockBuilderSetNodeSize(parent_node, ImGui::GetWindowSize());
|
||||||
|
ImGuiID nodeA;
|
||||||
|
ImGuiID nodeB;
|
||||||
|
ImGui::DockBuilderSplitNode(parentNode, direction, 0.5f, &nodeB, &nodeA);
|
||||||
|
|
||||||
|
ImGui::DockBuilderDockWindow((std::string("WindowDock#") + std::to_string(currentID)).data(), nodeA);
|
||||||
|
ImGui::DockBuilderDockWindow((std::string("WindowDock#") + std::to_string(lastID + 1)).data(), nodeB);
|
||||||
|
|
||||||
|
ImGuiDockNode* node = ImGui::DockBuilderGetNode(nodeB);
|
||||||
|
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoTabBar;
|
||||||
|
|
||||||
|
ImGui::DockBuilderFinish(parentNode);
|
||||||
|
parentNode = nodeA;
|
||||||
|
|
||||||
|
return nodeB;
|
||||||
|
};
|
||||||
|
static auto first_time = true;
|
||||||
|
|
||||||
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
const ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
ImGui::SetNextWindowPos(viewport->WorkPos);
|
ImGui::SetNextWindowPos(viewport->WorkPos);
|
||||||
ImGui::SetNextWindowSize(viewport->WorkSize);
|
ImGui::SetNextWindowSize(viewport->WorkSize);
|
||||||
@ -94,16 +251,16 @@ public:
|
|||||||
//window_flags |= ImGuiWindowFlags_MenuBar;
|
//window_flags |= ImGuiWindowFlags_MenuBar;
|
||||||
//window_flags |= ImGuiWindowFlags_NoBackground;
|
//window_flags |= ImGuiWindowFlags_NoBackground;
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
//ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
|
||||||
|
|
||||||
if (ImGui::Begin("Main dockspace", nullptr, window_flags))
|
if (ImGui::Begin("#Dockspace", nullptr, window_flags))
|
||||||
{
|
{
|
||||||
ImGui::PopStyleVar(3);
|
ImGui::PopStyleVar(2);
|
||||||
|
|
||||||
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
||||||
|
ImGuiID dockspace_id = ImGui::GetID("Dockspace");
|
||||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
||||||
|
|
||||||
if (first_time)
|
if (first_time)
|
||||||
@ -111,42 +268,40 @@ public:
|
|||||||
first_time = false;
|
first_time = false;
|
||||||
|
|
||||||
ImGui::DockBuilderRemoveNode(dockspace_id);
|
ImGui::DockBuilderRemoveNode(dockspace_id);
|
||||||
ImGui::DockBuilderAddNode(dockspace_id, dockspace_flags | ImGuiDockNodeFlags_DockSpace);
|
ImGui::DockBuilderAddNode(dockspace_id);
|
||||||
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
|
ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size);
|
||||||
|
|
||||||
ImGuiID dock_id_left = ImGui::DockBuilderSplitNode(dockspace_id, ImGuiDir_Right, 0.2f, nullptr, &dockspace_id);
|
// [ 1.1 ] [ 2.1 ]
|
||||||
//ImGuiID dock_id_down = ImGui::DockBuilderSplitNode(dockspace_id, ImGuiDir_Right, 1.0f, &dockspace_id, nullptr);
|
// [ ] [ 2.2 ]
|
||||||
ImGuiID dock_id_down = ImGui::DockBuilderSplitNode(dock_id_left, ImGuiDir_Down, 0.5f, nullptr, &dock_id_left);
|
ImGuiID dock21 = ImGui::DockBuilderSplitNode(dockspace_id, ImGuiDir_Right, 0.2f, nullptr, &dockspace_id);
|
||||||
|
ImGuiID dock22 = ImGui::DockBuilderSplitNode(dock21, ImGuiDir_Down, 0.5f, nullptr, &dock21);
|
||||||
|
|
||||||
|
ImGui::DockBuilderDockWindow("Component#1", dockspace_id);
|
||||||
ImGuiDockNode* node = ImGui::DockBuilderGetNode(dockspace_id);
|
ImGuiDockNode* node = ImGui::DockBuilderGetNode(dockspace_id);
|
||||||
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton;
|
|
||||||
|
|
||||||
ImGui::DockBuilderDockWindow("Scene", dockspace_id);
|
|
||||||
ImGui::DockBuilderDockWindow("Object explorer", dock_id_left);
|
|
||||||
// Properties
|
|
||||||
node = ImGui::DockBuilderGetNode(dock_id_down);
|
|
||||||
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoTabBar ;
|
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoTabBar ;
|
||||||
ImGui::DockBuilderDockWindow("Properties", dock_id_down);
|
|
||||||
//ImGui::DockBuilderDockWindow("Scene_", dock_id_down);
|
ImGui::DockBuilderDockWindow("Component#2", dock21);
|
||||||
|
node = ImGui::DockBuilderGetNode(dock21);
|
||||||
|
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoTabBar;
|
||||||
|
|
||||||
|
ImGui::DockBuilderDockWindow("Component#3", dock22);
|
||||||
|
node = ImGui::DockBuilderGetNode(dock22);
|
||||||
|
node->LocalFlags |= ImGuiDockNodeFlags_NoCloseButton | ImGuiDockNodeFlags_NoTabBar;
|
||||||
|
|
||||||
ImGui::DockBuilderFinish(dockspace_id);
|
ImGui::DockBuilderFinish(dockspace_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiViewport* viewport2 = ImGui::GetMainViewport();
|
|
||||||
ImGuiWindowFlags window_flags2 = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
|
|
||||||
float height = ImGui::GetFrameHeight();
|
|
||||||
|
|
||||||
if (ImGui::BeginViewportSideBar("##SecondaryMenuBar", viewport2, ImGuiDir_Up, height, window_flags2)) {
|
|
||||||
if (ImGui::BeginMenuBar()) {
|
|
||||||
ImGui::Text("menu bar");
|
|
||||||
ImGui::EndMenuBar();
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::BeginViewportSideBar("#MainStatusBar", viewport2, ImGuiDir_Down, height, window_flags2)) {
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
void statusBar()
|
||||||
|
{
|
||||||
|
if (ImGui::BeginViewportSideBar("#MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, ImGui::GetFrameHeight(), ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar))
|
||||||
|
{
|
||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenuBar()) {
|
||||||
ImGui::Text("status bar");
|
ImGui::Text("status bar");
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
@ -154,4 +309,5 @@ public:
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
0
source/creator/visual.hpp
Executable file → Normal file
0
source/creator/visual.hpp
Executable file → Normal file
0
source/hpr/CMakeLists.txt
Executable file → Normal file
0
source/hpr/CMakeLists.txt
Executable file → Normal file
0
source/hpr/containers.hpp
Executable file → Normal file
0
source/hpr/containers.hpp
Executable file → Normal file
0
source/hpr/containers/CMakeLists.txt
Executable file → Normal file
0
source/hpr/containers/CMakeLists.txt
Executable file → Normal file
1
source/hpr/containers/array.hpp
Executable file → Normal file
1
source/hpr/containers/array.hpp
Executable file → Normal file
@ -3,3 +3,4 @@
|
|||||||
#include <hpr/containers/array/iterator.hpp>
|
#include <hpr/containers/array/iterator.hpp>
|
||||||
#include <hpr/containers/array/dynamic_array.hpp>
|
#include <hpr/containers/array/dynamic_array.hpp>
|
||||||
#include <hpr/containers/array/static_array.hpp>
|
#include <hpr/containers/array/static_array.hpp>
|
||||||
|
#include <hpr/containers/array/algorithm.hpp>
|
46
source/hpr/containers/array/algorithm.hpp
Normal file
46
source/hpr/containers/array/algorithm.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hpr/containers/array/sequence.hpp>
|
||||||
|
#include <hpr/containers/array/dynamic_array.hpp>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
|
|
||||||
|
namespace hpr
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr
|
||||||
|
T sum(const Sequence<T>& s)
|
||||||
|
{
|
||||||
|
return std::accumulate(s.begin(), s.end(), T());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr
|
||||||
|
T prod(const Sequence<T>& s)
|
||||||
|
{
|
||||||
|
return std::accumulate(s.begin(), s.end(), T(), std::multiplies<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr
|
||||||
|
bool contain(const Sequence<T>& s, const T& val)
|
||||||
|
{
|
||||||
|
for (const T& el : s)
|
||||||
|
if (el == val)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr
|
||||||
|
Sequence<T> unique(const Sequence<T>& s)
|
||||||
|
{
|
||||||
|
darray<T> seq;
|
||||||
|
for (const T& el : s)
|
||||||
|
if (!contain(seq, el))
|
||||||
|
seq.push(el);
|
||||||
|
return seq;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
12
source/hpr/containers/array/dynamic_array.hpp
Executable file → Normal file
12
source/hpr/containers/array/dynamic_array.hpp
Executable file → Normal file
@ -64,6 +64,11 @@ public:
|
|||||||
base {b}
|
base {b}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
constexpr explicit
|
||||||
|
DynamicArray(base&& b) noexcept :
|
||||||
|
base {std::forward<base>(b)}
|
||||||
|
{}
|
||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
DynamicArray(const DynamicArray& arr) noexcept :
|
DynamicArray(const DynamicArray& arr) noexcept :
|
||||||
base {static_cast<base>(arr)}
|
base {static_cast<base>(arr)}
|
||||||
@ -111,6 +116,13 @@ public:
|
|||||||
base {size, value}
|
base {size, value}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
constexpr
|
||||||
|
DynamicArray& operator=(base other) noexcept
|
||||||
|
{
|
||||||
|
swap(*this, other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
DynamicArray& operator=(DynamicArray other) noexcept
|
DynamicArray& operator=(DynamicArray other) noexcept
|
||||||
{
|
{
|
||||||
|
0
source/hpr/containers/array/iterator.hpp
Executable file → Normal file
0
source/hpr/containers/array/iterator.hpp
Executable file → Normal file
15
source/hpr/containers/array/sequence.hpp
Executable file → Normal file
15
source/hpr/containers/array/sequence.hpp
Executable file → Normal file
@ -22,6 +22,11 @@ template <typename T>
|
|||||||
struct is_sequence<Sequence<T>> : public std::true_type
|
struct is_sequence<Sequence<T>> : public std::true_type
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
// concepts
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
concept IsSequence = is_sequence<Type>::value;
|
||||||
|
|
||||||
// class definition
|
// class definition
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -100,7 +105,7 @@ public:
|
|||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
constexpr
|
constexpr
|
||||||
Sequence(Iter start, Iter end) :
|
Sequence(Iter start, Iter end) :
|
||||||
p_size {static_cast<size_type>(std::distance(start, end))},//size_type(end.operator->() - start.operator->())},
|
p_size {static_cast<size_type>(std::distance(start, end))},
|
||||||
p_capacity {p_size},
|
p_capacity {p_size},
|
||||||
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
||||||
{
|
{
|
||||||
@ -109,7 +114,7 @@ public:
|
|||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
Sequence(iterator start, iterator end) :
|
Sequence(iterator start, iterator end) :
|
||||||
p_size {static_cast<size_type>(std::distance(start, end))},//size_type(end.operator->() - start.operator->())},
|
p_size {static_cast<size_type>(std::distance(start, end))},
|
||||||
p_capacity {p_size},
|
p_capacity {p_size},
|
||||||
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
||||||
{
|
{
|
||||||
@ -118,7 +123,7 @@ public:
|
|||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
Sequence(const_iterator start, const_iterator end) :
|
Sequence(const_iterator start, const_iterator end) :
|
||||||
p_size {std::distance(start, end)},//{size_type(end.operator->() - start.operator->())},
|
p_size {static_cast<size_type>(std::distance(start, end))},
|
||||||
p_capacity {p_size},
|
p_capacity {p_size},
|
||||||
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
||||||
{
|
{
|
||||||
@ -127,7 +132,7 @@ public:
|
|||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
Sequence(iterator start, iterator end, size_type capacity) :
|
Sequence(iterator start, iterator end, size_type capacity) :
|
||||||
p_size {static_cast<size_type>(std::distance(start, end))},//size_type(end.operator->() - start.operator->())},
|
p_size {static_cast<size_type>(std::distance(start, end))},
|
||||||
p_capacity {capacity},
|
p_capacity {capacity},
|
||||||
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
||||||
{
|
{
|
||||||
@ -136,7 +141,7 @@ public:
|
|||||||
|
|
||||||
constexpr
|
constexpr
|
||||||
Sequence(const_iterator start, const_iterator end, size_type capacity) :
|
Sequence(const_iterator start, const_iterator end, size_type capacity) :
|
||||||
p_size {std::distance(start, end)},//{size_type(end.operator->() - start.operator->())},
|
p_size {static_cast<size_type>(std::distance(start, end))},
|
||||||
p_capacity {capacity},
|
p_capacity {capacity},
|
||||||
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
p_start {p_capacity ? new value_type[p_capacity] : nullptr}
|
||||||
{
|
{
|
||||||
|
0
source/hpr/containers/array/static_array.hpp
Executable file → Normal file
0
source/hpr/containers/array/static_array.hpp
Executable file → Normal file
0
source/hpr/containers/graph.hpp
Executable file → Normal file
0
source/hpr/containers/graph.hpp
Executable file → Normal file
0
source/hpr/containers/graph/tree_node.hpp
Executable file → Normal file
0
source/hpr/containers/graph/tree_node.hpp
Executable file → Normal file
0
source/hpr/containers/tests/containers-test.cpp
Executable file → Normal file
0
source/hpr/containers/tests/containers-test.cpp
Executable file → Normal file
5
source/hpr/csg.hpp
Executable file → Normal file
5
source/hpr/csg.hpp
Executable file → Normal file
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hpr/csg/shape.hpp>
|
#include <hpr/csg/shape.hpp>
|
||||||
|
|
||||||
#include <hpr/csg/vertex.hpp>
|
#include <hpr/csg/vertex.hpp>
|
||||||
#include <hpr/csg/edge.hpp>
|
#include <hpr/csg/edge.hpp>
|
||||||
#include <hpr/csg/wire.hpp>
|
#include <hpr/csg/wire.hpp>
|
||||||
@ -10,3 +11,7 @@
|
|||||||
#include <hpr/csg/compound.hpp>
|
#include <hpr/csg/compound.hpp>
|
||||||
#include <hpr/csg/geometry.hpp>
|
#include <hpr/csg/geometry.hpp>
|
||||||
#include <hpr/csg/surface.hpp>
|
#include <hpr/csg/surface.hpp>
|
||||||
|
|
||||||
|
#include <hpr/csg/transformation.hpp>
|
||||||
|
#include <hpr/csg/generation.hpp>
|
||||||
|
#include <hpr/csg/boolean.hpp>
|
||||||
|
0
source/hpr/csg/CMakeLists.txt
Executable file → Normal file
0
source/hpr/csg/CMakeLists.txt
Executable file → Normal file
50
source/hpr/csg/boolean.hpp
Normal file
50
source/hpr/csg/boolean.hpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hpr/csg/shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace hpr::csg
|
||||||
|
{
|
||||||
|
|
||||||
|
Shape fuse(const darray<Shape>& args, const darray<Shape>& tools)
|
||||||
|
{
|
||||||
|
BRepAlgoAPI_Fuse builder;
|
||||||
|
NCollection_List<TopoDS_Shape> args_, tools_;
|
||||||
|
|
||||||
|
for (const auto& arg : args)
|
||||||
|
args_.Append(arg.tshape());
|
||||||
|
for (const auto& tool : tools)
|
||||||
|
tools_.Append(tool.tshape());
|
||||||
|
|
||||||
|
builder.SetArguments(args_);
|
||||||
|
builder.SetTools(tools_);
|
||||||
|
builder.Build();
|
||||||
|
|
||||||
|
return Shape {builder.Shape()};
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape fuse(const Shape& lhs, const Shape& rhs)
|
||||||
|
{
|
||||||
|
BRepAlgoAPI_Fuse builder {lhs.tshape(), rhs.tshape()};
|
||||||
|
builder.Build();
|
||||||
|
|
||||||
|
return Shape {builder.Shape()};
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape common(const Shape& lhs, const Shape& rhs)
|
||||||
|
{
|
||||||
|
BRepAlgoAPI_Common builder {lhs.tshape(), rhs.tshape()};
|
||||||
|
builder.Build();
|
||||||
|
|
||||||
|
return Shape {builder.Shape()};
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape cut(const Shape& lhs, const Shape& rhs)
|
||||||
|
{
|
||||||
|
BRepAlgoAPI_Cut builder {lhs.tshape(), rhs.tshape()};
|
||||||
|
builder.Build();
|
||||||
|
|
||||||
|
return Shape {builder.Shape()};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
0
source/hpr/csg/compound.hpp
Executable file → Normal file
0
source/hpr/csg/compound.hpp
Executable file → Normal file
0
source/hpr/csg/edge.hpp
Executable file → Normal file
0
source/hpr/csg/edge.hpp
Executable file → Normal file
2
source/hpr/csg/face.hpp
Executable file → Normal file
2
source/hpr/csg/face.hpp
Executable file → Normal file
@ -27,7 +27,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
Face(const darray<Shape>& edges) :
|
Face(const darray<Edge>& edges) :
|
||||||
Face {Wire(edges)}
|
Face {Wire(edges)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
43
source/hpr/csg/generation.hpp
Normal file
43
source/hpr/csg/generation.hpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hpr/csg/shape.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace hpr::csg
|
||||||
|
{
|
||||||
|
|
||||||
|
Shape extrude(const Shape& shape, const vec3& dir, double length)
|
||||||
|
{
|
||||||
|
BRepPrimAPI_MakePrism builder {shape.tshape(), length * gp_Vec(dir[0], dir[1], dir[2]), true};
|
||||||
|
builder.Build();
|
||||||
|
return builder.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape fillet(const Shape& shape, const darray<Shape>& edges, double radius)
|
||||||
|
{
|
||||||
|
BRepFilletAPI_MakeFillet fillet {shape.tshape()};
|
||||||
|
|
||||||
|
for (auto& e : edges)
|
||||||
|
fillet.Add(radius, TopoDS::Edge(e.tshape()));
|
||||||
|
fillet.Build();
|
||||||
|
|
||||||
|
return fillet.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape sphere(const vec3& center, double radius)
|
||||||
|
{
|
||||||
|
BRepPrimAPI_MakeSphere prim {gp_Pnt(center[0], center[1], center[2]), radius};
|
||||||
|
return Shape {prim.Shape()};
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape box(const vec3& corner, double dx, double dy, double dz)
|
||||||
|
{
|
||||||
|
BRepPrimAPI_MakeBox prim {gp_Pnt(corner[0], corner[1], corner[2]), dx, dy, dz};
|
||||||
|
return Shape {prim.Shape()};
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape box(const vec3& corner, const vec3& scale)
|
||||||
|
{
|
||||||
|
return box(corner, scale[0], scale[1], scale[2]);
|
||||||
|
}
|
||||||
|
}
|
0
source/hpr/csg/geometry.hpp
Executable file → Normal file
0
source/hpr/csg/geometry.hpp
Executable file → Normal file
15
source/hpr/csg/shape.cpp
Executable file → Normal file
15
source/hpr/csg/shape.cpp
Executable file → Normal file
@ -1,4 +1,5 @@
|
|||||||
#include <hpr/csg/shape.hpp>
|
#include <hpr/csg/shape.hpp>
|
||||||
|
#include <hpr/csg/compound.hpp>
|
||||||
|
|
||||||
|
|
||||||
bool std::less<hpr::csg::Shape>::operator()(const hpr::csg::Shape& s1, const hpr::csg::Shape& s2) const
|
bool std::less<hpr::csg::Shape>::operator()(const hpr::csg::Shape& s1, const hpr::csg::Shape& s2) const
|
||||||
@ -6,22 +7,10 @@ bool std::less<hpr::csg::Shape>::operator()(const hpr::csg::Shape& s1, const hpr
|
|||||||
return s1.tshape().HashCode(std::numeric_limits<Standard_Integer>::max()) <
|
return s1.tshape().HashCode(std::numeric_limits<Standard_Integer>::max()) <
|
||||||
s2.tshape().HashCode(std::numeric_limits<Standard_Integer>::max());
|
s2.tshape().HashCode(std::numeric_limits<Standard_Integer>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace hpr::csg
|
namespace hpr::csg
|
||||||
{
|
{
|
||||||
|
|
||||||
std::map<Shape, Shape::Metadata> Shape::metadata;
|
std::map<Shape, Shape::Metadata> Shape::metadata;
|
||||||
|
|
||||||
|
|
||||||
Shape sphere(vec3 center, double radius)
|
|
||||||
{
|
|
||||||
BRepPrimAPI_MakeSphere prim {gp_Pnt(center[0], center[1], center[2]), radius};
|
|
||||||
return Shape {prim.Shape()};
|
|
||||||
}
|
|
||||||
|
|
||||||
Shape box(vec3 corner, double dx, double dy, double dz)
|
|
||||||
{
|
|
||||||
BRepPrimAPI_MakeBox prim {gp_Pnt(corner[0], corner[1], corner[2]), dx, dy, dz};
|
|
||||||
return Shape {prim.Shape()};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
157
source/hpr/csg/shape.hpp
Executable file → Normal file
157
source/hpr/csg/shape.hpp
Executable file → Normal file
@ -26,6 +26,9 @@
|
|||||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeShell.hxx>
|
||||||
|
#include <BRepBuilderAPI_MakeSolid.hxx>
|
||||||
|
#include <BRepBuilderAPI_Sewing.hxx>
|
||||||
#include <BRep_Builder.hxx>
|
#include <BRep_Builder.hxx>
|
||||||
|
|
||||||
#include <BRepBndLib.hxx>
|
#include <BRepBndLib.hxx>
|
||||||
@ -38,6 +41,7 @@
|
|||||||
#include <BRepExtrema_DistShapeShape.hxx>
|
#include <BRepExtrema_DistShapeShape.hxx>
|
||||||
|
|
||||||
#include <BRepBuilderAPI_Transform.hxx>
|
#include <BRepBuilderAPI_Transform.hxx>
|
||||||
|
#include <BRepBuilderAPI_GTransform.hxx>
|
||||||
#include <BRepFilletAPI_MakeFillet.hxx>
|
#include <BRepFilletAPI_MakeFillet.hxx>
|
||||||
|
|
||||||
#include <BRepAlgoAPI_Fuse.hxx>
|
#include <BRepAlgoAPI_Fuse.hxx>
|
||||||
@ -65,6 +69,7 @@
|
|||||||
#include <ShapeFix_Face.hxx>
|
#include <ShapeFix_Face.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace hpr::csg
|
namespace hpr::csg
|
||||||
{
|
{
|
||||||
class Shape;
|
class Shape;
|
||||||
@ -82,19 +87,6 @@ namespace std
|
|||||||
namespace hpr::csg
|
namespace hpr::csg
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions
|
|
||||||
|
|
||||||
double distance(const Shape& lhs, const Shape& rhs);
|
|
||||||
|
|
||||||
Shape fuse(const Shape& lhs, const Shape& rhs);
|
|
||||||
|
|
||||||
Shape fuse(const darray<Shape>& args, const darray<Shape>& tools);
|
|
||||||
|
|
||||||
Shape common(const Shape& lhs, const Shape& rhs);
|
|
||||||
|
|
||||||
Shape cut(const Shape& lhs, const Shape& rhs);
|
|
||||||
|
|
||||||
|
|
||||||
// Class declaration
|
// Class declaration
|
||||||
|
|
||||||
class Shape
|
class Shape
|
||||||
@ -221,7 +213,7 @@ public:
|
|||||||
|
|
||||||
gp_Pnt center {props.CentreOfMass()};
|
gp_Pnt center {props.CentreOfMass()};
|
||||||
|
|
||||||
return vec3 {center.X(), center.Y(), center.Z()};
|
return vec3 {static_cast<scalar>(center.X()), static_cast<scalar>(center.Y()), static_cast<scalar>(center.Z())};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
@ -318,7 +310,10 @@ public:
|
|||||||
gp_Pnt p1 {bbox.CornerMin()};
|
gp_Pnt p1 {bbox.CornerMin()};
|
||||||
gp_Pnt p2 {bbox.CornerMax()};
|
gp_Pnt p2 {bbox.CornerMax()};
|
||||||
|
|
||||||
return sarray<vec3, 2> {{p1.X(), p1.Y(), p1.Z()}, {p2.X(), p2.Y(), p2.Z()}};
|
return sarray<vec3, 2> {
|
||||||
|
{static_cast<scalar>(p1.X()), static_cast<scalar>(p1.Y()), static_cast<scalar>(p1.Z())},
|
||||||
|
{static_cast<scalar>(p2.X()), static_cast<scalar>(p2.Y()), static_cast<scalar>(p2.Z())}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void incrementalMesh(double deflection)
|
void incrementalMesh(double deflection)
|
||||||
@ -329,10 +324,10 @@ public:
|
|||||||
|
|
||||||
darray<Shape> subShapes(Type type) const
|
darray<Shape> subShapes(Type type) const
|
||||||
{
|
{
|
||||||
darray<Shape> subshapes;
|
darray<Shape> shapes;
|
||||||
for (TopExp_Explorer exp(p_shape, static_cast<TopAbs_ShapeEnum>(type)); exp.More(); exp.Next())
|
for (TopExp_Explorer exp(p_shape, static_cast<TopAbs_ShapeEnum>(type)); exp.More(); exp.Next())
|
||||||
subshapes.push(Shape(exp.Current()));
|
shapes.push(Shape(exp.Current()));
|
||||||
return subshapes;
|
return shapes;
|
||||||
}
|
}
|
||||||
|
|
||||||
darray<Shape> edges() const
|
darray<Shape> edges() const
|
||||||
@ -350,141 +345,21 @@ public:
|
|||||||
return subShapes(Type::Shell);
|
return subShapes(Type::Shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Member functions: transformations
|
|
||||||
|
|
||||||
Shape translate(const vec3& dir)
|
|
||||||
{
|
|
||||||
gp_Trsf transform;
|
|
||||||
transform.SetTranslation(gp_Vec(dir[0], dir[1], dir[2]));
|
|
||||||
BRepBuilderAPI_Transform builder {p_shape, transform, true};
|
|
||||||
|
|
||||||
return builder.Shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
Shape rotate(const vec3& pos, const vec3& axis, double angle)
|
|
||||||
{
|
|
||||||
gp_Trsf transform;
|
|
||||||
transform.SetRotation(gp_Ax1({pos[0], pos[1], pos[2]}, {axis[0], axis[1], axis[2]}), rad(angle));
|
|
||||||
BRepBuilderAPI_Transform builder {p_shape, transform, true};
|
|
||||||
|
|
||||||
return builder.Shape();
|
};
|
||||||
}
|
|
||||||
|
|
||||||
Shape scale(const vec3& center, double scale)
|
|
||||||
{
|
|
||||||
gp_Trsf transform;
|
|
||||||
transform.SetScale(gp_Pnt(center[0], center[1], center[2]), scale);
|
|
||||||
BRepBuilderAPI_Transform builder {p_shape, transform, true};
|
|
||||||
|
|
||||||
return builder.Shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
Shape& scaled(const vec3& center, double scale)
|
|
||||||
{
|
|
||||||
p_shape = this->scale(center, scale).p_shape;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Shape extrude(const vec3& dir, double length)
|
|
||||||
{
|
|
||||||
BRepPrimAPI_MakePrism builder {p_shape, length * gp_Vec(dir[0], dir[1], dir[2]), true};
|
|
||||||
|
|
||||||
for (auto& type : { Type::Solid, Type::Face, Type::Edge, Type::Vertex })
|
|
||||||
for (TopExp_Explorer exp {p_shape, static_cast<TopAbs_ShapeEnum>(type)}; exp.More(); exp.Next())
|
|
||||||
{
|
|
||||||
auto data = metadata[Shape(exp.Current())];
|
|
||||||
|
|
||||||
for (auto& mod : builder.Generated(exp.Current()))
|
|
||||||
metadata[Shape(mod)].merge(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.Shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
Shape fillet(darray<Shape> edges, double radius)
|
|
||||||
{
|
|
||||||
BRepFilletAPI_MakeFillet fillet {p_shape};
|
|
||||||
|
|
||||||
for (auto& e : edges)
|
|
||||||
fillet.Add(radius, TopoDS::Edge(e.p_shape));
|
|
||||||
fillet.Build();
|
|
||||||
|
|
||||||
return fillet.Shape();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Friend functions
|
|
||||||
|
|
||||||
friend
|
|
||||||
double distance(const Shape& lhs, const Shape& rhs)
|
double distance(const Shape& lhs, const Shape& rhs)
|
||||||
{
|
{
|
||||||
return BRepExtrema_DistShapeShape(lhs.tshape(), rhs.tshape()).Value();
|
return BRepExtrema_DistShapeShape(lhs.tshape(), rhs.tshape()).Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend
|
|
||||||
Shape fuse(const Shape& lhs, const Shape& rhs)
|
|
||||||
{
|
|
||||||
BRepAlgoAPI_Fuse builder {lhs.p_shape, rhs.p_shape};
|
|
||||||
builder.Build();
|
|
||||||
return Shape {builder.Shape()};
|
|
||||||
}
|
|
||||||
|
|
||||||
friend
|
|
||||||
Shape fuse(const darray<Shape>& args, const darray<Shape>& tools)
|
|
||||||
{
|
|
||||||
BRepAlgoAPI_Fuse builder;
|
|
||||||
NCollection_List<TopoDS_Shape> args_, tools_;
|
|
||||||
for (auto& arg : args)
|
|
||||||
args_.Append(arg.tshape());
|
|
||||||
for (auto& tool : tools)
|
|
||||||
tools_.Append(tool.tshape());
|
|
||||||
builder.SetArguments(args_);
|
|
||||||
builder.SetTools(tools_);
|
|
||||||
builder.Build();
|
|
||||||
return Shape {builder.Shape()};
|
|
||||||
}
|
|
||||||
|
|
||||||
friend
|
|
||||||
Shape common(const Shape& lhs, const Shape& rhs)
|
|
||||||
{
|
|
||||||
BRepAlgoAPI_Common builder {lhs.p_shape, rhs.p_shape};
|
|
||||||
builder.Build();
|
|
||||||
return Shape {builder.Shape()};
|
|
||||||
}
|
|
||||||
|
|
||||||
friend
|
|
||||||
Shape cut(const Shape& lhs, const Shape& rhs)
|
|
||||||
{
|
|
||||||
BRepAlgoAPI_Cut builder {lhs.p_shape, rhs.p_shape};
|
|
||||||
builder.Build();
|
|
||||||
for (auto& type : { Type::Solid, Type::Face, Type::Edge, Type::Vertex })
|
|
||||||
for (TopExp_Explorer exp {lhs.p_shape, static_cast<TopAbs_ShapeEnum>(type)}; exp.More(); exp.Next())
|
|
||||||
{
|
|
||||||
auto data = metadata[Shape(exp.Current())];
|
|
||||||
|
|
||||||
for (auto& mod : builder.Modified(exp.Current()))
|
|
||||||
metadata[Shape(mod)].merge(data);
|
|
||||||
}
|
|
||||||
for (auto& type : { Type::Solid, Type::Face, Type::Edge, Type::Vertex })
|
|
||||||
for (TopExp_Explorer exp {rhs.p_shape, static_cast<TopAbs_ShapeEnum>(type)}; exp.More(); exp.Next())
|
|
||||||
{
|
|
||||||
auto data = metadata[Shape(exp.Current())];
|
|
||||||
|
|
||||||
for (auto& mod : builder.Modified(exp.Current()))
|
|
||||||
metadata[Shape(mod)].merge(data);
|
|
||||||
}
|
|
||||||
return Shape {builder.Shape()};
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// Global functions: primitives
|
|
||||||
|
|
||||||
Shape sphere(vec3 center, double radius);
|
|
||||||
|
|
||||||
Shape box(vec3 corner, double dx, double dy, double dz);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
13
source/hpr/csg/shell.hpp
Executable file → Normal file
13
source/hpr/csg/shell.hpp
Executable file → Normal file
@ -22,7 +22,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
Shell(const darray<Shape>& faces) :
|
Shell(const darray<Face>& faces) :
|
||||||
Shape {}
|
Shape {}
|
||||||
{
|
{
|
||||||
BRep_Builder builder;
|
BRep_Builder builder;
|
||||||
@ -38,7 +38,6 @@ public:
|
|||||||
default:
|
default:
|
||||||
throw std::runtime_error("");
|
throw std::runtime_error("");
|
||||||
}
|
}
|
||||||
|
|
||||||
p_shape = shell;
|
p_shape = shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,16 @@ public:
|
|||||||
{
|
{
|
||||||
return TopoDS::Shell(p_shape);
|
return TopoDS::Shell(p_shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
Shell sew(const darray<Face>& faces)
|
||||||
|
{
|
||||||
|
BRepBuilderAPI_Sewing builder;
|
||||||
|
for (const auto& face : faces)
|
||||||
|
builder.Add(face.tshape());
|
||||||
|
builder.Perform();
|
||||||
|
return Shell(builder.SewedShape());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
9
source/hpr/csg/solid.hpp
Executable file → Normal file
9
source/hpr/csg/solid.hpp
Executable file → Normal file
@ -25,13 +25,14 @@ namespace hpr::csg
|
|||||||
Solid(const Shell& shell) :
|
Solid(const Shell& shell) :
|
||||||
Shape {}
|
Shape {}
|
||||||
{
|
{
|
||||||
BRep_Builder builder;
|
/*BRep_Builder builder;
|
||||||
TopoDS_Solid solid;
|
TopoDS_Solid solid;
|
||||||
|
|
||||||
builder.MakeSolid(solid);
|
builder.MakeSolid(solid);
|
||||||
builder.Add(solid, shell.tcast());
|
builder.Add(solid, shell.tcast());*/
|
||||||
|
BRepBuilderAPI_MakeSolid builder {shell.tcast()};
|
||||||
p_shape = solid;
|
//p_shape = solid;
|
||||||
|
p_shape = builder.Shape();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
0
source/hpr/csg/surface.hpp
Executable file → Normal file
0
source/hpr/csg/surface.hpp
Executable file → Normal file
0
source/hpr/csg/tests/csg-test.cpp
Executable file → Normal file
0
source/hpr/csg/tests/csg-test.cpp
Executable file → Normal file
69
source/hpr/csg/transformation.hpp
Normal file
69
source/hpr/csg/transformation.hpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hpr/csg/shape.hpp>
|
||||||
|
#include <hpr/csg/compound.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace hpr::csg
|
||||||
|
{
|
||||||
|
|
||||||
|
Shape scale(const Shape& shape, const vec3& center, double scale)
|
||||||
|
{
|
||||||
|
gp_Trsf transform;
|
||||||
|
transform.SetScale(gp_Pnt(center[0], center[1], center[2]), scale);
|
||||||
|
BRepBuilderAPI_Transform builder {shape.tshape(), transform, true};
|
||||||
|
|
||||||
|
return builder.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape scale(const Shape& shape, const vec3& scale)
|
||||||
|
{
|
||||||
|
gp_GTrsf transform;
|
||||||
|
transform.SetValue(1,1, scale[0]);
|
||||||
|
transform.SetValue(2,2, scale[1]);
|
||||||
|
transform.SetValue(3,3, scale[2]);
|
||||||
|
BRepBuilderAPI_GTransform builder {shape.tshape(), transform, true};
|
||||||
|
|
||||||
|
return builder.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape translate(const Shape& shape, const vec3& dir)
|
||||||
|
{
|
||||||
|
gp_Trsf transform;
|
||||||
|
transform.SetTranslation(gp_Vec(dir[0], dir[1], dir[2]));
|
||||||
|
BRepBuilderAPI_Transform builder {transform};
|
||||||
|
builder.Perform(shape.tshape(), true);
|
||||||
|
|
||||||
|
return builder.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
Shape rotate(const Shape& shape, const vec3& pos, const vec3& axis, double angle)
|
||||||
|
{
|
||||||
|
gp_Trsf transform;
|
||||||
|
transform.SetRotation(gp_Ax1({pos[0], pos[1], pos[2]}, {axis[0], axis[1], axis[2]}), rad(angle));
|
||||||
|
BRepBuilderAPI_Transform builder {shape.tshape(), transform, true};
|
||||||
|
|
||||||
|
return builder.Shape();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Compound array(const Shape& shape, const vec3& dir, Size count)
|
||||||
|
{
|
||||||
|
darray<Shape> arr;
|
||||||
|
arr.resize(count);
|
||||||
|
for (Size n = 0; n < count; ++n)
|
||||||
|
arr.push(translate(shape, dir * count));
|
||||||
|
return Compound(arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Compound array(const Shape& shape, const vec3& dir1, Size count1, const vec3& dir2, Size count2)
|
||||||
|
{
|
||||||
|
return array(array(shape, dir1, count1), dir2, count2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Compound array(const Shape& shape, const vec3& dir1, Size count1, const vec3& dir2, Size count2, const vec3& dir3, Size count3)
|
||||||
|
{
|
||||||
|
return array(array(shape, dir1, count1, dir2, count2), dir3, count3);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
0
source/hpr/csg/vertex.hpp
Executable file → Normal file
0
source/hpr/csg/vertex.hpp
Executable file → Normal file
2
source/hpr/csg/wire.hpp
Executable file → Normal file
2
source/hpr/csg/wire.hpp
Executable file → Normal file
@ -22,7 +22,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
Wire(const darray<Shape>& edges) :
|
Wire(const darray<Edge>& edges) :
|
||||||
Shape {}
|
Shape {}
|
||||||
{
|
{
|
||||||
BRepBuilderAPI_MakeWire builder;
|
BRepBuilderAPI_MakeWire builder;
|
||||||
|
0
source/hpr/exception.hpp
Executable file → Normal file
0
source/hpr/exception.hpp
Executable file → Normal file
0
source/hpr/geometry.hpp
Executable file → Normal file
0
source/hpr/geometry.hpp
Executable file → Normal file
0
source/hpr/geometry/CMakeLists.txt
Executable file → Normal file
0
source/hpr/geometry/CMakeLists.txt
Executable file → Normal file
0
source/hpr/geometry/polytope.hpp
Executable file → Normal file
0
source/hpr/geometry/polytope.hpp
Executable file → Normal file
0
source/hpr/geometry/tetrahedron.hpp
Executable file → Normal file
0
source/hpr/geometry/tetrahedron.hpp
Executable file → Normal file
0
source/hpr/geometry/triangle.hpp
Executable file → Normal file
0
source/hpr/geometry/triangle.hpp
Executable file → Normal file
0
source/hpr/gpu.hpp
Executable file → Normal file
0
source/hpr/gpu.hpp
Executable file → Normal file
0
source/hpr/gpu/CMakeLists.txt
Executable file → Normal file
0
source/hpr/gpu/CMakeLists.txt
Executable file → Normal file
1
source/hpr/gpu/array_object.hpp
Executable file → Normal file
1
source/hpr/gpu/array_object.hpp
Executable file → Normal file
@ -88,6 +88,7 @@ namespace hpr::gpu
|
|||||||
void destroy()
|
void destroy()
|
||||||
{
|
{
|
||||||
glDeleteVertexArrays(1, &p_index);
|
glDeleteVertexArrays(1, &p_index);
|
||||||
|
p_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void attribPointer(BufferObject& buffer, unsigned int location, int size)
|
void attribPointer(BufferObject& buffer, unsigned int location, int size)
|
||||||
|
1
source/hpr/gpu/buffer_object.hpp
Executable file → Normal file
1
source/hpr/gpu/buffer_object.hpp
Executable file → Normal file
@ -140,6 +140,7 @@ public:
|
|||||||
throw std::runtime_error("Unknown buffer type");
|
throw std::runtime_error("Unknown buffer type");
|
||||||
|
|
||||||
glDeleteBuffers(1, &p_index);
|
glDeleteBuffers(1, &p_index);
|
||||||
|
p_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
0
source/hpr/gpu/camera.hpp
Executable file → Normal file
0
source/hpr/gpu/camera.hpp
Executable file → Normal file
0
source/hpr/gpu/color_buffer.hpp
Executable file → Normal file
0
source/hpr/gpu/color_buffer.hpp
Executable file → Normal file
0
source/hpr/gpu/common.hpp
Executable file → Normal file
0
source/hpr/gpu/common.hpp
Executable file → Normal file
0
source/hpr/gpu/context.hpp
Executable file → Normal file
0
source/hpr/gpu/context.hpp
Executable file → Normal file
0
source/hpr/gpu/cull_face.hpp
Executable file → Normal file
0
source/hpr/gpu/cull_face.hpp
Executable file → Normal file
0
source/hpr/gpu/depth_buffer.hpp
Executable file → Normal file
0
source/hpr/gpu/depth_buffer.hpp
Executable file → Normal file
1
source/hpr/gpu/framebuffer.hpp
Executable file → Normal file
1
source/hpr/gpu/framebuffer.hpp
Executable file → Normal file
@ -139,6 +139,7 @@ public:
|
|||||||
p_texture.destroy();
|
p_texture.destroy();
|
||||||
p_renderbuffer.destroy();
|
p_renderbuffer.destroy();
|
||||||
glDeleteFramebuffers(1, &p_index);
|
glDeleteFramebuffers(1, &p_index);
|
||||||
|
p_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
0
source/hpr/gpu/gpu.cpp
Executable file → Normal file
0
source/hpr/gpu/gpu.cpp
Executable file → Normal file
0
source/hpr/gpu/monitor.hpp
Executable file → Normal file
0
source/hpr/gpu/monitor.hpp
Executable file → Normal file
1
source/hpr/gpu/renderbuffer.hpp
Executable file → Normal file
1
source/hpr/gpu/renderbuffer.hpp
Executable file → Normal file
@ -58,6 +58,7 @@ namespace hpr::gpu
|
|||||||
void destroy()
|
void destroy()
|
||||||
{
|
{
|
||||||
glDeleteRenderbuffers(1, &p_index);
|
glDeleteRenderbuffers(1, &p_index);
|
||||||
|
p_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool valid() const
|
bool valid() const
|
||||||
|
0
source/hpr/gpu/scene.hpp
Executable file → Normal file
0
source/hpr/gpu/scene.hpp
Executable file → Normal file
1
source/hpr/gpu/shader.hpp
Executable file → Normal file
1
source/hpr/gpu/shader.hpp
Executable file → Normal file
@ -123,6 +123,7 @@ public:
|
|||||||
void destroy()
|
void destroy()
|
||||||
{
|
{
|
||||||
glDeleteShader(p_index);
|
glDeleteShader(p_index);
|
||||||
|
p_index = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user