当前位置: 首页>>代码示例>>C++>>正文


C++ PxPhysics类代码示例

本文整理汇总了C++中PxPhysics的典型用法代码示例。如果您正苦于以下问题:C++ PxPhysics类的具体用法?C++ PxPhysics怎么用?C++ PxPhysics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PxPhysics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createParticles

void
PhsXWorld::_addParticles(nau::render::Pass* pass, std::shared_ptr<nau::scene::IScene> &aScene, std::string name, nau::material::IBuffer* positions) {

    PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());

    float particleDistance = 0.01f;
    // create particle system in PhysX SDK
    particleSystem = gPhysics->createParticleFluid(MAXPARTICLE);
    //particleSystem->setGridSize(5.0f);
    particleSystem->setMaxMotionDistance(0.3f);
    //particleSystem->setRestOffset(particleDistance*0.3f);
    particleSystem->setRestOffset(0.04f);
    //particleSystem->setContactOffset(particleDistance*0.3f * 2);
    particleSystem->setContactOffset(0.036f);
    particleSystem->setDamping(0.0f);
    particleSystem->setRestitution(0.3f);
    particleSystem->setDynamicFriction(0.001f);
    particleSystem->setRestParticleDistance(particleDistance);
    particleSystem->setViscosity(60.0f);
    particleSystem->setStiffness(45.0f);
    //particleSystem->setParticleReadDataFlag(PxParticleReadDataFlag::eVELOCITY_BUFFER, true);

    particleSystem->userData = aScene.get();

    // add particle system to scene, in case creation was successful
    if (particleSystem)
        m_pDynamicsWorld->addActor(*particleSystem);

    particleIndexPool = PxParticleExt::createIndexPool(MAXPARTICLE);
    particlePass = pass;
    particlePositionBuffer = positions;
    createParticles();
}
开发者ID:david-leal,项目名称:nau,代码行数:33,代码来源:physXWorld.cpp

示例2: PxInitVehicleSDK

bool PxInitVehicleSDK(PxPhysics& physics)
{
	PX_ASSERT(static_cast<Ps::Foundation*>(&physics.getFoundation()) == &Ps::Foundation::getInstance());
	Ps::Foundation::incRefCount();
	setVehicleToleranceScale(physics.getTolerancesScale());
	return true;
}
开发者ID:nmovshov,项目名称:ARSS_win,代码行数:7,代码来源:PxVehicleSDK.cpp

示例3: GenerateConvexFromDXMesh

//=============================================================================
// 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;
}
开发者ID:DDJV-INF740,项目名称:GameEngine-src,代码行数:58,代码来源:ModelFactory.cpp

示例4: gPhysX

	void FPhysXMesh::initialize()
	{
		if (mCookedData != nullptr && mCookedDataSize > 0)
		{
			PxPhysics* physx = gPhysX().getPhysX();

			PxDefaultMemoryInputData input(mCookedData, mCookedDataSize);
			if (mType == PhysicsMeshType::Convex)
				mConvexMesh = physx->createConvexMesh(input);
			else
				mTriangleMesh = physx->createTriangleMesh(input);
		}
	}
开发者ID:MarcoROG,项目名称:BansheeEngine,代码行数:13,代码来源:BsPhysXMesh.cpp

示例5: PxTolerancesScale

void
PhsXWorld::build(void) {
    PxTolerancesScale scale = PxTolerancesScale();
    PxFoundation* gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback);
    PxProfileZoneManager* profileZoneManager = &PxProfileZoneManager::createProfileZoneManager(gFoundation);
    PxPhysics*	gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, scale, true, profileZoneManager);
    if (gPhysics->getPvdConnectionManager()) {
        gPhysics->getVisualDebugger()->setVisualizeConstraints(true);
        gPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_CONTACTS, true);
        gPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_SCENEQUERIES, true);
        //gPhysics->getVisualDebugger()->setVisualDebuggerFlag(PxVisualDebuggerFlag::eTRANSMIT_CONSTRAINTS, true);
        gConnection = PxVisualDebuggerExt::createConnection(gPhysics->getPvdConnectionManager(), "127.0.0.1", 5425, 100);
    }
    PxSceneDesc sceneDesc(gPhysics->getTolerancesScale());
    sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f);
    PxDefaultCpuDispatcher* gDispatcher = PxDefaultCpuDispatcherCreate(2);
    sceneDesc.cpuDispatcher = gDispatcher;
    sceneDesc.filterShader = PxDefaultSimulationFilterShader;
    sceneDesc.flags |= PxSceneFlag::eENABLE_ACTIVETRANSFORMS;
    m_pDynamicsWorld = gPhysics->createScene(sceneDesc);
    //m_pDynamicsWorld->setFlag(PxSceneFlag::eENABLE_ACTIVETRANSFORMS, true);

    mCooking = PxCreateCooking(PX_PHYSICS_VERSION, *gFoundation, PxCookingParams(scale));
    manager = PxCreateControllerManager(*m_pDynamicsWorld);

    std::srand(time(NULL));
}
开发者ID:david-leal,项目名称:nau,代码行数:27,代码来源:physXWorld.cpp

