Move SDK include and source to base
This commit is contained in:
58
include/NazaraSDK/Systems/DebugSystem.hpp
Normal file
58
include/NazaraSDK/Systems/DebugSystem.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_SYSTEMS_DEBUGSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_DEBUGSYSTEM_HPP
|
||||
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
#include <NazaraSDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API DebugSystem : public System<DebugSystem>
|
||||
{
|
||||
public:
|
||||
DebugSystem();
|
||||
~DebugSystem() = default;
|
||||
|
||||
void EnableDepthBuffer(bool enable);
|
||||
|
||||
inline bool IsDepthBufferEnabled() const;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
Nz::InstancedRenderableRef GenerateBox(Nz::Boxf box);
|
||||
Nz::InstancedRenderableRef GenerateCollision2DMesh(Entity* entity, Nz::Vector3f* offset);
|
||||
Nz::InstancedRenderableRef GenerateCollision3DMesh(Entity* entity);
|
||||
|
||||
std::pair<Nz::IndexBufferRef, Nz::VertexBufferRef> GetBoxMesh();
|
||||
Nz::MaterialRef GetCollisionMaterial();
|
||||
Nz::MaterialRef GetGlobalAABBMaterial();
|
||||
Nz::MaterialRef GetLocalAABBMaterial();
|
||||
Nz::MaterialRef GetOBBMaterial();
|
||||
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
Nz::MaterialRef m_globalAabbMaterial;
|
||||
Nz::MaterialRef m_localAabbMaterial;
|
||||
Nz::MaterialRef m_collisionMaterial;
|
||||
Nz::MaterialRef m_obbMaterial;
|
||||
Nz::IndexBufferRef m_boxMeshIndexBuffer;
|
||||
Nz::VertexBufferRef m_boxMeshVertexBuffer;
|
||||
bool m_isDepthBufferEnabled;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/DebugSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_DEBUGSYSTEM_HPP
|
||||
#endif // NDK_SERVER
|
||||
13
include/NazaraSDK/Systems/DebugSystem.inl
Normal file
13
include/NazaraSDK/Systems/DebugSystem.inl
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NazaraSDK/Systems/DebugSystem.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline bool DebugSystem::IsDepthBufferEnabled() const
|
||||
{
|
||||
return m_isDepthBufferEnabled;
|
||||
}
|
||||
}
|
||||
29
include/NazaraSDK/Systems/LifetimeSystem.hpp
Normal file
29
include/NazaraSDK/Systems/LifetimeSystem.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_LIFETIMESYSTEM_HPP
|
||||
#define NDK_SYSTEMS_LIFETIMESYSTEM_HPP
|
||||
|
||||
#include <NazaraSDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API LifetimeSystem : public System<LifetimeSystem>
|
||||
{
|
||||
public:
|
||||
LifetimeSystem();
|
||||
~LifetimeSystem() = default;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/LifetimeSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_LIFETIMESYSTEM_HPP
|
||||
3
include/NazaraSDK/Systems/LifetimeSystem.inl
Normal file
3
include/NazaraSDK/Systems/LifetimeSystem.inl
Normal file
@@ -0,0 +1,3 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
31
include/NazaraSDK/Systems/ListenerSystem.hpp
Normal file
31
include/NazaraSDK/Systems/ListenerSystem.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_SYSTEMS_LISTENERSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_LISTENERSYSTEM_HPP
|
||||
|
||||
#include <NazaraSDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API ListenerSystem : public System<ListenerSystem>
|
||||
{
|
||||
public:
|
||||
ListenerSystem();
|
||||
~ListenerSystem() = default;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/ListenerSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_LISTENERSYSTEM_HPP
|
||||
#endif // NDK_SERVER
|
||||
3
include/NazaraSDK/Systems/ListenerSystem.inl
Normal file
3
include/NazaraSDK/Systems/ListenerSystem.inl
Normal file
@@ -0,0 +1,3 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
31
include/NazaraSDK/Systems/ParticleSystem.hpp
Normal file
31
include/NazaraSDK/Systems/ParticleSystem.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP
|
||||
#define NDK_SYSTEMS_PARTICLESYSTEM_HPP
|
||||
|
||||
#include <NazaraSDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API ParticleSystem : public System<ParticleSystem>
|
||||
{
|
||||
public:
|
||||
ParticleSystem();
|
||||
~ParticleSystem() = default;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/ParticleSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP
|
||||
#endif // NDK_SERVER
|
||||
3
include/NazaraSDK/Systems/ParticleSystem.inl
Normal file
3
include/NazaraSDK/Systems/ParticleSystem.inl
Normal file
@@ -0,0 +1,3 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
132
include/NazaraSDK/Systems/PhysicsSystem2D.hpp
Normal file
132
include/NazaraSDK/Systems/PhysicsSystem2D.hpp
Normal file
@@ -0,0 +1,132 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP
|
||||
#define NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP
|
||||
|
||||
#include <Nazara/Physics2D/PhysWorld2D.hpp>
|
||||
#include <NazaraSDK/EntityList.hpp>
|
||||
#include <NazaraSDK/System.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API PhysicsSystem2D : public System<PhysicsSystem2D>
|
||||
{
|
||||
friend class CollisionComponent2D;
|
||||
friend class PhysicsComponent2D;
|
||||
|
||||
using ContactEndCallback = std::function<void(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
||||
using ContactPreSolveCallback = std::function<bool(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
||||
using ContactPostSolveCallback = std::function<void(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
||||
using ContactStartCallback = std::function<bool(PhysicsSystem2D& world, Nz::Arbiter2D& arbiter, const EntityHandle& bodyA, const EntityHandle& bodyB, void* userdata)>;
|
||||
|
||||
using DebugDrawCircleCallback = std::function<void(const Nz::Vector2f& origin, const Nz::RadianAnglef& rotation, float radius, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
||||
using DebugDrawDotCallback = std::function<void(const Nz::Vector2f& origin, float radius, Nz::Color color, void* userdata)>;
|
||||
using DebugDrawPolygonCallback = std::function<void(const Nz::Vector2f* vertices, std::size_t vertexCount, float radius, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
||||
using DebugDrawSegmentCallback = std::function<void(const Nz::Vector2f& first, const Nz::Vector2f& second, Nz::Color color, void* userdata)>;
|
||||
using DebugDrawTickSegmentCallback = std::function<void(const Nz::Vector2f& first, const Nz::Vector2f& second, float thickness, Nz::Color outlineColor, Nz::Color fillColor, void* userdata)>;
|
||||
using DebugDrawGetColorCallback = std::function<Nz::Color(const EntityHandle& body, std::size_t shapeIndex, void* userdata)>;
|
||||
|
||||
public:
|
||||
struct Callback;
|
||||
struct DebugDrawOptions;
|
||||
struct NearestQueryResult;
|
||||
struct RaycastHit;
|
||||
|
||||
PhysicsSystem2D();
|
||||
~PhysicsSystem2D() = default;
|
||||
|
||||
void DebugDraw(const DebugDrawOptions& options, bool drawShapes = true, bool drawConstraints = true, bool drawCollisions = true);
|
||||
|
||||
inline float GetDamping() const;
|
||||
inline Nz::Vector2f GetGravity() const;
|
||||
inline std::size_t GetIterationCount() const;
|
||||
inline std::size_t GetMaxStepCount() const;
|
||||
inline float GetStepSize() const;
|
||||
|
||||
bool NearestBodyQuery(const Nz::Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, EntityHandle* nearestBody = nullptr);
|
||||
bool NearestBodyQuery(const Nz::Vector2f& from, float maxDistance, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, NearestQueryResult* result);
|
||||
|
||||
void RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, const std::function<void(const RaycastHit&)>& callback);
|
||||
bool RaycastQuery(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector<RaycastHit>* hitInfos);
|
||||
bool RaycastQueryFirst(const Nz::Vector2f& from, const Nz::Vector2f& to, float radius, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, RaycastHit* hitInfo = nullptr);
|
||||
|
||||
void RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, const std::function<void(const EntityHandle&)>& callback);
|
||||
void RegionQuery(const Nz::Rectf& boundingBox, Nz::UInt32 collisionGroup, Nz::UInt32 categoryMask, Nz::UInt32 collisionMask, std::vector<EntityHandle>* bodies);
|
||||
|
||||
void RegisterCallbacks(unsigned int collisionId, Callback callbacks);
|
||||
void RegisterCallbacks(unsigned int collisionIdA, unsigned int collisionIdB, Callback callbacks);
|
||||
|
||||
inline void SetDamping(float dampingValue);
|
||||
inline void SetGravity(const Nz::Vector2f& gravity);
|
||||
inline void SetIterationCount(std::size_t iterationCount);
|
||||
inline void SetMaxStepCount(std::size_t maxStepCount);
|
||||
inline void SetSleepTime(float sleepTime);
|
||||
inline void SetStepSize(float stepSize);
|
||||
|
||||
inline void UseSpatialHash(float cellSize, std::size_t entityCount);
|
||||
|
||||
struct Callback
|
||||
{
|
||||
ContactEndCallback endCallback = nullptr;
|
||||
ContactPreSolveCallback preSolveCallback = nullptr;
|
||||
ContactPostSolveCallback postSolveCallback = nullptr;
|
||||
ContactStartCallback startCallback = nullptr;
|
||||
void* userdata;
|
||||
};
|
||||
|
||||
struct DebugDrawOptions
|
||||
{
|
||||
Nz::Color constraintColor;
|
||||
Nz::Color collisionPointColor;
|
||||
Nz::Color shapeOutlineColor;
|
||||
|
||||
DebugDrawCircleCallback circleCallback;
|
||||
DebugDrawGetColorCallback colorCallback;
|
||||
DebugDrawDotCallback dotCallback;
|
||||
DebugDrawPolygonCallback polygonCallback;
|
||||
DebugDrawSegmentCallback segmentCallback;
|
||||
DebugDrawTickSegmentCallback thickSegmentCallback;
|
||||
|
||||
void* userdata;
|
||||
};
|
||||
|
||||
struct NearestQueryResult
|
||||
{
|
||||
EntityHandle nearestBody;
|
||||
Nz::Vector2f closestPoint;
|
||||
Nz::Vector2f fraction;
|
||||
float distance;
|
||||
};
|
||||
|
||||
struct RaycastHit
|
||||
{
|
||||
EntityHandle body;
|
||||
Nz::Vector2f hitPos;
|
||||
Nz::Vector2f hitNormal;
|
||||
float fraction;
|
||||
};
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void CreatePhysWorld() const;
|
||||
const EntityHandle& GetEntityFromBody(const Nz::RigidBody2D& body) const;
|
||||
inline Nz::PhysWorld2D& GetPhysWorld();
|
||||
inline const Nz::PhysWorld2D& GetPhysWorld() const;
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
EntityList m_dynamicObjects;
|
||||
EntityList m_staticObjects;
|
||||
mutable std::unique_ptr<Nz::PhysWorld2D> m_physWorld; ///TODO: std::optional (Should I make a Nz::Optional class?)
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/PhysicsSystem2D.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_PHYSICSSYSTEM2D_HPP
|
||||
94
include/NazaraSDK/Systems/PhysicsSystem2D.inl
Normal file
94
include/NazaraSDK/Systems/PhysicsSystem2D.inl
Normal file
@@ -0,0 +1,94 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NazaraSDK/Systems/PhysicsSystem2D.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline float PhysicsSystem2D::GetDamping() const
|
||||
{
|
||||
return GetPhysWorld().GetDamping();
|
||||
}
|
||||
|
||||
inline Nz::Vector2f PhysicsSystem2D::GetGravity() const
|
||||
{
|
||||
return GetPhysWorld().GetGravity();
|
||||
}
|
||||
|
||||
inline std::size_t PhysicsSystem2D::GetIterationCount() const
|
||||
{
|
||||
return GetPhysWorld().GetIterationCount();
|
||||
}
|
||||
|
||||
inline std::size_t PhysicsSystem2D::GetMaxStepCount() const
|
||||
{
|
||||
return GetPhysWorld().GetMaxStepCount();
|
||||
}
|
||||
|
||||
inline float PhysicsSystem2D::GetStepSize() const
|
||||
{
|
||||
return GetPhysWorld().GetStepSize();
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::SetDamping(float dampingValue)
|
||||
{
|
||||
GetPhysWorld().SetDamping(dampingValue);
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::SetGravity(const Nz::Vector2f& gravity)
|
||||
{
|
||||
GetPhysWorld().SetGravity(gravity);
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::SetIterationCount(std::size_t iterationCount)
|
||||
{
|
||||
GetPhysWorld().SetIterationCount(iterationCount);
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::SetMaxStepCount(std::size_t maxStepCount)
|
||||
{
|
||||
GetPhysWorld().SetMaxStepCount(maxStepCount);
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::SetSleepTime(float sleepTime)
|
||||
{
|
||||
GetPhysWorld().SetSleepTime(sleepTime);
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::SetStepSize(float stepSize)
|
||||
{
|
||||
GetPhysWorld().SetStepSize(stepSize);
|
||||
}
|
||||
|
||||
inline void PhysicsSystem2D::UseSpatialHash(float cellSize, std::size_t entityCount)
|
||||
{
|
||||
GetPhysWorld().UseSpatialHash(cellSize, entityCount);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the physical world
|
||||
* \return A reference to the physical world
|
||||
*/
|
||||
|
||||
inline Nz::PhysWorld2D& PhysicsSystem2D::GetPhysWorld()
|
||||
{
|
||||
if (!m_physWorld)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_physWorld;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the physical world
|
||||
* \return A constant reference to the physical world
|
||||
*/
|
||||
|
||||
inline const Nz::PhysWorld2D& PhysicsSystem2D::GetPhysWorld() const
|
||||
{
|
||||
if (!m_physWorld)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_physWorld;
|
||||
}
|
||||
}
|
||||
41
include/NazaraSDK/Systems/PhysicsSystem3D.hpp
Normal file
41
include/NazaraSDK/Systems/PhysicsSystem3D.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP
|
||||
#define NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP
|
||||
|
||||
#include <Nazara/Physics3D/PhysWorld3D.hpp>
|
||||
#include <NazaraSDK/EntityList.hpp>
|
||||
#include <NazaraSDK/System.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API PhysicsSystem3D : public System<PhysicsSystem3D>
|
||||
{
|
||||
public:
|
||||
PhysicsSystem3D();
|
||||
~PhysicsSystem3D() = default;
|
||||
|
||||
Nz::PhysWorld3D& GetWorld();
|
||||
const Nz::PhysWorld3D& GetWorld() const;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void CreatePhysWorld() const;
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
EntityList m_dynamicObjects;
|
||||
EntityList m_staticObjects;
|
||||
mutable std::unique_ptr<Nz::PhysWorld3D> m_world; ///TODO: std::optional (Should I make a Nz::Optional class?)
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/PhysicsSystem3D.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_PHYSICSSYSTEM3D_HPP
|
||||
32
include/NazaraSDK/Systems/PhysicsSystem3D.inl
Normal file
32
include/NazaraSDK/Systems/PhysicsSystem3D.inl
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Gets the physical world
|
||||
* \return A reference to the physical world
|
||||
*/
|
||||
|
||||
inline Nz::PhysWorld3D& PhysicsSystem3D::GetWorld()
|
||||
{
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_world;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the physical world
|
||||
* \return A constant reference to the physical world
|
||||
*/
|
||||
|
||||
inline const Nz::PhysWorld3D& PhysicsSystem3D::GetWorld() const
|
||||
{
|
||||
if (!m_world)
|
||||
CreatePhysWorld();
|
||||
|
||||
return *m_world;
|
||||
}
|
||||
}
|
||||
85
include/NazaraSDK/Systems/RenderSystem.hpp
Normal file
85
include/NazaraSDK/Systems/RenderSystem.hpp
Normal file
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SERVER
|
||||
#ifndef NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Graphics/CullingList.hpp>
|
||||
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <NazaraSDK/EntityList.hpp>
|
||||
#include <NazaraSDK/System.hpp>
|
||||
#include <NazaraSDK/Components/GraphicsComponent.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class AbstractViewer;
|
||||
|
||||
class NDK_API RenderSystem : public System<RenderSystem>
|
||||
{
|
||||
public:
|
||||
RenderSystem();
|
||||
~RenderSystem() = default;
|
||||
|
||||
template<typename T> T& ChangeRenderTechnique();
|
||||
inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique);
|
||||
|
||||
inline void EnableCulling(bool enable);
|
||||
|
||||
inline const Nz::BackgroundRef& GetDefaultBackground() const;
|
||||
inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;
|
||||
inline Nz::Vector3f GetGlobalForward() const;
|
||||
inline Nz::Vector3f GetGlobalRight() const;
|
||||
inline Nz::Vector3f GetGlobalUp() const;
|
||||
inline Nz::AbstractRenderTechnique& GetRenderTechnique() const;
|
||||
|
||||
inline bool IsCullingEnabled() const;
|
||||
|
||||
inline void SetDefaultBackground(Nz::BackgroundRef background);
|
||||
inline void SetGlobalForward(const Nz::Vector3f& direction);
|
||||
inline void SetGlobalRight(const Nz::Vector3f& direction);
|
||||
inline void SetGlobalUp(const Nz::Vector3f& direction);
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
inline void InvalidateCoordinateSystem();
|
||||
|
||||
void OnEntityRemoved(Entity* entity) override;
|
||||
void OnEntityValidation(Entity* entity, bool justAdded) override;
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
|
||||
void UpdateDynamicReflections();
|
||||
void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer);
|
||||
void UpdatePointSpotShadowMaps();
|
||||
|
||||
std::unique_ptr<Nz::AbstractRenderTechnique> m_renderTechnique;
|
||||
std::vector<GraphicsComponentCullingList::VolumeEntry> m_volumeEntries;
|
||||
std::vector<EntityHandle> m_cameras;
|
||||
EntityList m_drawables;
|
||||
EntityList m_directionalLights;
|
||||
EntityList m_lights;
|
||||
EntityList m_pointSpotLights;
|
||||
EntityList m_particleGroups;
|
||||
EntityList m_realtimeReflected;
|
||||
GraphicsComponentCullingList m_drawableCulling;
|
||||
Nz::BackgroundRef m_background;
|
||||
Nz::DepthRenderTechnique m_shadowTechnique;
|
||||
Nz::Matrix4f m_coordinateSystemMatrix;
|
||||
Nz::RenderTexture m_shadowRT;
|
||||
bool m_coordinateSystemInvalidated;
|
||||
bool m_forceRenderQueueInvalidation;
|
||||
bool m_isCullingEnabled;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/RenderSystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_RENDERSYSTEM_HPP
|
||||
#endif // NDK_SERVER
|
||||
186
include/NazaraSDK/Systems/RenderSystem.inl
Normal file
186
include/NazaraSDK/Systems/RenderSystem.inl
Normal file
@@ -0,0 +1,186 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#include <NazaraSDK/Systems/RenderSystem.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Changes the render technique used for the system
|
||||
* \return A reference to the render technique type
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
inline T& RenderSystem::ChangeRenderTechnique()
|
||||
{
|
||||
static_assert(std::is_base_of<Nz::AbstractRenderTechnique, T>::value, "RenderTechnique is not a subtype of AbstractRenderTechnique");
|
||||
return static_cast<T&>(ChangeRenderTechnique(std::make_unique<T>()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes the render technique used for the system
|
||||
* \return A reference to the abstract render technique
|
||||
*
|
||||
* \param renderTechnique Render technique to use
|
||||
*/
|
||||
|
||||
inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
|
||||
{
|
||||
m_renderTechnique = std::move(renderTechnique);
|
||||
return *m_renderTechnique;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enables/disables object culling
|
||||
*
|
||||
* Object culling is an algorithm used by the render system to detect invisible objects (which will not appear on screen) before they are rendered.
|
||||
* This includes Frustum Culling and potentially Occlusion Culling.
|
||||
*
|
||||
* Disabling this is not recommended, as the system will draw every object in the world which could induce a performance loss.
|
||||
*
|
||||
* \param enable Whether to enable or disable culling
|
||||
*
|
||||
* \see IsCullingEnabled
|
||||
*/
|
||||
inline void RenderSystem::EnableCulling(bool enable)
|
||||
{
|
||||
m_isCullingEnabled = enable;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the background used for rendering
|
||||
* \return A reference to the background
|
||||
*/
|
||||
|
||||
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const
|
||||
{
|
||||
return m_background;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the coordinates matrix used for rendering
|
||||
* \return A constant reference to the matrix of coordinates
|
||||
*/
|
||||
|
||||
inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const
|
||||
{
|
||||
return m_coordinateSystemMatrix;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the "forward" global direction
|
||||
* \return The forward direction, by default, it's -UnitZ() (Right hand coordinates)
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f RenderSystem::GetGlobalForward() const
|
||||
{
|
||||
return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the "right" global direction
|
||||
* \return The right direction, by default, it's UnitX() (Right hand coordinates)
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f RenderSystem::GetGlobalRight() const
|
||||
{
|
||||
return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the "up" global direction
|
||||
* \return The up direction, by default, it's UnitY() (Right hand coordinates)
|
||||
*/
|
||||
|
||||
inline Nz::Vector3f RenderSystem::GetGlobalUp() const
|
||||
{
|
||||
return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the render technique used for rendering
|
||||
* \return A reference to the abstract render technique being used
|
||||
*/
|
||||
|
||||
inline Nz::AbstractRenderTechnique& RenderSystem::GetRenderTechnique() const
|
||||
{
|
||||
return *m_renderTechnique.get();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Query if culling is enabled (enabled by default)
|
||||
* \return True if culling is enabled, false otherwise
|
||||
*
|
||||
* \see EnableCulling
|
||||
*/
|
||||
inline bool RenderSystem::IsCullingEnabled() const
|
||||
{
|
||||
return m_isCullingEnabled;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the background used for rendering
|
||||
*
|
||||
* \param background A reference to the background
|
||||
*/
|
||||
|
||||
inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background)
|
||||
{
|
||||
m_background = std::move(background);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the "forward" global direction
|
||||
*
|
||||
* \param direction The new forward direction
|
||||
*/
|
||||
|
||||
inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction)
|
||||
{
|
||||
m_coordinateSystemMatrix.m13 = -direction.x;
|
||||
m_coordinateSystemMatrix.m23 = -direction.y;
|
||||
m_coordinateSystemMatrix.m33 = -direction.z;
|
||||
|
||||
InvalidateCoordinateSystem();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the "right" global direction
|
||||
*
|
||||
* \param direction The new right direction
|
||||
*/
|
||||
|
||||
inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction)
|
||||
{
|
||||
m_coordinateSystemMatrix.m11 = direction.x;
|
||||
m_coordinateSystemMatrix.m21 = direction.y;
|
||||
m_coordinateSystemMatrix.m31 = direction.z;
|
||||
|
||||
InvalidateCoordinateSystem();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the "up" global direction
|
||||
*
|
||||
* \param direction The new up direction
|
||||
*/
|
||||
|
||||
inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction)
|
||||
{
|
||||
m_coordinateSystemMatrix.m12 = direction.x;
|
||||
m_coordinateSystemMatrix.m22 = direction.y;
|
||||
m_coordinateSystemMatrix.m32 = direction.z;
|
||||
|
||||
InvalidateCoordinateSystem();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Invalidates the matrix of coordinates for the system
|
||||
*/
|
||||
|
||||
inline void RenderSystem::InvalidateCoordinateSystem()
|
||||
{
|
||||
m_coordinateSystemInvalidated = true;
|
||||
}
|
||||
}
|
||||
29
include/NazaraSDK/Systems/VelocitySystem.hpp
Normal file
29
include/NazaraSDK/Systems/VelocitySystem.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NDK_SYSTEMS_VELOCITYSYSTEM_HPP
|
||||
#define NDK_SYSTEMS_VELOCITYSYSTEM_HPP
|
||||
|
||||
#include <NazaraSDK/System.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API VelocitySystem : public System<VelocitySystem>
|
||||
{
|
||||
public:
|
||||
VelocitySystem();
|
||||
~VelocitySystem() = default;
|
||||
|
||||
static SystemIndex systemIndex;
|
||||
|
||||
private:
|
||||
void OnUpdate(float elapsedTime) override;
|
||||
};
|
||||
}
|
||||
|
||||
#include <NazaraSDK/Systems/VelocitySystem.inl>
|
||||
|
||||
#endif // NDK_SYSTEMS_VELOCITYSYSTEM_HPP
|
||||
3
include/NazaraSDK/Systems/VelocitySystem.inl
Normal file
3
include/NazaraSDK/Systems/VelocitySystem.inl
Normal file
@@ -0,0 +1,3 @@
|
||||
// Copyright (C) 2017 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
|
||||
Reference in New Issue
Block a user