diff --git a/README.md b/README.md index e777fd43785bb80b33ba83175fc5265431fe6fbf..10af74566eafdaec7c78e8ab5a22a2b3faf1bcc6 100644 --- a/README.md +++ b/README.md @@ -23,23 +23,25 @@ Detailed build process: Most dependencies will be used via submodules but for example Vulkan needs to be installed correctly depending on your platform. So please setup your environment properly. -| Name of dependency | Used as submodule | -|-----------------------------------|---| -| [Vulkan](https://www.vulkan.org/) | ⌠| -| [Vulkan-Headers](https://github.com/KhronosGroup/Vulkan-Headers) | ✅ | -| [Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp) | ✅ | -| [GLFW](https://www.glfw.org/) | ✅ | -| [SPIRV-CROSS](https://github.com/KhronosGroup/SPIRV-Cross) | ✅ | +| Name of dependency | Used as submodule | +|-----------------------------------------------------------------------------------|---| +| [Vulkan](https://www.vulkan.org/) | ⌠| +| [Vulkan-Headers](https://github.com/KhronosGroup/Vulkan-Headers) | ✅ | +| [Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp) | ✅ | +| [GLFW](https://www.glfw.org/) | ✅ | +| [SPIRV-CROSS](https://github.com/KhronosGroup/SPIRV-Cross) | ✅ | | [VulkanMemoryAllocator-Hpp](https://github.com/malte-v/VulkanMemoryAllocator-Hpp) | ✅ | ### Modules (optional): The following modules will be provided in this repository and they will automatically be builded together with the framework if used. You can configure/adjust the build using CMake if necessary. + - [Algorithm](modules/algorithm/README.md) - [Asset-Loader](modules/asset_loader/README.md) - [Camera](modules/asset_loader/README.md) - [GUI](modules/gui/README.md) - [Effects](modules/effects/README.md) + - [Geometry](modules/geometry/README.md) - [Material](modules/material/README.md) - [Meshlet](modules/meshlet/README.md) - [Scene](modules/scene/README.md) diff --git a/modules/geometry/include/vkcv/geometry/Circular.hpp b/modules/geometry/include/vkcv/geometry/Circular.hpp index 7e55b774e7d8f589f277913d49df6c90eb577af3..09165f9d8e984144bd9c2e21e8cfbbd2d32d1010 100644 --- a/modules/geometry/include/vkcv/geometry/Circular.hpp +++ b/modules/geometry/include/vkcv/geometry/Circular.hpp @@ -9,30 +9,97 @@ namespace vkcv::geometry { * @{ */ + /** + * A basic class to provide attributes for circular geometry. + */ class Circular { private: + /** + * Radius of the circular part of the geometry. + */ float m_radius; + + /** + * Resolution in case of generating the geometry in a + * discrete way. + */ size_t m_resolution; public: + /** + * Constructor creating circular geometry by a given + * radius and a resolution also provides a default. + * + * @param[in] radius Radius of the circular geometry + * @param[in] resoltion Resolution of the circular geometry + */ explicit Circular(float radius, size_t resoltion = 10); + /** + * Copy-constructor of a circular geometry. + * + * @param[in] other Other circular geometry + */ Circular(const Circular& other) = default; + + /** + * Move-constructor of a circular geometry. + * + * @param[in] other Other circular geometry + */ Circular(Circular&& other) = default; + /** + * Destructor of a circular geometry. + */ ~Circular() = default; + /** + * Copy-operator of a circular geometry. + * + * @param[in] other Other circular geometry + * @return Reference to this circular geometry + */ Circular& operator=(const Circular& other) = default; + + /** + * Move-operator of a circular geometry. + * + * @param[in] other Other circular geometry + * @return Reference to this circular geometry + */ Circular& operator=(Circular&& other) = default; + /** + * Return the radius of the circular part of the geometry. + * + * @return Radius of the circular geometry + */ [[nodiscard]] float getRadius() const; + /** + * Set the radius of the circular part of the geometry. + * + * @param[in] radius Radius of the circular geometry + */ void setRadius(float radius); + /** + * Return the resolution of the geometry for discrete + * generation. + * + * @return Resolution of the circular geometry + */ [[nodiscard]] size_t getResolution() const; + /** + * Set the resolution of the geometry for any discrete + * generation. + * + * @param[in] resolution Resolution of the circular geometry + */ void setResolution(size_t resolution); }; diff --git a/modules/geometry/include/vkcv/geometry/Cuboid.hpp b/modules/geometry/include/vkcv/geometry/Cuboid.hpp index efcf533106161365336d91192c2e3605743169c9..411152513eb6a4c5d7c368c1defa70258ff9ac9c 100644 --- a/modules/geometry/include/vkcv/geometry/Cuboid.hpp +++ b/modules/geometry/include/vkcv/geometry/Cuboid.hpp @@ -9,31 +9,110 @@ namespace vkcv::geometry { * @{ */ + /** + * A class to use geometry in form of a cuboid. + */ class Cuboid : public Volume { private: + /** + * Size of the cuboid in 3D-space. + */ glm::vec3 m_size; public: + /** + * Constructor creating cuboid by a given position + * and size as 3D vectors. + * + * @param[in] position Position of the cuboid as 3D vector + * @param[in] size Size of the cuboid as 3D vector + */ Cuboid(const glm::vec3& position, const glm::vec3& size); + /** + * Constructor creating cube by a given position + * as 3D vector and uniform size. + * + * @param[in] position Position of the cube as 3D vector + * @param[in] size Uniform size of the cube + */ Cuboid(const glm::vec3& position, float size); + /** + * Copy-constructor of a cuboid. + * + * @param[in] other Other cuboid + */ Cuboid(const Cuboid& other) = default; + + /** + * Move-constructor of a cuboid. + * + * @param[in] other Other cuboid + */ Cuboid(Cuboid&& other) = default; + /** + * Destructor of a cuboid. + */ ~Cuboid() = default; + /** + * Copy-operator of a cuboid. + * + * @param[in] other Other cuboid + * @return Reference to this cuboid + */ Cuboid& operator=(const Cuboid& other) = default; + + /** + * Move-operator of a cuboid. + * + * @param[in] other Other cuboid + * @return Reference to this cuboid + */ Cuboid& operator=(Cuboid&& other) = default; + /** + * Return the size of a cuboid as 3D vector. + * + * @return Size of the cuboid as 3D vector + */ [[nodiscard]] const glm::vec3& getSize() const; + /** + * Set the size of a cuboid to a specific + * 3D vector. + * + * @param[in] position Size as 3D vector + */ void setSize(const glm::vec3& size); + /** + * Returns the signed distance from a point to the closest + * surface of the cuboid. + * + * The result is negative if the point is contained by the + * cuboid. + * + * @param[in] point Point as 3D vector + * @return Signed distance from point to surface + */ [[nodiscard]] float distanceTo(const glm::vec3& point) override; + /** + * Generates a vertex data structure, which can be + * used for rendering via draw calls, containing + * the cuboid in a discrete form. + * + * The vertex data will store positions, normals and + * UV-coordinates as vertex attributes. + * + * @param[in,out] core Core instance + * @return Vertex data with generated geometry + */ [[nodiscard]] VertexData generateVertexData(Core& core) const override; diff --git a/modules/geometry/include/vkcv/geometry/Cylinder.hpp b/modules/geometry/include/vkcv/geometry/Cylinder.hpp index 8fa9cc32d2049760ead396b99dab23c5d006d37e..fe6ccc74b9ade02b4a8b7bc530557315aceb3703 100644 --- a/modules/geometry/include/vkcv/geometry/Cylinder.hpp +++ b/modules/geometry/include/vkcv/geometry/Cylinder.hpp @@ -10,29 +10,101 @@ namespace vkcv::geometry { * @{ */ + /** + * A class to use geometry in form of a cylinder. + */ class Cylinder : public Volume, public Circular { private: + /** + * Height of the cylinder (Y-axis) + */ float m_height; public: + /** + * Constructor creating cylinder by a given position + * as 3D vector, a given height and a radius. + * + * @param[in] position Position of the cylinder as 3D vector + * @param[in] height Height of the cylinder + * @param[in] radius Radius of the cylinder + */ Cylinder(const glm::vec3& position, float height, float radius); + /** + * Copy-constructor of a cylinder. + * + * @param[in] other Other cylinder + */ Cylinder(const Cylinder& other) = default; + + /** + * Move-constructor of a cylinder. + * + * @param[in] other Other cylinder + */ Cylinder(Cylinder&& other) = default; + /** + * Destructor of a cylinder. + */ ~Cylinder() = default; + /** + * Copy-operator of a cylinder. + * + * @param[in] other Other cylinder + * @return Reference to this cylinder + */ Cylinder& operator=(const Cylinder& other) = default; + + /** + * Move-operator of a cylinder. + * + * @param[in] other Other cylinder + * @return Reference to this cylinder + */ Cylinder& operator=(Cylinder&& other) = default; + /** + * Return the height of the cylinder. + * + * @return Height of the cylinder + */ [[nodiscard]] float getHeight() const; + /** + * Set the height of the cylinder. + * + * @param[in] height Height of the cylinder + */ void setHeight(float height); + /** + * Returns the signed distance from a point to the closest + * surface of the cylinder. + * + * The result is negative if the point is contained by the + * cylinder. + * + * @param[in] point Point as 3D vector + * @return Signed distance from point to surface + */ [[nodiscard]] float distanceTo(const glm::vec3& point) override; + /** + * Generates a vertex data structure, which can be + * used for rendering via draw calls, containing + * the cylinder in a discrete form. + * + * The vertex data will store positions, normals and + * UV-coordinates as vertex attributes. + * + * @param[in,out] core Core instance + * @return Vertex data with generated geometry + */ [[nodiscard]] VertexData generateVertexData(Core& core) const override; diff --git a/modules/geometry/include/vkcv/geometry/Geometry.hpp b/modules/geometry/include/vkcv/geometry/Geometry.hpp index f46f835c64a694f88b321ea4c0d39a5c5431e34a..7924dfa570c510bddab6e0003a17ed7602290d0d 100644 --- a/modules/geometry/include/vkcv/geometry/Geometry.hpp +++ b/modules/geometry/include/vkcv/geometry/Geometry.hpp @@ -14,26 +14,87 @@ namespace vkcv::geometry { * @{ */ + /** + * A basic class to provide attributes for any kind of geometry. + */ class Geometry { private: + /** + * Position of the geometry in 3D-coordinates. + */ glm::vec3 m_position; public: + /** + * Constructor creating geometry by a given position + * as 3D vector. + * + * @param[in] position Position of the geometry as 3D vector + */ explicit Geometry(const glm::vec3& position); + /** + * Copy-constructor of a geometry. + * + * @param[in] other Other geometry + */ Geometry(const Geometry& other) = default; + + /** + * Move-constructor of a geometry. + * + * @param[in] other Other geometry + */ Geometry(Geometry&& other) = default; + /** + * Destructor of a geometry. + */ ~Geometry() = default; + /** + * Copy-operator of a geometry. + * + * @param[in] other Other geometry + * @return Reference to this geometry + */ Geometry& operator=(const Geometry& other) = default; + + /** + * Move-operator of a geometry. + * + * @param[in] other Other geometry + * @return Reference to this geometry + */ Geometry& operator=(Geometry&& other) = default; + /** + * Return the position of a geometry as 3D vector. + * + * @return Position of the geometry as 3D vector + */ [[nodiscard]] const glm::vec3& getPosition() const; + /** + * Set the position of a geometry to a specific + * 3D vector. + * + * @param[in] position Position as 3D vector + */ void setPosition(const glm::vec3& position); + /** + * Generates a vertex data structure, which can be + * used for rendering via draw calls, containing + * the geometry in a discrete form. + * + * The vertex data will store positions, normals and + * UV-coordinates as vertex attributes. + * + * @param[in,out] core Core instance + * @return Vertex data with generated geometry + */ [[nodiscard]] virtual VertexData generateVertexData(Core& core) const = 0; diff --git a/modules/geometry/include/vkcv/geometry/Sphere.hpp b/modules/geometry/include/vkcv/geometry/Sphere.hpp index 1c854a27fd34d1b8d56e160b68cf99c65248160b..173d1f157dfd4e3987e278a1516dc08ba2f7cf9b 100644 --- a/modules/geometry/include/vkcv/geometry/Sphere.hpp +++ b/modules/geometry/include/vkcv/geometry/Sphere.hpp @@ -10,24 +10,79 @@ namespace vkcv::geometry { * @{ */ + /** + * A class to use geometry in form of a sphere. + */ class Sphere : public Volume, public Circular { - private: - float m_radius; - public: + /** + * Constructor creating sphere by a given position + * as 3D vector and a radius. + * + * @param[in] position Position of the sphere as 3D vector + * @param[in] radius Radius of the sphere + */ Sphere(const glm::vec3& position, float radius); - + + /** + * Copy-constructor of a sphere. + * + * @param[in] other Other sphere + */ Sphere(const Sphere& other) = default; + + /** + * Move-constructor of a sphere. + * + * @param[in] other Other sphere + */ Sphere(Sphere&& other) = default; - + + /** + * Destructor of a sphere. + */ ~Sphere() = default; + /** + * Copy-operator of a sphere. + * + * @param[in] other Other sphere + * @return Reference to this sphere + */ Sphere& operator=(const Sphere& other) = default; + + /** + * Move-operator of a sphere. + * + * @param[in] other Other sphere + * @return Reference to this sphere + */ Sphere& operator=(Sphere&& other) = default; + /** + * Returns the signed distance from a point to the closest + * surface of the sphere. + * + * The result is negative if the point is contained by the + * sphere. + * + * @param[in] point Point as 3D vector + * @return Signed distance from point to surface + */ [[nodiscard]] float distanceTo(const glm::vec3& point) override; + /** + * Generates a vertex data structure, which can be + * used for rendering via draw calls, containing + * the sphere in a discrete form. + * + * The vertex data will store positions, normals and + * UV-coordinates as vertex attributes. + * + * @param[in,out] core Core instance + * @return Vertex data with generated geometry + */ [[nodiscard]] VertexData generateVertexData(Core& core) const override; diff --git a/modules/geometry/include/vkcv/geometry/Teapot.hpp b/modules/geometry/include/vkcv/geometry/Teapot.hpp index 6aa09710344ad737c61e1870d744d1c96d843bd9..ef0f973dee8a617573cf91274afc51f4a499b5f0 100644 --- a/modules/geometry/include/vkcv/geometry/Teapot.hpp +++ b/modules/geometry/include/vkcv/geometry/Teapot.hpp @@ -9,26 +9,87 @@ namespace vkcv::geometry { * @{ */ + /** + * A class to use geometry in form of a teapot. + */ class Teapot : public Geometry { private: + /** + * Uniform scale of the teapot. + */ float m_scale; public: + /** + * Constructor creating teapot by a given position + * as 3D vector and uniform scale. + * + * @param[in] position Position of the teapot as 3D vector + * @param[in] scale Uniform scale of the teapot + */ explicit Teapot(const glm::vec3& position, float scale); + /** + * Copy-constructor of a teapot. + * + * @param[in] other Other teapot + */ Teapot(const Teapot& other) = default; + + /** + * Move-constructor of a teapot. + * + * @param[in] other Other teapot + */ Teapot(Teapot&& other) = default; + /** + * Destructor of a teapot. + */ ~Teapot() = default; + /** + * Copy-operator of a teapot. + * + * @param[in] other Other teapot + * @return Reference to this teapot + */ Teapot& operator=(const Teapot& other) = default; + + /** + * Move-operator of a teapot. + * + * @param[in] other Other teapot + * @return Reference to this teapot + */ Teapot& operator=(Teapot&& other) = default; + /** + * Return the uniform scale of a teapot. + * + * @return Uniform scale of the teapot + */ [[nodiscard]] float getScale() const; + /** + * Set the uniform scale of a teapot. + * + * @param scale Uniform scale + */ void setScale(float scale); + /** + * Generates a vertex data structure, which can be + * used for rendering via draw calls, containing + * the teapot in a discrete form. + * + * The vertex data will store positions, normals and + * UV-coordinates as vertex attributes. + * + * @param[in,out] core Core instance + * @return Vertex data with generated geometry + */ [[nodiscard]] VertexData generateVertexData(Core& core) const override; diff --git a/modules/geometry/include/vkcv/geometry/Volume.hpp b/modules/geometry/include/vkcv/geometry/Volume.hpp index b4ba66c6d99494e56b750143d2b59134f55d9124..5705b6687492f4425e7ac0dfd060a9575606704a 100644 --- a/modules/geometry/include/vkcv/geometry/Volume.hpp +++ b/modules/geometry/include/vkcv/geometry/Volume.hpp @@ -9,22 +9,75 @@ namespace vkcv::geometry { * @{ */ + /** + * A basic class to provide functions for any volumetric geometry. + */ class Volume : public Geometry { private: public: + /** + * Constructor creating volumetric geometry by a given + * position as 3D vector. + * + * @param[in] position Position of the geometry as 3D vector + */ explicit Volume(const glm::vec3& position); + /** + * Copy-constructor of a volumetric geometry. + * + * @param[in] other Other volumetric geometry + */ Volume(const Volume& other) = default; + + /** + * Move-constructor of a volumetric geometry. + * + * @param[in] other Other volumetric geometry + */ Volume(Volume&& other) = default; + /** + * Destructor of a volumetric geometry. + */ ~Volume() = default; + /** + * Copy-operator of a volumetric geometry. + * + * @param[in] other Other volumetric geometry + * @return Reference to this volumetric geometry + */ Volume& operator=(const Volume& other) = default; + + /** + * Move-operator of a volumetric geometry. + * + * @param[in] other Other volumetric geometry + * @return Reference to this volumetric geometry + */ Volume& operator=(Volume&& other) = default; + /** + * Returns the signed distance from a point to the closest + * surface of the volumetric geometry. + * + * The result is negative if the point is contained by the + * volumetric geometry. + * + * @param[in] point Point as 3D vector + * @return Signed distance from point to surface + */ [[nodiscard]] virtual float distanceTo(const glm::vec3& point) = 0; + /** + * Returns as boolean value whether a point is contained + * by a volumetric geometry. + * + * @param[in] point Point as 3D vector + * @return true if the point is contained, other false. + */ [[nodiscard]] bool contains(const glm::vec3& point);