Просмотр исходного кода

Started work on Colliders and Rigidbodies

BearishSun 10 лет назад
Родитель
Сommit
a60f238c6c

+ 5 - 0
BansheeCore/BansheeCore.vcxproj

@@ -296,6 +296,8 @@
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClInclude Include="Include\BsCollider.h" />
+    <ClInclude Include="Include\BsCollision.h" />
     <ClInclude Include="Include\BsCoreObjectCore.h" />
     <ClInclude Include="Include\BsCoreObjectCore.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsIconUtility.h" />
     <ClInclude Include="Include\BsIconUtility.h" />
@@ -315,6 +317,7 @@
     <ClInclude Include="Include\BsPrefabRTTI.h" />
     <ClInclude Include="Include\BsPrefabRTTI.h" />
     <ClInclude Include="Include\BsPrefabUtility.h" />
     <ClInclude Include="Include\BsPrefabUtility.h" />
     <ClInclude Include="Include\BsRendererMeshData.h" />
     <ClInclude Include="Include\BsRendererMeshData.h" />
+    <ClInclude Include="Include\BsRigidbody.h" />
     <ClInclude Include="Include\BsShaderIncludeRTTI.h" />
     <ClInclude Include="Include\BsShaderIncludeRTTI.h" />
     <ClInclude Include="Include\BsIResourceListener.h" />
     <ClInclude Include="Include\BsIResourceListener.h" />
     <ClInclude Include="Include\BsMaterialParam.h" />
     <ClInclude Include="Include\BsMaterialParam.h" />
@@ -464,6 +467,7 @@
     <ClInclude Include="Include\Win32\BSWin32PlatformData.h" />
     <ClInclude Include="Include\Win32\BSWin32PlatformData.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClCompile Include="Source\BsCollider.cpp" />
     <ClCompile Include="Source\BsCoreObjectCore.cpp" />
     <ClCompile Include="Source\BsCoreObjectCore.cpp" />
     <ClCompile Include="Source\BsCoreThread.cpp" />
     <ClCompile Include="Source\BsCoreThread.cpp" />
     <ClCompile Include="Source\BsHString.cpp" />
     <ClCompile Include="Source\BsHString.cpp" />
@@ -501,6 +505,7 @@
     <ClCompile Include="Source\BsGpuParams.cpp" />
     <ClCompile Include="Source\BsGpuParams.cpp" />
     <ClCompile Include="Source\BsProfilerGPU.cpp" />
     <ClCompile Include="Source\BsProfilerGPU.cpp" />
     <ClCompile Include="Source\BsRendererMeshData.cpp" />
     <ClCompile Include="Source\BsRendererMeshData.cpp" />
+    <ClCompile Include="Source\BsRigidbody.cpp" />
     <ClCompile Include="Source\BsShaderInclude.cpp" />
     <ClCompile Include="Source\BsShaderInclude.cpp" />
     <ClCompile Include="Source\BsGpuProgram.cpp" />
     <ClCompile Include="Source\BsGpuProgram.cpp" />
     <ClCompile Include="Source\BsGpuResourceData.cpp" />
     <ClCompile Include="Source\BsGpuResourceData.cpp" />

+ 15 - 0
BansheeCore/BansheeCore.vcxproj.filters

@@ -599,6 +599,15 @@
     <ClInclude Include="Include\BsPhysicsMaterialRTTI.h">
     <ClInclude Include="Include\BsPhysicsMaterialRTTI.h">
       <Filter>Header Files\RTTI</Filter>
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsCollider.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRigidbody.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCollision.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCoreApplication.cpp">
     <ClCompile Include="Source\BsCoreApplication.cpp">
@@ -940,5 +949,11 @@
     <ClCompile Include="Source\BsPhysicsMaterial.cpp">
     <ClCompile Include="Source\BsPhysicsMaterial.cpp">
       <Filter>Source Files\Physics</Filter>
       <Filter>Source Files\Physics</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsCollider.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRigidbody.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 46 - 0
BansheeCore/Include/BsCollider.h