示例6: deserializeFromRepXFile

	void CEntity::deserializeFromRepXFile(const std::string &file, int group, const std::vector<int>& groupList, const Logic::IPhysics* component) {
		// Obtenemos el puntero al servidor de fisicas
		Physics::CServer* physicsServer = Physics::CServer::getSingletonPtr();
		PxScene* scene = physicsServer->getActiveScene();
		PxPhysics* physics = physicsServer->getPhysxSDK();
		PxCooking* cooking = physicsServer->getCooking();
		assert(scene);

		// Preparar parámetros para deserializar
		PxDefaultFileInputData data(file.c_str());
		PxCollection* bufferCollection = physics->createCollection();
		PxCollection* sceneCollection = physics->createCollection(); 
		PxStringTable* stringTable = &PxStringTableExt::createStringTable( CServer::getSingletonPtr()->getFoundation()->getAllocatorCallback() ); 
		PxUserReferences* externalRefs = NULL; 
		PxUserReferences* userRefs = NULL; 

		// Deserializar a partir del fichero RepX
		repx::deserializeFromRepX(data, *physics, *cooking, stringTable, externalRefs, 
								  *bufferCollection, *sceneCollection, userRefs);


		// Añadir entidades físicas a la escena
		physics->addCollection(*sceneCollection, *scene);

		// Buscar una entidad de tipo PxRigidActor. Asumimos que hay exactamente 1 en el fichero.
		_actor = NULL;
		for (unsigned int i = 0; i < sceneCollection->getNbObjects() && !_actor; ++i) {
			PxSerializable* p = sceneCollection->getObject(i);
			_actor = p->is<PxRigidActor>();
		}
		assert(_actor);

		// Anotar el componente lógico asociado a la entidad física
		_actor->userData = (void*)component;

		// Establecer el grupo de colisión
		PxSetGroup(*_actor, group);
		// Establecer los filtros de colisión
		Physics::CServer::getSingletonPtr()->setupFiltering(_actor, group, groupList);

		// Liberar recursos
		bufferCollection->release();
		sceneCollection->release();
	}
开发者ID:franaisa,项目名称:Gloom,代码行数:44,代码来源:Entity.cpp

示例7:

void
PhsXWorld::_addCharacter(float mass, float radius, float height, float stepHeight, std::shared_ptr<nau::scene::IScene> &aScene, std::string name) {
    PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());
    PxCapsuleControllerDesc desc;
    //desc.height = 1.3f;
    //desc.radius = 0.35f;
    desc.height = height;
    desc.radius = radius;
    PxVec3 pos = PxMat44(const_cast<float*> (aScene->getTransform().getMatrix())).getPosition();
    desc.position = PxExtendedVec3(pos.x, pos.y, pos.z);
    desc.material = gPhysics->createMaterial(0.5f, 0.5f, 0.6f);
    desc.userData = aScene.get();
    desc.reportCallback = this;
    desc.climbingMode = PxCapsuleClimbingMode::eCONSTRAINED;
    desc.stepOffset = stepHeight;
    desc.upDirection = PxVec3(0, 1, 0);
    //desc.slopeLimit = cosf(DegToRad(80.0f));
    controller = manager->createController(desc);
}
开发者ID:david-leal,项目名称:nau,代码行数:19,代码来源:physXWorld.cpp

示例8: PxInitExtensions

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;
}
开发者ID:thomhughes,项目名称:Awe,代码行数:17,代码来源:ExtExtensions.cpp

示例9: PxInitExtensions

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;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:17,代码来源:ExtExtensions.cpp

示例10: createProxyActor

bool Controller::createProxyActor(PxPhysics& sdk, const PxGeometry& geometry, const PxMaterial& material)
{
    // PT: we don't disable raycasting or CD because:
    // - raycasting is needed for visibility queries (the SDK otherwise doesn't know about the CCTS)
    // - collision is needed because the only reason we create actors there is to handle collisions with dynamic shapes
    // So it's actually wrong to disable any of those.

    PxTransform globalPose;
    globalPose.p = toVec3(mPosition);	// LOSS OF ACCURACY
    globalPose.q = mUserParams.mQuatFromUp;

    mKineActor = sdk.createRigidDynamic(globalPose);
    if(!mKineActor)
        return false;

    mKineActor->createShape(geometry, material);
    mKineActor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);

    PxRigidBodyExt::updateMassAndInertia(*mKineActor, mProxyDensity);
    mScene->addActor(*mKineActor);
    return true;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:22,代码来源:CctController.cpp

示例11: PxCollectForExportSDK

void PxCollectForExportSDK(const PxPhysics& physics, PxCollection& collection)
{
    // Collect convexes
    {
        Ps::Array<PxConvexMesh*> objects(physics.getNbConvexMeshes());
        const PxU32 nb = physics.getConvexMeshes(objects.begin(), objects.size());
        PX_ASSERT(nb == objects.size());
        PX_UNUSED(nb);

        for(PxU32 i=0; i<objects.size(); i++)
            objects[i]->collectForExport(collection);
    }

    // Collect triangle meshes
    {
        Ps::Array<PxTriangleMesh*> objects(physics.getNbTriangleMeshes());
        const PxU32 nb = physics.getTriangleMeshes(objects.begin(), objects.size());

        PX_ASSERT(nb == objects.size());
        PX_UNUSED(nb);

        for(PxU32 i=0; i<objects.size(); i++)
            objects[i]->collectForExport(collection);
    }

    // Collect heightfields
    {
        Ps::Array<PxHeightField*> objects(physics.getNbHeightFields());
        const PxU32 nb = physics.getHeightFields(objects.begin(), objects.size());

        PX_ASSERT(nb == objects.size());
        PX_UNUSED(nb);

        for(PxU32 i=0; i<objects.size(); i++)
            objects[i]->collectForExport(collection);
    }

    // Collect materials
    {
        Ps::Array<PxMaterial*> objects(physics.getNbMaterials());
        const PxU32 nb = physics.getMaterials(objects.begin(), objects.size());

        PX_ASSERT(nb == objects.size());
        PX_UNUSED(nb);

        for(PxU32 i=0; i<objects.size(); i++)
            objects[i]->collectForExport(collection);
    }

#if PX_USE_CLOTH_API
    // Collect cloth fabrics
    {
        Ps::Array<PxClothFabric*> objects(physics.getNbClothFabrics());
        const PxU32 nb = physics.getClothFabrics(objects.begin(), objects.size());

        PX_ASSERT(nb == objects.size());
        PX_UNUSED(nb);

        for(PxU32 i=0; i<objects.size(); i++)
            objects[i]->collectForExport(collection);
    }
#endif
}
开发者ID:thomhughes,项目名称:Awe,代码行数:63,代码来源:ExtExtensions.cpp

示例12: triGeom

void 
PhysXRigidManager::addStaticBody(const std::string & scene, physx::PxScene * world, physx::PxCooking * mCooking, nau::physics::IPhysics::BoundingVolume shape, physx::PxMaterial * material) {
	PxPhysics *gPhysics = &(world->getPhysics());
	PxRigidStatic * staticActor;
	PxTransform trans = PxTransform(PxMat44(rigidBodies[scene].info.extInfo.transform));
	switch (shape.sceneShape)
	{
	case nau::physics::IPhysics::BOX:
	{
		staticActor = PxCreateStatic(
			world->getPhysics(),
			trans,
			PxBoxGeometry(shape.max[0], shape.max[1], shape.max[2]),
			*material
		);
	}
	break;
	case nau::physics::IPhysics::SPHERE:
	{
		staticActor = PxCreateStatic(
			world->getPhysics(),
			trans,
			PxSphereGeometry(shape.max[0]),
			*material
		);
	}
	break;
	case nau::physics::IPhysics::CAPSULE:
	{
		staticActor = PxCreateStatic(
			world->getPhysics(),
			trans,
			PxCapsuleGeometry(
				shape.max[0],
				shape.max[1]
			),
			*material
		);
	}
	break;
	default:
	{
		if (scene.compare("plane") == 0) {
			staticActor = PxCreatePlane(
				world->getPhysics(),
				PxPlane(0.0f, 1.0f, 0.0f, 0.0f),
				*material
			);
		}
		else {
			staticActor = gPhysics->createRigidStatic(trans);
			PxTriangleMeshGeometry triGeom(gPhysics->createTriangleMesh(*getTriangleMeshGeo(world, mCooking, rigidBodies[scene].info.extInfo, true)));
			//triGeom.triangleMesh = gPhysics->createTriangleMesh(*getTriangleMeshGeo(world, mCooking, rigidBodies[scene].extInfo, true));
			staticActor->createShape(triGeom, *material);
		}
	}
	break;
	}
	staticActor->userData = static_cast<void*> (new std::string(scene));
	world->addActor(*staticActor);
	rigidBodies[scene].info.actor = staticActor;
}
开发者ID:david-leal,项目名称:nau,代码行数:62,代码来源:physXRigidManager.cpp

