コード例 #1
0
ファイル: PxVehicleSDK.cpp プロジェクト: nmovshov/ARSS_win
bool PxInitVehicleSDK(PxPhysics& physics)
{
	PX_ASSERT(static_cast<Ps::Foundation*>(&physics.getFoundation()) == &Ps::Foundation::getInstance());
	Ps::Foundation::incRefCount();
	setVehicleToleranceScale(physics.getTolerancesScale());
	return true;
}
コード例 #2
0
//=============================================================================
// PRIVATE FUNCTIONS
//=============================================================================
static physx::unique_ptr<PxConvexMesh> GenerateConvexFromDXMesh(PxPhysics &iPhysics, ID3DXMesh *iMesh)
{
	//Used to retrieve information from X file
	struct Mesh_FVF {
		D3DXVECTOR3 VertexPos;
		D3DXVECTOR3 Normal;
		D3DXVECTOR2 TexCoord;
	};

	int aNumVerticies = iMesh->GetNumVertices();
	DWORD FVFSize = D3DXGetFVFVertexSize(iMesh->GetFVF());

	//Create pointer for vertices
	PxVec3* verts = new PxVec3[aNumVerticies];

	char *DXMeshPtr;
	iMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&DXMeshPtr);
	for(int i = 0; i < aNumVerticies; i++)
	{
		Mesh_FVF *DXMeshFVF = (Mesh_FVF*)DXMeshPtr;
		verts[i] = PxVec3(DXMeshFVF->VertexPos.x, DXMeshFVF->VertexPos.y, DXMeshFVF->VertexPos.z);
		DXMeshPtr += FVFSize;
	}
	iMesh->UnlockVertexBuffer();

	// Create descriptor for convex mesh
	PxConvexMeshDesc convexDesc;
	convexDesc.points.count		= aNumVerticies;
	convexDesc.points.stride	= sizeof(PxVec3);
	convexDesc.points.data		= verts;
	convexDesc.flags			= PxConvexFlag::eCOMPUTE_CONVEX;

	PxTolerancesScale toleranceScale;
	toleranceScale.length = 1.0f;
	toleranceScale.mass = 1000.0f;
	toleranceScale.speed = 9.8f;

	assert(toleranceScale.isValid());

	physx::unique_ptr<PxCooking> cooker = physx::unique_ptr<PxCooking>(
		PxCreateCooking(PX_PHYSICS_VERSION, iPhysics.getFoundation(), PxCookingParams(toleranceScale))
		);

	// Cooking from memory
	MemoryStream buf;
	physx::unique_ptr<PxConvexMesh> convexMesh;
	if(cooker->cookConvexMesh(convexDesc, buf))
	{
		convexMesh = physx::unique_ptr<PxConvexMesh>(iPhysics.createConvexMesh(buf));
	}	

	delete[] verts;

	return convexMesh;
}
コード例 #3
0
ファイル: ExtExtensions.cpp プロジェクト: thomhughes/Awe
bool PxInitExtensions(PxPhysics& physics)
{
    PX_ASSERT(static_cast<Ps::Foundation*>(&physics.getFoundation()) == &Ps::Foundation::getInstance());
    Ps::Foundation::incRefCount();

    physics.registerClass(PxConcreteType::eUSER_SPHERICAL_JOINT,	Ext::SphericalJoint::createInstance);
    physics.registerClass(PxConcreteType::eUSER_REVOLUTE_JOINT,	Ext::RevoluteJoint::createInstance);
    physics.registerClass(PxConcreteType::eUSER_DISTANCE_JOINT,	Ext::DistanceJoint::createInstance);
    physics.registerClass(PxConcreteType::eUSER_D6_JOINT,			Ext::D6Joint::createInstance);
    physics.registerClass(PxConcreteType::eUSER_PRISMATIC_JOINT,	Ext::PrismaticJoint::createInstance);
    physics.registerClass(PxConcreteType::eUSER_FIXED_JOINT,		Ext::FixedJoint::createInstance);
#if PX_SUPPORT_VISUAL_DEBUGGER
    if ( physics.getPvdConnectionManager() != NULL )
        physics.getPvdConnectionManager()->addHandler( gPvdHandler );
#endif
    return true;
}
コード例 #4
0
bool PxInitExtensions(PxPhysics& physics, PxPvd* pvd)
{
	PX_ASSERT(static_cast<Ps::Foundation*>(&physics.getFoundation()) == &Ps::Foundation::getInstance());
	PX_UNUSED(physics);
	PX_UNUSED(pvd);
	Ps::Foundation::incRefCount();

#if PX_SUPPORT_PVD
	if(pvd)
	{
		gPvdHandler.mPvd = static_cast<PsPvd*>(pvd);
		gPvdHandler.mPvd->addClient(&gPvdHandler);
	}
#endif

	return true;
}