// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_GEOM_HPP #define NAZARA_GEOM_HPP #include #include #include #include #include #include #include #include #include #include #include ///TODO: CollisionModifier ///TODO: HeightfieldGeom ///TODO: PlaneGeom ? ///TODO: SceneGeom ///TODO: TreeGeom class NzPhysGeom; class NzPhysWorld; struct NewtonCollision; using NzPhysGeomConstListener = NzObjectListenerWrapper; using NzPhysGeomConstRef = NzObjectRef; using NzPhysGeomLibrary = NzObjectLibrary; using NzPhysGeomListener = NzObjectListenerWrapper; using NzPhysGeomRef = NzObjectRef; class NAZARA_API NzPhysGeom : public NzRefCounted, NzNonCopyable { public: NzPhysGeom(NzPhysWorld* physWorld); virtual ~NzPhysGeom(); virtual NzBoxf ComputeAABB(const NzVector3f& translation, const NzQuaternionf& rotation, const NzVector3f& scale) const; virtual NzBoxf ComputeAABB(const NzMatrix4f& offsetMatrix = NzMatrix4f::Identity()) const; virtual void ComputeInertialMatrix(NzVector3f* inertia, NzVector3f* center) const; virtual float ComputeVolume() const; NewtonCollision* GetHandle() const; virtual nzGeomType GetType() const = 0; NzPhysWorld* GetWorld() const; static NzPhysGeomRef Build(NzPhysWorld* physWorld, const NzPrimitiveList& list); protected: NewtonCollision* m_collision; NzPhysWorld* m_world; static NzPhysGeomLibrary::LibraryMap s_library; }; class NzBoxGeom; using NzBoxGeomConstListener = NzObjectListenerWrapper; using NzBoxGeomConstRef = NzObjectRef; using NzBoxGeomListener = NzObjectListenerWrapper; using NzBoxGeomRef = NzObjectRef; class NAZARA_API NzBoxGeom : public NzPhysGeom { public: NzBoxGeom(NzPhysWorld* physWorld, const NzVector3f& lengths, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity()); NzBoxGeom(NzPhysWorld* physWorld, const NzVector3f& lengths, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity()); NzVector3f GetLengths() const; nzGeomType GetType() const override; template static NzBoxGeomRef New(Args&&... args); private: NzVector3f m_lengths; }; class NzCapsuleGeom; using NzCapsuleGeomConstListener = NzObjectListenerWrapper; using NzCapsuleGeomConstRef = NzObjectRef; using NzCapsuleGeomListener = NzObjectListenerWrapper; using NzCapsuleGeomRef = NzObjectRef; class NAZARA_API NzCapsuleGeom : public NzPhysGeom { public: NzCapsuleGeom(NzPhysWorld* physWorld, float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity()); NzCapsuleGeom(NzPhysWorld* physWorld, float length, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity()); float GetLength() const; float GetRadius() const; nzGeomType GetType() const override; template static NzCapsuleGeomRef New(Args&&... args); private: float m_length; float m_radius; }; class NzCompoundGeom; using NzCompoundGeomConstListener = NzObjectListenerWrapper; using NzCompoundGeomConstRef = NzObjectRef; using NzCompoundGeomListener = NzObjectListenerWrapper; using NzCompoundGeomRef = NzObjectRef; class NAZARA_API NzCompoundGeom : public NzPhysGeom { public: NzCompoundGeom(NzPhysWorld* physWorld, NzPhysGeom** geoms, unsigned int geomCount); const std::vector& GetGeoms() const; nzGeomType GetType() const override; template static NzCompoundGeomRef New(Args&&... args); private: std::vector m_geoms; }; class NzConeGeom; using NzConeGeomConstListener = NzObjectListenerWrapper; using NzConeGeomConstRef = NzObjectRef; using NzConeGeomListener = NzObjectListenerWrapper; using NzConeGeomRef = NzObjectRef; class NAZARA_API NzConeGeom : public NzPhysGeom { public: NzConeGeom(NzPhysWorld* physWorld, float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity()); NzConeGeom(NzPhysWorld* physWorld, float length, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity()); float GetLength() const; float GetRadius() const; nzGeomType GetType() const override; template static NzConeGeomRef New(Args&&... args); private: float m_length; float m_radius; }; class NzConvexHullGeom; using NzConvexHullGeomConstListener = NzObjectListenerWrapper; using NzConvexHullGeomConstRef = NzObjectRef; using NzConvexHullGeomListener = NzObjectListenerWrapper; using NzConvexHullGeomRef = NzObjectRef; class NAZARA_API NzConvexHullGeom : public NzPhysGeom { public: NzConvexHullGeom(NzPhysWorld* physWorld, const void* vertices, unsigned int vertexCount, unsigned int stride = sizeof(NzVector3f), float tolerance = 0.002f, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity()); NzConvexHullGeom(NzPhysWorld* physWorld, const void* vertices, unsigned int vertexCount, unsigned int stride, float tolerance, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity()); nzGeomType GetType() const override; template static NzConvexHullGeomRef New(Args&&... args); }; class NzCylinderGeom; using NzCylinderGeomConstListener = NzObjectListenerWrapper; using NzCylinderGeomConstRef = NzObjectRef; using NzCylinderGeomListener = NzObjectListenerWrapper; using NzCylinderGeomRef = NzObjectRef; class NAZARA_API NzCylinderGeom : public NzPhysGeom { public: NzCylinderGeom(NzPhysWorld* physWorld, float length, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity()); NzCylinderGeom(NzPhysWorld* physWorld, float length, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity()); float GetLength() const; float GetRadius() const; nzGeomType GetType() const override; template static NzCylinderGeomRef New(Args&&... args); private: float m_length; float m_radius; }; class NzNullGeom; using NzNullGeomConstListener = NzObjectListenerWrapper; using NzNullGeomConstRef = NzObjectRef; using NzNullGeomListener = NzObjectListenerWrapper; using NzNullGeomRef = NzObjectRef; class NAZARA_API NzNullGeom : public NzPhysGeom { public: NzNullGeom(NzPhysWorld* physWorld); nzGeomType GetType() const override; template static NzNullGeomRef New(Args&&... args); }; class NzSphereGeom; using NzSphereGeomConstListener = NzObjectListenerWrapper; using NzSphereGeomConstRef = NzObjectRef; using NzSphereGeomListener = NzObjectListenerWrapper; using NzSphereGeomRef = NzObjectRef; class NAZARA_API NzSphereGeom : public NzPhysGeom { public: NzSphereGeom(NzPhysWorld* physWorld, float radius, const NzMatrix4f& transformMatrix = NzMatrix4f::Identity()); NzSphereGeom(NzPhysWorld* physWorld, float radius, const NzVector3f& translation, const NzQuaternionf& rotation = NzQuaternionf::Identity()); NzVector3f GetRadius() const; nzGeomType GetType() const override; template static NzSphereGeomRef New(Args&&... args); private: NzVector3f m_radius; }; #include #endif // NAZARA_PHYSWORLD_HPP