示例13: PxClothParticle

void
PhsXWorld::_addCloth(float mass, std::shared_ptr<nau::scene::IScene> &aScene, std::string name, nau::math::vec3 aVec) {
    PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());

    std::shared_ptr<nau::scene::SceneObject> &aObject = aScene->getSceneObject(0);
    std::shared_ptr<VertexData> &vd = aObject->getRenderable()->getVertexData();
    std::vector<std::shared_ptr<MaterialGroup>> &matGroups = aObject->getRenderable()->getMaterialGroups();
    std::vector<std::shared_ptr<MaterialGroup>>::iterator matGroupsIter;

    PxDefaultMemoryOutputStream writeBuffer;

    int count = static_cast<int> (vd->getDataOf(VertexData::GetAttribIndex(std::string("position")))->size());
    PxClothParticle *particles = new PxClothParticle[count];

    PxClothMeshDesc meshDesc;
    matGroupsIter = matGroups.begin();
    for (; matGroupsIter != matGroups.end(); matGroupsIter++) {
        if ((*matGroupsIter)->getIndexData()->getIndexSize()) {
            std::shared_ptr<std::vector<unsigned int>> &indexes = (*matGroupsIter)->getIndexData()->getIndexData();
            PxClothParticle *ptls = particles;
            std::shared_ptr<std::vector<VertexData::Attr>> points = vd->getDataOf(VertexData::GetAttribIndex(std::string("position")));
            for (int i = 0; i < count; i++) {
                VertexData::Attr tempPoint = points->at(i);
                //ptls[i] = PxClothParticle(PxVec3(tempPoint.x, tempPoint.y, tempPoint.z), (i==0 || i==1) ? 0.0f : 1.0f);
                ptls[i] = PxClothParticle(PxVec3(tempPoint.x, tempPoint.y, tempPoint.z), i == 0 ? 0.0f : 0.1f);
            }

            meshDesc.points.data = reinterpret_cast<const unsigned char *>(&(vd->getDataOf(VertexData::GetAttribIndex(std::string("position")))->at(0)));
            meshDesc.points.count = count;
            meshDesc.points.stride = 4 * sizeof(float);

            meshDesc.invMasses.data = &particles->invWeight;
            meshDesc.invMasses.count = count;
            meshDesc.invMasses.stride = sizeof(PxClothParticle);

            meshDesc.triangles.data = reinterpret_cast<const unsigned char *>(&((*indexes)[0]));
            meshDesc.triangles.count = static_cast<int> (indexes->size() / 3);
            meshDesc.triangles.stride = 3 * sizeof(unsigned int);

        }
    }
    //float * points = reinterpret_cast<float *>(&(vd->getDataOf(VertexData::GetAttribIndex(std::string("position")))->at(0)));
    //PxU32 numParticles = static_cast<int> (vd->getDataOf(VertexData::GetAttribIndex(std::string("position")))->size());
    //PxU32 stride = 4 * sizeof(float);
    //// create particles
    //PxClothParticle* particles = new PxClothParticle[numParticles];
    //PxClothParticle* pIt = particles;
    //for (PxU32 i = 0; i<numParticles; ++i) {
    //	pIt->invWeight = i==0 ? 0.0f : 1.0f;
    //	int tempStride = i*stride;
    //	pIt->pos = PxVec3(points[tempStride], points[tempStride + 1], points[tempStride + 2]);
    //}

    PxClothFabric* fabric = PxClothFabricCreate(*gPhysics, meshDesc, PxVec3(0, -1, 0));
    PxTransform pose = PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix())));
    PxClothFlags flags = PxClothFlags();
    /*if(!flags.isSet(PxClothFlag::eSCENE_COLLISION))
    	flags.set(PxClothFlag::eSCENE_COLLISION);
    if (!flags.isSet(PxClothFlag::eGPU))
    	flags.set(PxClothFlag::eGPU);
    if (!flags.isSet(PxClothFlag::eSWEPT_CONTACT))
    	flags.set(PxClothFlag::eSWEPT_CONTACT);*/
    cloth = gPhysics->createCloth(pose, *fabric, particles, flags);
    cloth->userData = aScene.get();
    cloth->setClothFlag(PxClothFlag::eSCENE_COLLISION, true);
    cloth->setClothFlag(PxClothFlag::eGPU, true);
    cloth->setClothFlag(PxClothFlag::eSWEPT_CONTACT, true);
    cloth->setSolverFrequency(300.0f);
    cloth->setInertiaScale(0.9f);

    cloth->setStretchConfig(PxClothFabricPhaseType::eVERTICAL, PxClothStretchConfig(0.2f));
    cloth->setStretchConfig(PxClothFabricPhaseType::eHORIZONTAL, PxClothStretchConfig(0.2f));
    cloth->setStretchConfig(PxClothFabricPhaseType::eSHEARING, PxClothStretchConfig(0.75f));
    cloth->setStretchConfig(PxClothFabricPhaseType::eBENDING, PxClothStretchConfig(0.2f));
    m_pDynamicsWorld->addActor(*cloth);

}
开发者ID:david-leal,项目名称:nau,代码行数:77,代码来源:physXWorld.cpp