@@ -0,0 +1,46 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCollision.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT Collider
+	{
+	public:
+		virtual ~Collider();
+
+		virtual void setIsTrigger(bool value) = 0;
+		virtual bool getIsTrigger() const = 0;
+
+		virtual void setRigidbody(const SPtr<Rigidbody>& rigidbody);
+		virtual SPtr<Rigidbody> getRigidbody() const { return mRigidbody; }
+
+		virtual void setMaterial(const HPhysicsMaterial& material);
+		virtual HPhysicsMaterial getMaterial() const { return mMaterial; }
+
+		virtual void setIsActive(bool value);
+		virtual bool getIsActive() const { return mIsActive; }
+
+		virtual void setContactOffset(float value) = 0;
+		virtual float getContactOffset() = 0;
+
+		virtual void setRestOffset(float value) = 0;
+		virtual float getRestOffset() = 0;
+
+		virtual void setLayer(UINT64 layer);
+		virtual UINT64 getLayer() const { return mLayer; }
+
+		Event<void(const CollisionData&)> onCollisionStart;
+		Event<void(const CollisionData&)> onCollisionStay;
+		Event<void(const CollisionData&)> onCollisionEnd;
+	protected:
+		bool mIsActive = true;
+		UINT64 mLayer = 1;
+
+		SPtr<Rigidbody> mRigidbody;
+		HPhysicsMaterial mMaterial;
+	};
+}

+ 23 - 0
BansheeCore/Include/BsCollision.h

@@ -0,0 +1,23 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsVector3.h"
+
+namespace BansheeEngine
+{
+	struct ContactPoint
+	{
+		Vector3 point;
+		Vector3 normal;
+	};
+
+	struct CollisionData
+	{
+		SPtr<Collider> collider;
+		Vector<ContactPoint> contactPoints;
+		Vector3 impulse;
+		Vector3 relativeVelocity;
+	};
+}

+ 4 - 0
BansheeCore/Include/BsPhysics.h

@@ -4,6 +4,8 @@
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 #include "BsModule.h"
 #include "BsModule.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -16,6 +18,8 @@ namespace BansheeEngine
 		virtual void update() = 0;
 		virtual void update() = 0;
 
 
 		virtual SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) = 0;
 		virtual SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) = 0;
+		virtual SPtr<Rigidbody> createRigidbody(const Vector3& position = Vector3::ZERO, 
+			const Quaternion& rotation = Quaternion::IDENTITY) = 0;
 
 
 		void toggleCollision(UINT64 groupA, UINT64 groupB, bool enabled);
 		void toggleCollision(UINT64 groupA, UINT64 groupB, bool enabled);
 		bool isCollisionEnabled(UINT64 groupA, UINT64 groupB) const;
 		bool isCollisionEnabled(UINT64 groupA, UINT64 groupB) const;

+ 33 - 0
BansheeCore/Include/BsRigidbody.h

@@ -0,0 +1,33 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCollision.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT Rigidbody
+	{
+	public:
+		virtual ~Rigidbody();
+
+		// TODO
+
+		virtual void addCollider(Collider* collider);
+		virtual void removeCollider(Collider* collider);
+
+		virtual void setIsActive(bool value);
+		virtual bool getIsActive() const { return mIsActive; }
+
+		static SPtr<Rigidbody> create(const Vector3& position, const Quaternion& rotation);
+
+		Event<void(const CollisionData&)> onCollisionStart;
+		Event<void(const CollisionData&)> onCollisionStay;
+		Event<void(const CollisionData&)> onCollisionEnd;
+	protected:
+		bool mIsActive = true;
+
+		Vector<Collider*> mColliders;
+	};
+}

+ 40 - 0
BansheeCore/Source/BsCollider.cpp

@@ -0,0 +1,40 @@
+#include "BsCollider.h"
+#include "BsRigidbody.h"
+
+namespace BansheeEngine
+{
+	Collider::~Collider()
+	{
+		if (mRigidbody != nullptr)
+			mRigidbody->removeCollider(this);
+	}
+
+	void Collider::setRigidbody(const SPtr<Rigidbody>& rigidbody)
+	{
+		if (mRigidbody == rigidbody)
+			return;
+
+		if (mRigidbody != nullptr)
+			mRigidbody->removeCollider(this);
+
+		mRigidbody = rigidbody;
+
+		if(mRigidbody != nullptr)
+			mRigidbody->addCollider(this);
+	}
+
+	void Collider::setMaterial(const HPhysicsMaterial& material)
+	{
+		mMaterial = material;
+	}
+
+	void Collider::setIsActive(bool value)
+	{
+		mIsActive = value;
+	}
+
+	void Collider::setLayer(UINT64 layer)
+	{
+		mLayer = layer;
+	}
+}

+ 32 - 0
BansheeCore/Source/BsRigidbody.cpp

@@ -0,0 +1,32 @@
+#include "BsRigidbody.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	Rigidbody::~Rigidbody()
+	{
+		// It is assumed that child colliders will keep the parent Rigidbody alive, so we don't need to clear their parents
+	}
+
+	void Rigidbody::addCollider(Collider* collider)
+	{
+		mColliders.push_back(collider);
+	}
+
+	void Rigidbody::removeCollider(Collider* collider)
+	{
+		auto iterFind = std::find(mColliders.begin(), mColliders.end(), collider);
+		if (iterFind != mColliders.end())
+			mColliders.erase(iterFind);
+	}
+
+	void Rigidbody::setIsActive(bool value)
+	{
+		mIsActive = value;
+	}
+
+	SPtr<Rigidbody> Rigidbody::create(const Vector3& position, const Quaternion& rotation)
+	{
+		return gPhysics().createRigidbody(position, rotation);
+	}
+}

+ 2 - 0
BansheeEngine.sln

@@ -87,12 +87,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExampleProject", "ExamplePr
 		{4F05EF0A-B8DE-424B-8848-6ECEE9D99912} = {4F05EF0A-B8DE-424B-8848-6ECEE9D99912}
 		{4F05EF0A-B8DE-424B-8848-6ECEE9D99912} = {4F05EF0A-B8DE-424B-8848-6ECEE9D99912}
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79} = {122B7A22-0C62-4B35-B661-EBF3F394EA79}
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79} = {122B7A22-0C62-4B35-B661-EBF3F394EA79}
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E} = {876EB338-489E-4727-84DA-8CBBF0DA5B5E}
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
 		{CC7F9445-71C9-4559-9976-FF0A64DCB582} = {CC7F9445-71C9-4559-9976-FF0A64DCB582}
 		{1437BB4E-DDB3-4307-AA41-8C035DA3014B} = {1437BB4E-DDB3-4307-AA41-8C035DA3014B}
 		{1437BB4E-DDB3-4307-AA41-8C035DA3014B} = {1437BB4E-DDB3-4307-AA41-8C035DA3014B}
 		{69517850-7050-4A1A-B03F-6DC4498B0340} = {69517850-7050-4A1A-B03F-6DC4498B0340}
 		{69517850-7050-4A1A-B03F-6DC4498B0340} = {69517850-7050-4A1A-B03F-6DC4498B0340}
 		{F58FF869-2EA6-4FFF-AB84-328C531BA9D9} = {F58FF869-2EA6-4FFF-AB84-328C531BA9D9}
 		{F58FF869-2EA6-4FFF-AB84-328C531BA9D9} = {F58FF869-2EA6-4FFF-AB84-328C531BA9D9}
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC} = {08975177-4A13-4EE7-BB21-3BB92FB3F3CC}
 		{08975177-4A13-4EE7-BB21-3BB92FB3F3CC} = {08975177-4A13-4EE7-BB21-3BB92FB3F3CC}
 		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73} = {AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}
 		{AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73} = {AB6C9284-D1CB-4AAD-BA4B-8A9E81AD1A73}
+		{A4865386-A95B-41BE-B016-4674F6B4272E} = {A4865386-A95B-41BE-B016-4674F6B4272E}
 		{07B0C186-5173-46F2-BE26-7E4148BD0CCA} = {07B0C186-5173-46F2-BE26-7E4148BD0CCA}
 		{07B0C186-5173-46F2-BE26-7E4148BD0CCA} = {07B0C186-5173-46F2-BE26-7E4148BD0CCA}
 		{7F449698-73DF-4203-9F31-0877DBF01695} = {7F449698-73DF-4203-9F31-0877DBF01695}
 		{7F449698-73DF-4203-9F31-0877DBF01695} = {7F449698-73DF-4203-9F31-0877DBF01695}
 		{2BA791F1-87F6-4863-A784-D07FF605AC5E} = {2BA791F1-87F6-4863-A784-D07FF605AC5E}
 		{2BA791F1-87F6-4863-A784-D07FF605AC5E} = {2BA791F1-87F6-4863-A784-D07FF605AC5E}

+ 1 - 1
BansheeFBXImporter/Source/BsFBXImporter.cpp

@@ -357,7 +357,7 @@ namespace BansheeEngine
 			Vector<Vector<UINT32>> indicesPerMaterial;
 			Vector<Vector<UINT32>> indicesPerMaterial;
 			for (UINT32 i = 0; i < (UINT32)mesh->indices.size(); i++)
 			for (UINT32 i = 0; i < (UINT32)mesh->indices.size(); i++)
 			{
 			{
-				while (mesh->materials[i] >= indicesPerMaterial.size())
+				while ((UINT32)mesh->materials[i] >= (UINT32)indicesPerMaterial.size())
 					indicesPerMaterial.push_back(Vector<UINT32>());
 					indicesPerMaterial.push_back(Vector<UINT32>());
 
 
 				indicesPerMaterial[mesh->materials[i]].push_back(mesh->indices[i]);
 				indicesPerMaterial[mesh->materials[i]].push_back(mesh->indices[i]);

+ 2 - 0
BansheePhysX/BansheePhysX.vcxproj

@@ -248,11 +248,13 @@
     <ClCompile Include="Source\BsPhysX.cpp" />
     <ClCompile Include="Source\BsPhysX.cpp" />
     <ClCompile Include="Source\BsPhysXMaterial.cpp" />
     <ClCompile Include="Source\BsPhysXMaterial.cpp" />
     <ClCompile Include="Source\BsPhysXPlugin.cpp" />
     <ClCompile Include="Source\BsPhysXPlugin.cpp" />
+    <ClCompile Include="Source\BsPhysXRigidbody.cpp" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsPhysX.h" />
     <ClInclude Include="Include\BsPhysX.h" />
     <ClInclude Include="Include\BsPhysXMaterial.h" />
     <ClInclude Include="Include\BsPhysXMaterial.h" />
     <ClInclude Include="Include\BsPhysXPrerequisites.h" />
     <ClInclude Include="Include\BsPhysXPrerequisites.h" />
+    <ClInclude Include="Include\BsPhysXRigidbody.h" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   <ImportGroup Label="ExtensionTargets">

+ 6 - 0
BansheePhysX/BansheePhysX.vcxproj.filters

@@ -20,6 +20,9 @@
     <ClCompile Include="Source\BsPhysXMaterial.cpp">
     <ClCompile Include="Source\BsPhysXMaterial.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsPhysXRigidbody.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsPhysXPrerequisites.h">
     <ClInclude Include="Include\BsPhysXPrerequisites.h">
@@ -31,5 +34,8 @@
     <ClInclude Include="Include\BsPhysXMaterial.h">
     <ClInclude Include="Include\BsPhysXMaterial.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsPhysXRigidbody.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 3 - 1
BansheePhysX/Include/BsPhysX.h

@@ -17,8 +17,10 @@ namespace BansheeEngine
 		~PhysX();
 		~PhysX();
 
 
 		void update() override;
 		void update() override;
-		SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) override;
 
 
+		SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) override;
+		SPtr<Rigidbody> createRigidbody(const Vector3& position = Vector3::ZERO,
+			const Quaternion& rotation = Quaternion::IDENTITY) override;
 	private:
 	private:
 		float mSimulationStep = 1.0f/60.0f;
 		float mSimulationStep = 1.0f/60.0f;
 		float mLastSimulationTime = 0.0f;
 		float mLastSimulationTime = 0.0f;

+ 36 - 0
BansheePhysX/Include/BsPhysXPrerequisites.h

@@ -3,6 +3,9 @@
 #pragma once
 #pragma once
 
 
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
+#include "foundation\PxVec3.h"
+#include "foundation\PxVec4.h"
+#include "foundation\PxQuat.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -19,4 +22,37 @@ namespace BansheeEngine
 #else
 #else
 #	define BS_PHYSX_EXPORT
 #	define BS_PHYSX_EXPORT
 #endif
 #endif
