Rename ChipmunkPhysics2D and JoltPhysics3D to Physics[2D|3D]
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/ChipmunkPhysics2D.hpp>
|
||||
#include <Nazara/Physics2D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Widgets.hpp>
|
||||
@@ -21,14 +21,14 @@ int main(int argc, char* argv[])
|
||||
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
|
||||
resourceDir = "../.." / resourceDir;
|
||||
|
||||
Nz::Application<Nz::Graphics, Nz::ChipmunkPhysics2D> app(argc, argv);
|
||||
Nz::Application<Nz::Graphics, Nz::Physics2D> app(argc, argv);
|
||||
|
||||
auto& windowing = app.AddComponent<Nz::WindowingAppComponent>();
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::EntitySystemAppComponent>();
|
||||
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
Nz::ChipmunkPhysics2DSystem& physSytem = world.AddSystem<Nz::ChipmunkPhysics2DSystem>();
|
||||
Nz::Physics2DSystem& physSytem = world.AddSystem<Nz::Physics2DSystem>();
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
std::string windowTitle = "Physics 2D";
|
||||
@@ -59,9 +59,9 @@ int main(int argc, char* argv[])
|
||||
std::shared_ptr<Nz::MaterialInstance> spriteMaterial = Nz::MaterialInstance::Instantiate(Nz::MaterialType::Phong);
|
||||
spriteMaterial->SetTextureProperty("BaseColorMap", Nz::Texture::LoadFromFile(resourceDir / "box.png", texParams));
|
||||
|
||||
Nz::ChipmunkRigidBody2DComponent::DynamicSettings boxSettings;
|
||||
Nz::RigidBody2DComponent::DynamicSettings boxSettings;
|
||||
boxSettings.mass = 50.f;
|
||||
boxSettings.geom = std::make_shared<Nz::ChipmunkBoxCollider2D>(Nz::Vector2f(32.f, 32.f));
|
||||
boxSettings.geom = std::make_shared<Nz::BoxCollider2D>(Nz::Vector2f(32.f, 32.f));
|
||||
|
||||
std::shared_ptr<Nz::Sprite> boxSprite = std::make_shared<Nz::Sprite>(spriteMaterial);
|
||||
boxSprite->SetSize({ 32.f, 32.f });
|
||||
@@ -76,7 +76,7 @@ int main(int argc, char* argv[])
|
||||
spriteEntity.emplace<Nz::NodeComponent>(Nz::Vector2f(windowSize.x * 0.5f + x * 32.f - 15.f * 32.f, windowSize.y / 2 + y * 48.f));
|
||||
spriteEntity.emplace<Nz::GraphicsComponent>(boxSprite, 1);
|
||||
|
||||
auto& rigidBody = spriteEntity.emplace<Nz::ChipmunkRigidBody2DComponent>(boxSettings);
|
||||
auto& rigidBody = spriteEntity.emplace<Nz::RigidBody2DComponent>(boxSettings);
|
||||
rigidBody.SetFriction(0.9f);
|
||||
//rigidBody.SetElasticity(0.99f);
|
||||
}
|
||||
@@ -102,12 +102,12 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Nz::ChipmunkRigidBody2DComponent::StaticSettings groundSettings;
|
||||
groundSettings.geom = std::make_shared<Nz::ChipmunkBoxCollider2D>(tilemap->GetSize());
|
||||
Nz::RigidBody2DComponent::StaticSettings groundSettings;
|
||||
groundSettings.geom = std::make_shared<Nz::BoxCollider2D>(tilemap->GetSize());
|
||||
|
||||
groundEntity.emplace<Nz::NodeComponent>().SetPosition(windowSize.x * 0.5f, -windowSize.y * 0.2f);
|
||||
groundEntity.emplace<Nz::GraphicsComponent>().AttachRenderable(tilemap, 1);
|
||||
auto& rigidBody = groundEntity.emplace<Nz::ChipmunkRigidBody2DComponent>(groundSettings);
|
||||
auto& rigidBody = groundEntity.emplace<Nz::RigidBody2DComponent>(groundSettings);
|
||||
rigidBody.SetFriction(0.9f);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ int main(int argc, char* argv[])
|
||||
Nz::PidController<Nz::Vector3f> headingController(0.5f, 0.f, 0.05f);
|
||||
Nz::PidController<Nz::Vector3f> upController(1.f, 0.f, 0.1f);
|
||||
|
||||
std::optional<Nz::ChipmunkPivotConstraint2D> grabConstraint;
|
||||
std::optional<Nz::PhysPivotConstraint2D> grabConstraint;
|
||||
NazaraSlot(Nz::WindowEventHandler, OnMouseMoved, grabbedObjectMove);
|
||||
|
||||
Nz::WindowEventHandler& eventHandler = window.GetEventHandler();
|
||||
@@ -139,14 +139,14 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
if (nearestEntity && nearestEntity != groundEntity)
|
||||
{
|
||||
grabConstraint.emplace(nearestEntity.get<Nz::ChipmunkRigidBody2DComponent>(), worldPos);
|
||||
grabConstraint.emplace(nearestEntity.get<Nz::RigidBody2DComponent>(), worldPos);
|
||||
|
||||
grabbedObjectMove.Connect(eventHandler.OnMouseMoved, [&, nearestEntity, viewer](const Nz::WindowEventHandler*, const Nz::WindowEvent::MouseMoveEvent& event)
|
||||
{
|
||||
auto& viewerComponent = viewer.get<Nz::CameraComponent>();
|
||||
Nz::Vector2f worldPos = Nz::Vector2f(viewerComponent.Unproject(Nz::Vector3f(event.x, event.y, 0.f)));
|
||||
|
||||
auto& rigidBody = nearestEntity.get<Nz::ChipmunkRigidBody2DComponent>();
|
||||
auto& rigidBody = nearestEntity.get<Nz::RigidBody2DComponent>();
|
||||
|
||||
grabConstraint->SetFirstAnchor(worldPos);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
target("Physics2DDemo")
|
||||
add_deps("NazaraGraphics", "NazaraChipmunkPhysics2D")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics2D")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/JoltPhysics3D.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
@@ -20,14 +20,14 @@ int main(int argc, char* argv[])
|
||||
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
|
||||
resourceDir = "../.." / resourceDir;
|
||||
|
||||
Nz::Application<Nz::Graphics, Nz::JoltPhysics3D> app(argc, argv);
|
||||
Nz::Application<Nz::Graphics, Nz::Physics3D> app(argc, argv);
|
||||
|
||||
auto& windowing = app.AddComponent<Nz::WindowingAppComponent>();
|
||||
|
||||
auto& ecs = app.AddComponent<Nz::EntitySystemAppComponent>();
|
||||
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
Nz::JoltPhysics3DSystem& physSytem = world.AddSystem<Nz::JoltPhysics3DSystem>();
|
||||
Nz::Physics3DSystem& physSytem = world.AddSystem<Nz::Physics3DSystem>();
|
||||
physSytem.GetPhysWorld().SetGravity(Nz::Vector3f::Zero());
|
||||
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
@@ -101,7 +101,7 @@ int main(int argc, char* argv[])
|
||||
cameraComponent.UpdateClearColor(Nz::Color(0.5f, 0.5f, 0.5f));
|
||||
}
|
||||
|
||||
auto shipCollider = std::make_shared<Nz::JoltConvexHullCollider3D>(vertices, vertexMapper.GetVertexCount());
|
||||
auto shipCollider = std::make_shared<Nz::ConvexHullCollider3D>(vertices, vertexMapper.GetVertexCount());
|
||||
|
||||
std::shared_ptr<Nz::MaterialInstance> colliderMat = Nz::MaterialInstance::Instantiate(Nz::MaterialType::Basic);
|
||||
colliderMat->SetValueProperty("BaseColor", Nz::Color::Green());
|
||||
@@ -139,11 +139,11 @@ int main(int argc, char* argv[])
|
||||
auto& entityNode = playerEntity.emplace<Nz::NodeComponent>();
|
||||
entityNode.SetPosition(Nz::Vector3f(12.5f, 0.f, 25.f));
|
||||
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.geom = shipCollider;
|
||||
settings.mass = 100.f;
|
||||
|
||||
auto& entityPhys = playerEntity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
auto& entityPhys = playerEntity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
entityPhys.SetMass(50.f);
|
||||
entityPhys.SetAngularDamping(0.1f);
|
||||
entityPhys.SetLinearDamping(0.5f);
|
||||
@@ -182,11 +182,11 @@ int main(int argc, char* argv[])
|
||||
entityNode.SetPosition(Nz::Vector3f(x * 2.f, y * 1.5f, z * 2.f));
|
||||
entityNode.SetRotation(Nz::EulerAnglesf(0.f, Nz::TurnAnglef(0.5f), 0.f));
|
||||
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.geom = shipCollider;
|
||||
settings.mass = 100.f;
|
||||
|
||||
auto& entityPhys = entity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
auto& entityPhys = entity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
entityPhys.SetMass(1.f);
|
||||
entityPhys.SetAngularDamping(0.f);
|
||||
entityPhys.SetLinearDamping(0.f);
|
||||
@@ -221,13 +221,13 @@ int main(int argc, char* argv[])
|
||||
showColliders = !showColliders;
|
||||
if (showColliders)
|
||||
{
|
||||
auto view = world.GetRegistry().view<Nz::GraphicsComponent, Nz::JoltRigidBody3DComponent>();
|
||||
auto view = world.GetRegistry().view<Nz::GraphicsComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto [entity, gfxComponent, _] : view.each())
|
||||
gfxComponent.AttachRenderable(colliderModel, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto view = world.GetRegistry().view<Nz::GraphicsComponent, Nz::JoltRigidBody3DComponent>();
|
||||
auto view = world.GetRegistry().view<Nz::GraphicsComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto [entity, gfxComponent, _] : view.each())
|
||||
gfxComponent.DetachRenderable(colliderModel);
|
||||
}
|
||||
@@ -242,11 +242,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
entity.emplace<Nz::NodeComponent>();
|
||||
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.geom = shipCollider;
|
||||
settings.mass = 100.f;
|
||||
|
||||
auto& entityPhys = entity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
auto& entityPhys = entity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
entityPhys.SetMass(1.f);
|
||||
entityPhys.SetAngularDamping(0.f);
|
||||
entityPhys.SetLinearDamping(0.f);
|
||||
@@ -273,7 +273,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
float elapsedTime = deltaTime->AsSeconds();
|
||||
|
||||
auto spaceshipView = world.GetRegistry().view<Nz::NodeComponent, Nz::JoltRigidBody3DComponent>();
|
||||
auto spaceshipView = world.GetRegistry().view<Nz::NodeComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto&& [entity, node, _] : spaceshipView.each())
|
||||
{
|
||||
if (entity == playerEntity)
|
||||
@@ -284,7 +284,7 @@ int main(int argc, char* argv[])
|
||||
world.GetRegistry().destroy(entity);
|
||||
}
|
||||
|
||||
Nz::JoltRigidBody3DComponent& playerShipBody = playerEntity.get<Nz::JoltRigidBody3DComponent>();
|
||||
Nz::RigidBody3DComponent& playerShipBody = playerEntity.get<Nz::RigidBody3DComponent>();
|
||||
Nz::Quaternionf currentRotation = playerShipBody.GetRotation();
|
||||
|
||||
Nz::Vector3f desiredHeading = headingEntity.get<Nz::NodeComponent>().GetForward();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
target("PhysicsDemo")
|
||||
add_deps("NazaraGraphics", "NazaraJoltPhysics3D")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics3D")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Platform/WindowingAppComponent.hpp>
|
||||
#include <Nazara/JoltPhysics3D.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <iostream>
|
||||
@@ -16,7 +16,7 @@ int main(int argc, char* argv[])
|
||||
Nz::Renderer::Config renderConfig;
|
||||
renderConfig.validationLevel = Nz::RenderAPIValidationLevel::None;
|
||||
|
||||
Nz::Application<Nz::Graphics, Nz::JoltPhysics3D> app(argc, argv, renderConfig);
|
||||
Nz::Application<Nz::Graphics, Nz::Physics3D> app(argc, argv, renderConfig);
|
||||
|
||||
auto& windowing = app.AddComponent<Nz::WindowingAppComponent>();
|
||||
Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), "Physics playground");
|
||||
@@ -33,7 +33,7 @@ int main(int argc, char* argv[])
|
||||
auto& ecs = app.AddComponent<Nz::EntitySystemAppComponent>();
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
|
||||
auto& physSystem = world.AddSystem<Nz::JoltPhysics3DSystem>();
|
||||
auto& physSystem = world.AddSystem<Nz::Physics3DSystem>();
|
||||
physSystem.GetPhysWorld().SetMaxStepCount(1);
|
||||
physSystem.GetPhysWorld().SetStepSize(Nz::Time::TickDuration(30));
|
||||
physSystem.GetPhysWorld().SetGravity(Nz::Vector3f::Down() * 9.81f);
|
||||
@@ -81,9 +81,9 @@ int main(int argc, char* argv[])
|
||||
boxColliderEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
float thickness = 1.f;
|
||||
std::shared_ptr<Nz::JoltBoxCollider3D> wallCollider = std::make_shared<Nz::JoltBoxCollider3D>(Nz::Vector3f(BoxDims + thickness * 2.f, BoxDims + thickness * 2.f, thickness));
|
||||
std::shared_ptr<Nz::BoxCollider3D> wallCollider = std::make_shared<Nz::BoxCollider3D>(Nz::Vector3f(BoxDims + thickness * 2.f, BoxDims + thickness * 2.f, thickness));
|
||||
|
||||
std::vector<Nz::JoltCompoundCollider3D::ChildCollider> colliders;
|
||||
std::vector<Nz::CompoundCollider3D::ChildCollider> colliders;
|
||||
for (Nz::Vector3f normal : { Nz::Vector3f::Forward(), Nz::Vector3f::Backward(), Nz::Vector3f::Left(), Nz::Vector3f::Right(), Nz::Vector3f::Up(), Nz::Vector3f::Down() })
|
||||
{
|
||||
auto& colliderEntry = colliders.emplace_back();
|
||||
@@ -92,12 +92,12 @@ int main(int argc, char* argv[])
|
||||
colliderEntry.offset = normal * BoxDims * 0.5f + normal * 0.5f;
|
||||
}
|
||||
|
||||
std::shared_ptr<Nz::JoltCompoundCollider3D> boxCollider = std::make_shared<Nz::JoltCompoundCollider3D>(std::move(colliders));
|
||||
std::shared_ptr<Nz::CompoundCollider3D> boxCollider = std::make_shared<Nz::CompoundCollider3D>(std::move(colliders));
|
||||
|
||||
Nz::JoltRigidBody3D::StaticSettings settings;
|
||||
Nz::RigidBody3D::StaticSettings settings;
|
||||
settings.geom = boxCollider;
|
||||
|
||||
boxColliderEntity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
boxColliderEntity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
|
||||
std::shared_ptr<Nz::Model> colliderModel;
|
||||
{
|
||||
@@ -125,7 +125,7 @@ int main(int argc, char* argv[])
|
||||
float radius = radiusDis(rd);
|
||||
std::uniform_real_distribution<float> positionRandom(-BoxDims * 0.5f + radius, BoxDims * 0.5f - radius);
|
||||
|
||||
std::shared_ptr<Nz::JoltSphereCollider3D> sphereCollider = std::make_shared<Nz::JoltSphereCollider3D>(radius);
|
||||
std::shared_ptr<Nz::SphereCollider3D> sphereCollider = std::make_shared<Nz::SphereCollider3D>(radius);
|
||||
|
||||
entt::handle ballEntity = world.CreateEntity();
|
||||
|
||||
@@ -142,11 +142,11 @@ int main(int argc, char* argv[])
|
||||
ballNode.SetPosition(positionRandom(rd), positionRandom(rd), positionRandom(rd));
|
||||
ballNode.SetScale(radius);
|
||||
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.geom = sphereCollider;
|
||||
settings.mass = 4.f / 3.f * Nz::Pi<float> * Nz::IntegralPow(radius, 3);
|
||||
|
||||
ballEntity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
ballEntity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
}
|
||||
|
||||
std::uniform_real_distribution<float> lengthDis(0.2f, 1.5f);
|
||||
@@ -177,13 +177,13 @@ int main(int argc, char* argv[])
|
||||
ballNode.SetPosition(xRandom(rd), yRandom(rd), zRandom(rd));
|
||||
ballNode.SetScale(width, height, depth);
|
||||
|
||||
std::shared_ptr<Nz::JoltBoxCollider3D> boxCollider = std::make_shared<Nz::JoltBoxCollider3D>(Nz::Vector3f(width, height, depth));
|
||||
std::shared_ptr<Nz::BoxCollider3D> boxCollider = std::make_shared<Nz::BoxCollider3D>(Nz::Vector3f(width, height, depth));
|
||||
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.geom = boxCollider;
|
||||
settings.mass = width * height * depth;
|
||||
|
||||
boxEntity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
boxEntity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
}
|
||||
|
||||
// Spaceships
|
||||
@@ -227,7 +227,7 @@ int main(int argc, char* argv[])
|
||||
Nz::VertexMapper vertexMapper(*spaceshipMesh->GetSubMesh(0));
|
||||
Nz::SparsePtr<Nz::Vector3f> vertices = vertexMapper.GetComponentPtr<Nz::Vector3f>(Nz::VertexComponent::Position);
|
||||
|
||||
auto shipCollider = std::make_shared<Nz::JoltConvexHullCollider3D>(vertices, vertexMapper.GetVertexCount(), 0.1f);
|
||||
auto shipCollider = std::make_shared<Nz::ConvexHullCollider3D>(vertices, vertexMapper.GetVertexCount(), 0.1f);
|
||||
|
||||
std::shared_ptr<Nz::Model> colliderModel;
|
||||
{
|
||||
@@ -249,11 +249,11 @@ int main(int argc, char* argv[])
|
||||
auto& shipNode = shipEntity.emplace<Nz::NodeComponent>();
|
||||
shipNode.SetPosition(xRandom(rd), yRandom(rd), zRandom(rd));
|
||||
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.geom = shipCollider;
|
||||
settings.mass = 100.f;
|
||||
|
||||
shipEntity.emplace<Nz::JoltRigidBody3DComponent>(settings);
|
||||
shipEntity.emplace<Nz::RigidBody3DComponent>(settings);
|
||||
|
||||
//shipEntity.get<Nz::GraphicsComponent>().AttachRenderable(colliderModel);
|
||||
}
|
||||
@@ -304,7 +304,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
struct GrabConstraint
|
||||
{
|
||||
GrabConstraint(Nz::JoltRigidBody3D& body, const Nz::Vector3f& grabPos) :
|
||||
GrabConstraint(Nz::RigidBody3D& body, const Nz::Vector3f& grabPos) :
|
||||
grabBody(body.GetWorld(), BodySettings(grabPos)),
|
||||
grabConstraint(body, grabBody, grabPos)
|
||||
{
|
||||
@@ -324,9 +324,9 @@ int main(int argc, char* argv[])
|
||||
grabBody.SetPosition(pos);
|
||||
}
|
||||
|
||||
static Nz::JoltRigidBody3D::DynamicSettings BodySettings(const Nz::Vector3f& pos)
|
||||
static Nz::RigidBody3D::DynamicSettings BodySettings(const Nz::Vector3f& pos)
|
||||
{
|
||||
Nz::JoltRigidBody3D::DynamicSettings settings;
|
||||
Nz::RigidBody3D::DynamicSettings settings;
|
||||
settings.mass = 0.f; //< kinematic
|
||||
settings.isSimulationEnabled = false;
|
||||
settings.position = pos;
|
||||
@@ -334,8 +334,8 @@ int main(int argc, char* argv[])
|
||||
return settings;
|
||||
}
|
||||
|
||||
Nz::JoltRigidBody3D grabBody;
|
||||
Nz::JoltDistanceConstraint3D grabConstraint;
|
||||
Nz::RigidBody3D grabBody;
|
||||
Nz::PhysDistanceConstraint3D grabConstraint;
|
||||
};
|
||||
|
||||
std::optional<GrabConstraint> grabConstraint;
|
||||
@@ -365,7 +365,7 @@ int main(int argc, char* argv[])
|
||||
Nz::Vector3f from = cameraComponent.Unproject({ float(event.x), float(event.y), 0.f });
|
||||
Nz::Vector3f to = cameraComponent.Unproject({ float(event.x), float(event.y), 1.f });
|
||||
|
||||
Nz::JoltPhysics3DSystem::RaycastHit lastHitInfo;
|
||||
Nz::Physics3DSystem::RaycastHit lastHitInfo;
|
||||
auto callback = [&](const decltype(lastHitInfo)& hitInfo) -> std::optional<float>
|
||||
{
|
||||
if (hitInfo.hitEntity == boxColliderEntity)
|
||||
@@ -386,7 +386,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
if (lastHitInfo.hitBody && lastHitInfo.hitEntity != boxColliderEntity)
|
||||
{
|
||||
grabConstraint.emplace(static_cast<Nz::JoltRigidBody3D&>(*lastHitInfo.hitBody), lastHitInfo.hitPosition);
|
||||
grabConstraint.emplace(static_cast<Nz::RigidBody3D&>(*lastHitInfo.hitBody), lastHitInfo.hitPosition);
|
||||
|
||||
grabbedObjectMove.Connect(eventHandler.OnMouseMoved, [&, distance = Nz::Vector3f::Distance(from, lastHitInfo.hitPosition)](const Nz::WindowEventHandler*, const Nz::WindowEvent::MouseMoveEvent& event)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
target("PhysicsPlayground")
|
||||
add_deps("NazaraGraphics", "NazaraJoltPhysics3D")
|
||||
add_deps("NazaraGraphics", "NazaraPhysics3D")
|
||||
add_packages("entt")
|
||||
add_files("main.cpp")
|
||||
add_defines("NAZARA_ENTT")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Math/PidController.hpp>
|
||||
#include <Nazara/JoltPhysics3D.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <Nazara/Utility/Plugins/AssimpPlugin.hpp>
|
||||
@@ -18,7 +18,7 @@ NAZARA_REQUEST_DEDICATED_GPU()
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Nz::Application<Nz::Graphics, Nz::JoltPhysics3D> app(argc, argv);
|
||||
Nz::Application<Nz::Graphics, Nz::Physics3D> app(argc, argv);
|
||||
|
||||
Nz::PluginLoader loader;
|
||||
Nz::Plugin<Nz::AssimpPlugin> assimp = loader.Load<Nz::AssimpPlugin>();
|
||||
@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
|
||||
auto& world = ecs.AddWorld<Nz::EnttWorld>();
|
||||
world.AddSystem<Nz::SkeletonSystem>();
|
||||
|
||||
Nz::JoltPhysics3DSystem& physSytem = world.AddSystem<Nz::JoltPhysics3DSystem>();
|
||||
Nz::Physics3DSystem& physSytem = world.AddSystem<Nz::Physics3DSystem>();
|
||||
physSytem.GetPhysWorld().SetGravity(Nz::Vector3f::Zero());
|
||||
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>();
|
||||
|
||||
@@ -51,7 +51,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
|
||||
|
||||
std::optional<Nz::JoltCharacter> character;
|
||||
std::optional<Nz::PhysCharacter3D> character;
|
||||
|
||||
entt::handle playerEntity = world.CreateEntity();
|
||||
entt::handle playerRotation = world.CreateEntity();
|
||||
@@ -60,12 +60,12 @@ int main(int argc, char* argv[])
|
||||
auto& playerNode = playerEntity.emplace<Nz::NodeComponent>();
|
||||
playerNode.SetPosition(0.f, 1.8f, 1.f);
|
||||
|
||||
auto playerCollider = std::make_shared<Nz::JoltBoxCollider3D>(Nz::Vector3f(0.2f, 1.8f, 0.2f));
|
||||
auto playerCollider = std::make_shared<Nz::BoxCollider3D>(Nz::Vector3f(0.2f, 1.8f, 0.2f));
|
||||
|
||||
//auto& playerBody = playerEntity.emplace<Nz::JoltRigidBody3DComponent>(physSytem.CreateRigidBody(playerCollider));
|
||||
//auto& playerBody = playerEntity.emplace<Nz::RigidBody3DComponent>(physSytem.CreateRigidBody(playerCollider));
|
||||
//playerBody.SetMass(42.f);
|
||||
|
||||
Nz::JoltCharacter::Settings characterSettings;
|
||||
Nz::PhysCharacter3D::Settings characterSettings;
|
||||
characterSettings.collider = playerCollider;
|
||||
characterSettings.position = Nz::Vector3f::Up() * 5.f;
|
||||
|
||||
@@ -363,13 +363,13 @@ int main(int argc, char* argv[])
|
||||
|
||||
floorEntity.emplace<Nz::NodeComponent>();
|
||||
|
||||
auto floorCollider = std::make_shared<Nz::JoltBoxCollider3D>(Nz::Vector3f(planeSize.x, 1.f, planeSize.y));
|
||||
auto translatedFloorCollider = std::make_shared<Nz::JoltTranslatedRotatedCollider3D>(std::move(floorCollider), Nz::Vector3f::Down() * 0.5f);
|
||||
auto floorCollider = std::make_shared<Nz::BoxCollider3D>(Nz::Vector3f(planeSize.x, 1.f, planeSize.y));
|
||||
auto translatedFloorCollider = std::make_shared<Nz::TranslatedRotatedCollider3D>(std::move(floorCollider), Nz::Vector3f::Down() * 0.5f);
|
||||
|
||||
Nz::JoltRigidBody3D::StaticSettings floorSettings;
|
||||
Nz::RigidBody3D::StaticSettings floorSettings;
|
||||
floorSettings.geom = translatedFloorCollider;
|
||||
|
||||
floorEntity.emplace<Nz::JoltRigidBody3DComponent>(floorSettings);
|
||||
floorEntity.emplace<Nz::RigidBody3DComponent>(floorSettings);
|
||||
|
||||
std::shared_ptr<Nz::GraphicalMesh> boxMeshGfx = Nz::GraphicalMesh::Build(Nz::Primitive::Box(Nz::Vector3f(0.5f, 0.5f, 0.5f)), meshPrimitiveParams);
|
||||
|
||||
@@ -529,7 +529,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
float updateTime = deltaTime->AsSeconds();
|
||||
|
||||
//auto& playerBody = playerEntity.get<Nz::JoltRigidBody3DComponent>();
|
||||
//auto& playerBody = playerEntity.get<Nz::RigidBody3DComponent>();
|
||||
//playerBody.SetAngularDamping(std::numeric_limits<float>::max());
|
||||
|
||||
Nz::Vector3f velocity = character->GetLinearVelocity();
|
||||
@@ -596,7 +596,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
//renderBuffer->Fill(skeletalBufferMem.data(), 0, skeletalBufferMem.size());
|
||||
|
||||
/*auto spaceshipView = registry.view<Nz::NodeComponent, Nz::JoltRigidBody3DComponent>();
|
||||
/*auto spaceshipView = registry.view<Nz::NodeComponent, Nz::RigidBody3DComponent>();
|
||||
for (auto&& [entity, node, _] : spaceshipView.each())
|
||||
{
|
||||
if (entity == playerEntity)
|
||||
@@ -607,7 +607,7 @@ int main(int argc, char* argv[])
|
||||
registry.destroy(entity);
|
||||
}
|
||||
|
||||
Nz::JoltRigidBody3DComponent& playerShipBody = registry.get<Nz::JoltRigidBody3DComponent>(playerEntity);
|
||||
Nz::RigidBody3DComponent& playerShipBody = registry.get<Nz::RigidBody3DComponent>(playerEntity);
|
||||
Nz::Quaternionf currentRotation = playerShipBody.GetRotation();
|
||||
|
||||
Nz::Vector3f desiredHeading = registry.get<Nz::NodeComponent>(headingEntity).GetForward();
|
||||
|
||||
@@ -5,7 +5,7 @@ end
|
||||
target("Showcase")
|
||||
set_group("Examples")
|
||||
set_kind("binary")
|
||||
add_deps("NazaraAudio", "NazaraGraphics", "NazaraChipmunkPhysics2D", "NazaraJoltPhysics3D", "NazaraWidgets")
|
||||
add_deps("NazaraAudio", "NazaraGraphics", "NazaraPhysics2D", "NazaraPhysics3D", "NazaraWidgets")
|
||||
if has_config("embed_plugins", "static") then
|
||||
add_deps("PluginAssimp")
|
||||
else
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Network.hpp>
|
||||
#include <Nazara/ChipmunkPhysics2D.hpp>
|
||||
#include <Nazara/Physics3D.hpp>
|
||||
#include <Nazara/Physics2D.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
#include <iostream>
|
||||
@@ -11,7 +12,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
// This "example" has only one purpose: Giving an empty project for you to test whatever you want
|
||||
// If you wish to have multiple test projects, you only have to copy/paste this directory and change the name in the xmake.lua
|
||||
Nz::Application<Nz::Audio, Nz::Core, Nz::Graphics, Nz::Network, Nz::ChipmunkPhysics2D, Nz::Renderer, Nz::Utility> app(argc, argv);
|
||||
Nz::Application<Nz::Audio, Nz::Core, Nz::Graphics, Nz::Network, Nz::Physics2D, Nz::Physics3D, Nz::Renderer, Nz::Utility> app(argc, argv);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
target("Tut00_EmptyProject")
|
||||
add_deps("NazaraAudio", "NazaraGraphics", "NazaraNetwork", "NazaraChipmunkPhysics2D", "NazaraRenderer", "NazaraUtility")
|
||||
add_deps("NazaraAudio", "NazaraGraphics", "NazaraNetwork", "NazaraPhysics2D", "NazaraPhysics3D", "NazaraRenderer", "NazaraUtility")
|
||||
add_files("main.cpp")
|
||||
|
||||
Reference in New Issue
Block a user