This commit is contained in:
ninja
2025-12-15 23:22:33 +08:00
parent 019570564b
commit 8782765fbc
809 changed files with 118753 additions and 18289 deletions

View File

@@ -0,0 +1,72 @@
/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#include "bounding_box.h"
namespace utils
{
namespace geometry
{
void BoundingBox::reset()
{
min = glm::vec3(std::numeric_limits<float>::max());
max = glm::vec3(std::numeric_limits<float>::lowest());
}
void BoundingBox::add_point(const glm::vec3& point)
{
min.x = std::min(min.x, point.x);
min.y = std::min(min.y, point.y);
min.z = std::min(min.z, point.z);
max.x = std::max(max.x, point.x);
max.y = std::max(max.y, point.y);
max.z = std::max(max.z, point.z);
};
void BoundingBox::add_box(const BoundingBox& box)
{
add_point(box.min);
add_point(box.max);
};
BoundingBox BoundingBox::transform(const glm::mat4& mat) const
{
glm::vec3 trsf_min = glm::vec3(mat * glm::vec4(min, 1.));
glm::vec3 trsf_max = glm::vec3(mat * glm::vec4(max, 1.));
BoundingBox new_box;
new_box.add_point(trsf_min);
new_box.add_point(trsf_max);
return new_box;
};
void BoundingBox::add_boxes(const BoundingBox& box, const std::vector<glm::mat4>& mat4s)
{
for (const auto& mat : mat4s)
{
add_box(box.transform(mat));
}
};
glm::vec3 BoundingBox::diagonal() const
{
return max - min;
}
glm::vec3 BoundingBox::center() const
{
return ( max + min ) / 2.f;
}
double BoundingBox::size_max() const
{
double x = fabs(max.x - min.x);
double y = fabs(max.y - min.y);
double z = fabs(max.z - min.z);
if (x > y)
return x > z ? x : z;
else
return y > z ? y : z;
}
}
}

View File

@@ -0,0 +1,40 @@
/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#ifndef BOUNDING_BOX_H
#define BOUNDING_BOX_H
#include <vector>
#include <glm/vec3.hpp>
#include <glm/mat4x4.hpp>
namespace utils
{
namespace geometry
{
struct BoundingBox
{
glm::vec3 min = glm::vec3(std::numeric_limits<float>::max());
glm::vec3 max = glm::vec3(std::numeric_limits<float>::lowest());
void reset();
void add_point(const glm::vec3& point);
void add_box(const BoundingBox& box);
BoundingBox transform(const glm::mat4& mat) const;
void add_boxes(const BoundingBox& box, const std::vector<glm::mat4>& mat4s);
glm::vec3 diagonal() const;
glm::vec3 center() const;
double size_max() const;
};
}
}
#endif // BOUNDING_BOX_H

View File

@@ -0,0 +1,38 @@
/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <vector>
#include "properties.h"
#include "bounding_box.h"
namespace utils
{
namespace geometry
{
struct Vertex
{
glm::vec3 position;
glm::vec3 normal;
};
struct BufferData
{
std::vector<Vertex> vertices;
std::vector<unsigned int> indices;
BoundingBox mesh_box;
properties::style::Graphics graphics;
};
}
}
#endif // GEOMETRY_H

View File

@@ -0,0 +1,30 @@
/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#include "properties.h"
namespace utils
{
namespace properties
{
namespace style
{
bool Graphics::has_transparency() const
{
if (type == Type::RGBA)
return rgba[3] != 1;
if (type == Type::MATERIAL)
return material.ambient[3] != 1;
return false;
}
}
}
}

View File

@@ -0,0 +1,63 @@
/***********************************************************************************************************************
*
* Copyright (c) 2010 - 2025 by Tech Soft 3D, Inc.
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
* scope and manner of such use.
*
***********************************************************************************************************************/
#ifndef PROPERTIES_H
#define PROPERTIES_H
#include <glm/vec4.hpp>
namespace utils
{
namespace properties
{
constexpr unsigned int screen_width = 1200;
constexpr unsigned int screen_height = 800;
namespace style
{
constexpr glm::vec4 default_rgba = glm::vec4(0.7f);
struct Material {
glm::vec4 ambient;
glm::vec4 diffuse;
glm::vec4 specular;
glm::vec4 emissive;
float shininess;
};
constexpr Material default_material = {
glm::vec4(0.25f, 0.25f, 0.25f, 1.f),
glm::vec4(0.40f, 0.40f, 0.40f, 1.f),
glm::vec4(0.5f, 0.5f, 0.5f, 1.f),
glm::vec4(0.f, 0.f, 0.f, 1.f),
5.f
};
struct Graphics
{
enum Type
{
UNDEF = 0,
RGBA,
MATERIAL,
TEXTURE
};
int id = -1;
Type type = Type::UNDEF;
glm::vec4 rgba;
Material material;
bool has_transparency() const;
};
}
}
}
#endif // PROPERTIES_H