+
+	class PhysXRigidbody;
+	class PhsyXMaterial;
+
+	inline const physx::PxVec3& toPxVector(const Vector3& input)
+	{
+		return *(physx::PxVec3*)&input;
+	}
+
+	inline const physx::PxVec4& toPxVector(const Vector4& input)
+	{
+		return *(physx::PxVec4*)&input;
+	}
+
+	inline const physx::PxQuat& toPxQuaternion(const Quaternion& input)
+	{
+		return *(physx::PxQuat*)&input;
+	}
+
+	inline const Vector3& fromPxVector(const physx::PxVec3& input)
+	{
+		return *(Vector3*)&input;
+	}
+
+	inline const Vector4& fromPxVector(const physx::PxVec4& input)
+	{
+		return *(Vector4*)&input;
+	}
+
+	inline const Quaternion& fromPxQuaternion(const physx::PxQuat& input)
+	{
+		return *(Quaternion*)&input;
+	}
 }
 }

+ 22 - 0
BansheePhysX/Include/BsPhysXRigidbody.h

@@ -0,0 +1,22 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsRigidbody.h"
+#include "PxPhysics.h"
+
+namespace BansheeEngine
+{
+	class PhysXRigidbody : public Rigidbody
+	{
+	public:
+		PhysXRigidbody(physx::PxPhysics* physx, const Vector3& position, const Quaternion& rotation);
+		~PhysXRigidbody();
+
+		// TODO
+
+	private:
+		physx::PxRigidDynamic* mInternal;
+	};
+}

+ 6 - 5
BansheePhysX/Source/BsPhysX.cpp

@@ -1,6 +1,7 @@
 #include "BsPhysX.h"
 #include "BsPhysX.h"
 #include "PxPhysicsAPI.h"
 #include "PxPhysicsAPI.h"
 #include "BsPhysXMaterial.h"
 #include "BsPhysXMaterial.h"
+#include "BsPhysXRigidbody.h"
 #include "BsTaskScheduler.h"
 #include "BsTaskScheduler.h"
 #include "BsTime.h"
 #include "BsTime.h"
 #include "Bsvector3.h"
 #include "Bsvector3.h"
@@ -150,11 +151,6 @@ namespace BansheeEngine
 		return PxFilterFlags();
 		return PxFilterFlags();
 	}
 	}
 
 
-	PxVec3 toPxVector(Vector3 input)
-	{
-		return PxVec3(input.x, input.y, input.z);
-	}
-
 	static PhysXAllocator gPhysXAllocator;
 	static PhysXAllocator gPhysXAllocator;
 	static PhysXErrorCallback gPhysXErrorHandler;
 	static PhysXErrorCallback gPhysXErrorHandler;
 	static PhysXCPUDispatcher gPhysXCPUDispatcher;
 	static PhysXCPUDispatcher gPhysXCPUDispatcher;
@@ -237,4 +233,9 @@ namespace BansheeEngine
 	{
 	{
 		return bs_shared_ptr_new<PhysXMaterial>(mPhysics, staticFriction, dynamicFriction, restitution);
 		return bs_shared_ptr_new<PhysXMaterial>(mPhysics, staticFriction, dynamicFriction, restitution);
 	}
 	}
+
+	SPtr<Rigidbody> PhysX::createRigidbody(const Vector3& position, const Quaternion& rotation)
+	{
+		return bs_shared_ptr_new<PhysXRigidbody>(mPhysics, position, rotation);
+	}
 }
 }

+ 19 - 0
BansheePhysX/Source/BsPhysXRigidbody.cpp

@@ -0,0 +1,19 @@
+#include "BsPhysXRigidbody.h"
+#include "PxRigidDynamic.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PhysXRigidbody::PhysXRigidbody(PxPhysics* physx, const Vector3& position, const Quaternion& rotation)
+	{
+		PxTransform tfrm(toPxVector(position), toPxQuaternion(rotation));
+
+		mInternal = physx->createRigidDynamic(tfrm);
+	}
+
+	PhysXRigidbody::~PhysXRigidbody()
+	{
+		mInternal->release();
+	}
+}