Implement Geometric Class Definitions

This commit is contained in:
2024-01-25 19:09:48 -05:00
parent 56077b7c86
commit 4152b0d2aa
13 changed files with 87 additions and 85 deletions

View File

@@ -48,7 +48,12 @@ add_library(J3ML SHARED ${J3ML_SRC}
src/J3ML/Geometry/Plane.cpp
src/J3ML/Geometry/Sphere.cpp
src/J3ML/Geometry/Frustum.cpp
src/J3ML/Geometry/OBB.cpp)
src/J3ML/Geometry/OBB.cpp
src/J3ML/Geometry/Ray.cpp
src/J3ML/Geometry/Capsule.cpp
src/J3ML/Geometry/TriangleMesh.cpp
src/J3ML/Geometry/QuadTree.cpp
src/J3ML/Geometry/LineSegment.cpp)
set_target_properties(J3ML PROPERTIES LINKER_LANGUAGE CXX)
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})

View File

@@ -13,65 +13,16 @@ namespace Geometry {
Vector2 B;
};
class Rectangle; //AABB2D;
class Rectangle;
class OBB2D;
class Line2D;
class Ray2D;
class Triangle2D;
class Polygon2D;
class Sphere;
class LineSegment
{
Vector3 A;
Vector3 B;
};
struct IntersectionResult2D {};
bool Intersects2D(LineSegment2D seg, Rectangle rect);
IntersectionResult2D GetIntersection2D(LineSegment2D seg, Rectangle rect);
class OBB;
// A 3D axis-aligned bounding box
// This data structure can be used to represent coarse bounds of objects, in situations where detailed triangle-level
// computations can be avoided. In physics systems, bounding boxes are used as an efficient early-out test for geometry
// intersection queries.
// the 'Axis-aligned' part in the name means that the local axes of this bounding box are restricted to align with the
// axes of the world space coordinate system. This makes computation involving AABB's very fast, since AABB's cannot
// be arbitrarily oriented in the space with respect to each other.
// If you need to represent a box in 3D space with arbitrary orientation, see the class OBB. */
class Capsule;
class Line;
class Ray
{
Vector3 Origin;
Vector3 Direction;
};
class Camera {
public:
Vector3 Position;
Vector3 Front;
Vector3 Right;
Vector3 Up;
};
class Polygon;
class Polyhedron;
class QuadTree;
class OctTree;
class Triangle;
class TriangleMesh;
}

View File

@@ -1,8 +1,27 @@
//
// Created by dawsh on 1/25/24.
//
#pragma once
#ifndef J3ML_CAPSULE_H
#define J3ML_CAPSULE_H
#include "LineSegment.h"
#include <J3ML/LinearAlgebra/Vector3.h>
#endif //J3ML_CAPSULE_H
namespace Geometry
{
using namespace LinearAlgebra;
class Capsule
{
// Specifies the two inner points of this capsule
LineSegment l;
// Specifies the radius of this capsule
float r;
Capsule() {}
Capsule(const LineSegment& endPoints, float radius);
Capsule(const Vector3& bottomPt, const Vector3& topPt, float radius);
bool IsDegenerate()const;
float Height() const;
float Diameter() const;
Vector3 Bottom() const;
Vector3 Center() const;
Vector3 Centroid() const;
Vector3 ExtremePoint(const Vector3& direction);
};
}

View File

@@ -1,8 +1,10 @@
//
// Created by dawsh on 1/25/24.
//
#pragma once
#ifndef J3ML_LINESEGMENT_H
#define J3ML_LINESEGMENT_H
#endif //J3ML_LINESEGMENT_H
namespace Geometry
{
class LineSegment
{
Vector3 A;
Vector3 B;
};
}

View File

@@ -1,8 +1,9 @@
//
// Created by dawsh on 1/25/24.
//
#pragma once
#ifndef J3ML_QUADTREE_H
#define J3ML_QUADTREE_H
namespace Geometry
{
class QuadTree
{
#endif //J3ML_QUADTREE_H
};
}

View File

@@ -2,7 +2,15 @@
// Created by dawsh on 1/25/24.
//
#ifndef J3ML_RAY_H
#define J3ML_RAY_H
#pragma once
#endif //J3ML_RAY_H
#include <J3ML/LinearAlgebra/Vector3.h>
namespace Geometry
{
class Ray
{
Vector3 Origin;
Vector3 Direction;
};
}

View File

@@ -1,8 +1,6 @@
//
// Created by dawsh on 1/25/24.
//
#pragma once
#ifndef J3ML_TRIANGLE_H
#define J3ML_TRIANGLE_H
namespace Geometry
{
#endif //J3ML_TRIANGLE_H
}

View File

@@ -1,8 +1,9 @@
//
// Created by dawsh on 1/25/24.
//
#pragma once
#ifndef J3ML_TRIANGLEMESH_H
#define J3ML_TRIANGLEMESH_H
namespace Geometry
{
class TriangleMesh
{
#endif //J3ML_TRIANGLEMESH_H
};
}

View File

@@ -0,0 +1,6 @@
#include <J3ML/Geometry/Capsule.h>
namespace Geometry
{
}

View File

@@ -0,0 +1,3 @@
//
// Created by dawsh on 1/25/24.
//

View File

@@ -0,0 +1 @@
#include <J3ML/Geometry/QuadTree.h>

View File

@@ -0,0 +1,6 @@
#include <J3ML/Geometry/Ray.h>
namespace Geometry
{
}

View File

@@ -0,0 +1 @@
#include <J3ML/Geometry/TriangleMesh.h>