Sligthly changed interface & added functionnalities
NzPhysicsWorld has now a public pointer to NewtonWorld NzCollisionShape added, can be constructed from a NzCube for now NzPhysicsEntity added Minor fix + typo
This commit is contained in:
36
include/Nazara/Physics/CollisionShape.hpp
Normal file
36
include/Nazara/Physics/CollisionShape.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef COLLISIONSHAPE_HPP
|
||||
#define COLLISIONSHAPE_HPP
|
||||
|
||||
#include <Newton/Newton.h>
|
||||
#include "PhysicsWorld.hpp"
|
||||
//#include <Nazara/Physics/PhysicsWorld.hpp>
|
||||
|
||||
class NzCollisionShape
|
||||
{
|
||||
public:
|
||||
NzCollisionShape(NzPhysicsWorld* world);
|
||||
~NzCollisionShape();
|
||||
|
||||
void Create(const NzVector3f& cubeSize);
|
||||
//void Create(const NzSpheref& sphere);
|
||||
//void Create(const NzConef& cone);
|
||||
//void Create(const NzMesh& customMesh);
|
||||
void Release();
|
||||
|
||||
bool IsValid();
|
||||
|
||||
NewtonCollision* newtonCollisionShape;
|
||||
|
||||
protected:
|
||||
private:
|
||||
NzPhysicsWorld* m_world;
|
||||
bool m_isCreated;
|
||||
};
|
||||
|
||||
#endif // COLLISIONSHAPE_HPP
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/ModuleName/Config.hpp>
|
||||
#include <Nazara/Physics/Config.hpp>
|
||||
#if NAZARA_PHYSICS_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
|
||||
33
include/Nazara/Physics/PhysicsEntity.hpp
Normal file
33
include/Nazara/Physics/PhysicsEntity.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PHYSICSENTITY_HPP
|
||||
#define PHYSICSENTITY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Newton/Newton.h>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
//#include <Nazara/Physics/CollisionShape.hpp>
|
||||
#include "CollisionShape.hpp"
|
||||
|
||||
class NzPhysicsWorld;
|
||||
|
||||
class NzPhysicsEntity
|
||||
{
|
||||
public:
|
||||
NzPhysicsEntity(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass);
|
||||
virtual void Init();
|
||||
virtual ~NzPhysicsEntity();
|
||||
protected:
|
||||
NzPhysicsWorld* m_world;
|
||||
NewtonBody* m_body;
|
||||
float m_mass;
|
||||
NzMatrix4f m_entityMatrix;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // PHYSICSENTITY_HPP
|
||||
@@ -9,34 +9,43 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Newton/Newton.h>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Cube.hpp>
|
||||
#include "PhysicsSolver.hpp"
|
||||
//#include <Nazara/Physics/PhysicsSolver.hpp>
|
||||
|
||||
enum nzFrictionModel
|
||||
{
|
||||
nzExact,
|
||||
nzAdaptative
|
||||
};
|
||||
|
||||
class NzPhysicsSolver;
|
||||
//TODO : ajouter Axis Aligned Bounding Box
|
||||
|
||||
class NzPhysicsWorld
|
||||
{
|
||||
enum nzFrictionModel
|
||||
{
|
||||
nzExact,
|
||||
nzAdaptative
|
||||
};
|
||||
|
||||
public:
|
||||
NzPhysicsWorld();
|
||||
~NzPhysicsWorld();
|
||||
|
||||
void SetSize(const NzCubef& size);
|
||||
const NzCubef& GetSize() const;
|
||||
|
||||
void SetPhysicsSolver(const NzPhysicsSolver& solver);
|
||||
const NzPhysicsSolver& GetPhysicsSolver() const;
|
||||
|
||||
void SetFrictionModel(nzFrictionModel model);
|
||||
const nzFrictionModel& GetFrictionModel();
|
||||
const nzFrictionModel& GetFrictionModel() const;
|
||||
|
||||
void UpdatePhysics(nzUint64 timestep);
|
||||
void UpdatePhysics(float timestep);
|
||||
|
||||
NewtonWorld* newtonWorld;
|
||||
|
||||
protected:
|
||||
private:
|
||||
NewtonWorld* m_world;
|
||||
NzPhysicsSolver m_solver;
|
||||
nzFrictionModel m_frictionModel;
|
||||
NzCubef m_size;
|
||||
};
|
||||
|
||||
#endif // PHYSICSWORLD_HPP
|
||||
|
||||
23
include/Nazara/Physics/StaticBody.hpp
Normal file
23
include/Nazara/Physics/StaticBody.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq / Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef STATICBODY_HPP
|
||||
#define STATICBODY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
//#include <Nazara/Physics/PhysicsEntity.hpp>
|
||||
#include "PhysicsEntity.hpp"
|
||||
|
||||
class NzStaticBody : public NzPhysicsEntity
|
||||
{
|
||||
public:
|
||||
NzStaticBody(NzPhysicsWorld* world, const NzCollisionShape& shape, const NzVector3f& position, float mass);
|
||||
~NzStaticBody();
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // STATICBODY_HPP
|
||||
Reference in New Issue
Block a user