示例14: convGeom

void
PhsXWorld::_addRigid(float mass, float friction, float restitution, std::shared_ptr<nau::scene::IScene> &aScene, std::string name, nau::math::vec3 aVec) {

    PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());

    if (mass == 0.0f) {
        PxRigidStatic* staticActor;
        if (name.compare("plane") == 0) {
            staticActor = PxCreatePlane(*gPhysics,
                                        PxPlane(0.0f, 1.0f, 0.0f, 0.0f),
                                        *(gPhysics->createMaterial(friction, friction, restitution))
                                       );

        }
        else {
            /*if (name.compare("box") == 0) {
            	staticActor = PxCreateStatic(*gPhysics,
            		PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))),
            		PxBoxGeometry(1.0f,1.0f,1.0f),
            		*(gPhysics->createMaterial(1.0f, 1.0f, 0.6f))
            	);
            }
            else {*/
            staticActor = gPhysics->createRigidStatic(PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))));
            PxTriangleMeshGeometry triGeom;
            triGeom.triangleMesh = gPhysics->createTriangleMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene));
            staticActor->createShape(triGeom, *(gPhysics->createMaterial(friction, friction, restitution)));
            //}
        }
        staticActor->userData = aScene.get();
        m_pDynamicsWorld->addActor(*staticActor);
    }
    else {
        PxRigidDynamic* dynamic;
        //if (name.compare("ball") == 0) {
        //	dynamic = PxCreateDynamic(*gPhysics,
        //		PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))),
        //		PxSphereGeometry(1),
        //		*(gPhysics->createMaterial(0.5f, 0.5f, 0.6f)),
        //		10.0f
        //	);
        //	//dynamic->setLinearVelocity(PxVec3(0, -50, -100));
        //}
        //else {
        PxTransform trans = PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix())));
        dynamic = gPhysics->createRigidDynamic(trans);
        PxConvexMesh * convexMesh = gPhysics->createConvexMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene, false));
        PxConvexMeshGeometry convGeom(convexMesh);
        //PxConvexMeshGeometry convGeom(convexMesh, PxMeshScale(0.5f));
        //convGeom.convexMesh = gPhysics->createConvexMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene, false));

        //PxShape *shape = dynamic->createShape(convGeom, *(gPhysics->createMaterial(0.5f, 0.5f, 0.6f)), PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE);
        PxShape *shape = dynamic->createShape(convGeom, *(gPhysics->createMaterial(friction, friction, restitution)));
        //shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
        //dynamic->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, false);
        //}
        dynamic->userData = aScene.get();
        //dynamic->setAngularDamping(0.5f);
        //dynamic->setLinearVelocity(velocity);

        m_pDynamicsWorld->addActor(*dynamic);
    }
}
开发者ID:david-leal,项目名称:nau,代码行数:63,代码来源:physXWorld.cpp

示例15: sizeof

bool Ext::RevoluteJoint::attach(PxPhysics &physics, PxRigidActor* actor0, PxRigidActor* actor1)
{
    mPxConstraint = physics.createConstraint(actor0, actor1, *this, sShaders, sizeof(RevoluteJointData));
    return mPxConstraint!=NULL;
}
开发者ID:savant-nz,项目名称:carbon,代码行数:5,代码来源:ExtRevoluteJoint.cpp


注:本文中的PxPhysics类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。