Browse Source

Adding newton skeleton

Panagiotis Christopoulos Charitos 11 years ago
parent
commit
3077d449b4

+ 33 - 0
include/anki/physics/Common.h

@@ -0,0 +1,33 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#ifndef ANKI_PHYSICS_COMMON_H
+#define ANKI_PHYSICS_COMMON_H
+
+#include "anki/util/StdTypes.h"
+#include "anki/util/Enum.h"
+
+namespace anki {
+
+/// @addtogroup physics
+/// @{
+
+/// Material types.
+enum class PhysicsMaterialBit: U16
+{
+	NONE = 0,
+	STATIC_GEOMETRY = 1 << 0,
+	DYNAMIC_GEOMETRY = 1 << 1,
+	RAGDOLL = 1 << 2,
+	PARTICLES = 1 << 3
+};
+ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(PhysicsMaterialBit, inline)
+
+/// @}
+
+} // end namespace anki
+
+#endif
+

+ 28 - 0
include/anki/physics/PhysicsBody.h

@@ -0,0 +1,28 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#ifndef ANKI_PHYSICS_BODY_H
+#define ANKI_PHYSICS_BODY_H
+
+#include "anki/physics/Common.h"
+
+namespace anki {
+
+/// @addtogroup physics
+/// @{
+
+/// Rigid body.
+class Body
+{
+public:
+private:
+	NewtonBody* m_body;
+	Transform m_trf;
+};
+/// @}
+
+} // end namespace anki
+
+#endif

+ 53 - 0
include/anki/physics/PhysicsCollisionShape.h

@@ -0,0 +1,53 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#ifndef ANKI_PHYSICS_PHYSICS_COLLISION_SHAPE_H
+#define ANKI_PHYSICS_PHYSICS_COLLISION_SHAPE_H
+
+#include "anki/physics/Common.h"
+
+namespace anki {
+
+/// @addtogroup physics
+/// @{
+
+/// Standard initializer for all collision shapes.
+struct PhysicsCollisionShapeInitializer
+{
+	PhysicsWorld* m_world = nullptr;
+};
+
+/// The base of all collision shapes.
+class PhysicsCollisionShape
+{
+public:
+	using Initializer = PhysicsCollisionShapeInitializer;
+
+	PhysicsCollisionShape();
+	~PhysicsCollisionShape();
+
+	/// Create sphere.
+	ANKI_USE_RESULT Error createSphere(Initializer& init, F32 radius);
+
+	/// Create box.
+	ANKI_USE_RESULT Error createBox(Initializer& init, const Vec3& extend);
+
+	/// Create convex hull.
+	ANKI_USE_RESULT Error createConvexHull(Initializer& init, 
+		const Vec3* positions, U32 positionsCount, U32 positionsStride);
+
+	/// Create face soup.
+	ANKI_USE_RESULT Error createStaticTriangleSoup(Initializer& init,
+		const Vec3* positions, U32 positionsStride, U16* indices);
+
+private:
+	NewtonCollision* m_shape = nullptr;
+};
+/// @}
+
+} // end namespace anki
+
+#endif
+

+ 1 - 0
include/anki/physics/PhysicsWorld.h

@@ -21,6 +21,7 @@ public:
 	~PhysicsWorld();
 	~PhysicsWorld();
 
 
 private:
 private:
+	NewtonWorld* m_world = nullptr;
 };
 };
 
 
 /// @}
 /// @}

+ 18 - 0
src/physics/PhysicsBody.cpp

@@ -0,0 +1,18 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include "anki/physics/PhysicsBody.h"
+
+namespace anki {
+
+//==============================================================================
+PhysicsBody::PhysicsBody()
+{}
+
+//==============================================================================
+PhysicsBody::~PhysicsBody()
+{}
+
+} // end namespace anki

+ 24 - 0
src/physics/PhysicsCollisionShape.cpp

@@ -0,0 +1,24 @@
+// Copyright (C) 2014, Panagiotis Christopoulos Charitos.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include "anki/physics/PhysicsCollisionShape.cpp"
+
+namespace anki {
+
+//==============================================================================
+PhysicsCollisionShape::PhysicsCollisionShape()
+{}
+
+//==============================================================================
+PhysicsCollisionShape::~PhysicsCollisionShape()
+{
+	if(m_shape)
+	{
+		NewtonDestroyCollision(m_shape);
+	}
+}
+
+} // end namespace anki
+