public ActorHandler(Game game) { foundation = PxFoundation.create(PxVersion.PX_PHYSICS_VERSION, pxAllocatorCallback, new ErrorPhysXHandler()); physics = foundation.createPhysics(PxVersion.PX_PHYSICS_VERSION); this.game = game; CurrentScene = game.SceneSystem.SceneInstance.RootScene; }
public void AddShape(PxPhysics physics, Shapes type, PxMaterial material) { PxShape shape; bool cdn = type == Shapes.Box; if (rigidbody == null) { var t = Entity.Get <TransformComponent>().LocalMatrix; var Matrix = new PxMat44(new PxVec4(t.M11, t.M12, t.M13, t.M14), new PxVec4(t.M21, t.M22, t.M23, t.M24), new PxVec4(t.M31, t.M32, t.M33, t.M34), new PxVec4(t.M41, t.M42, t.M43, t.M44)); rigidbody = physics.createRigidDynamic(new PxTransform(Matrix)); if (cdn) { shape = physics.createShape(new PxBoxGeometry(new PxVec3(1, 1, 1)), material, true); } else { shape = physics.createShape(new PxCapsuleGeometry(1, 1), material, true); } } else { if (cdn) { shape = physics.createShape(new PxBoxGeometry(new PxVec3(1, 1, 1)), material, true); } else { shape = physics.createShape(new PxCapsuleGeometry(1, 1), material, true); } } }
public static void PxRegisterParticles(PxPhysics physics) { physxPINVOKE.PxRegisterParticles(PxPhysics.getCPtr(physics)); if (physxPINVOKE.SWIGPendingException.Pending) { throw physxPINVOKE.SWIGPendingException.Retrieve(); } }
public static void PxRegisterUnifiedHeightFields(PxPhysics physics) { physxPINVOKE.PxRegisterUnifiedHeightFields(PxPhysics.getCPtr(physics)); if (physxPINVOKE.SWIGPendingException.Pending) { throw physxPINVOKE.SWIGPendingException.Retrieve(); } }
public static PxPhysics PxCreatePhysics(SWIGTYPE_p_uint32_t version, SWIGTYPE_p_physx__PxFoundation foundation, PxTolerancesScale scale) { global::System.IntPtr cPtr = physxPINVOKE.PxCreatePhysics__SWIG_2(SWIGTYPE_p_uint32_t.getCPtr(version), SWIGTYPE_p_physx__PxFoundation.getCPtr(foundation), PxTolerancesScale.getCPtr(scale)); PxPhysics ret = (cPtr == global::System.IntPtr.Zero) ? null : new PxPhysics(cPtr, false); if (physxPINVOKE.SWIGPendingException.Pending) { throw physxPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
//void createPhysicsAndScene() void createPhysicsAndScene() { //gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback); gFoundation = SharpPhysX.CreateFoundation(gErrorCallback, PX_PHYSICS_VERSION); //gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, PxTolerancesScale(),true,gPvd); gPhysics = PxPhysics.PxCreatePhysics(PX_PHYSICS_VERSION, gFoundation, PxTolerancesScale.Default()); //gMaterial = gPhysics->createMaterial(0.5f, 0.5f, 0.6f); gMaterial = gPhysics.createMaterial(.5f, .5f, .6f); //PxSceneDesc sceneDesc(gPhysics->getTolerancesScale()); //sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f); var sceneDesc = PxSceneDescPtr.New(PxTolerancesScale.Default()); sceneDesc.gravity = new PxVec3(0, -9.81f, 0); //PxU32 numCores = SnippetUtils::getNbPhysicalCores(); //gDispatcher = PxDefaultCpuDispatcherCreate(numCores == 0 ? 0 : numCores - 1); //sceneDesc.cpuDispatcher = gDispatcher; //sceneDesc.filterShader = PxDefaultSimulationFilterShader; uint numCores = 4; //TODO gDispatcher = PxDefaultCpuDispatcherCreate(numCores); sceneDesc.cpuDispatcher = gDispatcher; sceneDesc.filterShader = PxDefaultSimulationFilterShader; //gScene = gPhysics->createScene(sceneDesc); gScene = gPhysics.createScene(sceneDesc); //PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0,1,0,0), *gMaterial); //gScene->addActor(*groundPlane); var groundPlane = PxCreatePlane(gPhysics, new PxPlane(0, 1, 0, 0), gMaterial); gScene.addActor(groundPlane); //for(PxU32 i=0;i<5;i++) //createStack(PxTransform(PxVec3(0,0,i*10.0f)), 10, 2.0f); for (int i = 0; i < 5; i++) { createStack(new PxTransform(new PxVec3(0, 0, i * 10)), 10, 2); } }
//void initPhysics(bool interactive){ void initPhysics(bool interactive) { //gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback); gFoundation = SharpPhysX.CreateFoundation(gErrorCallback, PX_PHYSICS_VERSION); //gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, PxTolerancesScale(),true,gPvd); gPhysics = PxPhysics.PxCreatePhysics(PX_PHYSICS_VERSION, gFoundation, PxTolerancesScale.Default()); //PxSceneDesc sceneDesc(gPhysics->getTolerancesScale()); //sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f); //gDispatcher = PxDefaultCpuDispatcherCreate(2); //sceneDesc.cpuDispatcher = gDispatcher; //sceneDesc.filterShader = PxDefaultSimulationFilterShader; //gScene = gPhysics->createScene(sceneDesc); var sceneDesc = PxSceneDescPtr.New(PxTolerancesScale.Default()); sceneDesc.gravity = new PxVec3(0, -9.81f, 0); gDispatcher = PxDefaultCpuDispatcherCreate(2); sceneDesc.cpuDispatcher = gDispatcher; sceneDesc.filterShader = PxDefaultSimulationFilterShader; gScene = gPhysics.createScene(sceneDesc); //gMaterial = gPhysics->createMaterial(0.5f, 0.5f, 0.6f); gMaterial = gPhysics.createMaterial(.5f, .5f, .6f); //PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0,1,0,0), *gMaterial); //gScene->addActor(*groundPlane); var groundPlane = PxCreatePlane(gPhysics, new PxPlane(0, 1, 0, 0), gMaterial); gScene.addActor(groundPlane); //for(PxU32 i=0;i<5;i++) // createStack(PxTransform(PxVec3(0,0,stackZ-=10.0f)), 10, 2.0f); // for (int i = 0; i < 5; i++) // createStack(new PxTransform(new PxVec3(0, 0, stackZ -= 10)), 10, 2); //if(!interactive) // createDynamic(PxTransform(PxVec3(0,40,100)), PxSphereGeometry(10), PxVec3(0,-50,-100)); if (!interactive) { DEBUG = createDynamic(new PxTransform(new PxVec3(0, 40, 100)), new PxSphereGeometry(10), new PxVec3(0, -50, -100)); } }
public static PxPhysics PxGetPhysics() { PxPhysics ret = new PxPhysics(physxPINVOKE.PxGetPhysics(), false); return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PxPhysics obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }