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


C++ PxShape::setFlag方法代码示例

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


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

示例1: createStaticBox

PxRigidStatic* CPhysicManager::createStaticBox(const Vector3 &position, const Vector3 &dimensions, bool trigger,
        int group, const IPhysic *component)
{
    assert(m_scene);
    PxVec3 p = Vector3ToPxVec3(position);
    PxVec3 d = Vector3ToPxVec3(dimensions);

    PxTransform pose(p);
    PxBoxGeometry geom(d);
    PxTransform localPose(PxVec3(0,dimensions.y,0));

    PxRigidStatic *actor = PxCreateStatic(*m_physics,pose,geom,*m_defaultMaterial,localPose);

    if(trigger) {
        PxShape *shape;
        actor->getShapes(&shape,1,0);
        shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
        shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
    }

    actor->userData = (void*)component;

    PxSetGroup(*actor,group);

    setupFiltering(actor,FilterGroup::eSPACE_FILTER,FilterGroup::eSPACE_FILTER);

    //m_scene->addActor(*actor);

    return actor;
}
开发者ID:Ithos,项目名称:TTG,代码行数:30,代码来源:PhysicManager.cpp

示例2: createStaticSphere

physx::PxRigidStatic* CPhysicManager::createStaticSphere(const Vector3 &position, const float &radius, bool trigger, int group, const Logic::Component::IPhysic *component)
{
    assert(m_scene);
    PxVec3 p = Vector3ToPxVec3(position);

    PxTransform pose(p);
    PxSphereGeometry geom(radius);

    PxRigidStatic *actor = PxCreateStatic(*m_physics,pose,geom,*m_defaultMaterial);

    if(trigger) {
        PxShape *shape;
        actor->getShapes(&shape,1,0);
        shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
        shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
    }

    actor->userData = (void*)component;

    PxSetGroup(*actor,group);

    setupFiltering(actor,FilterGroup::eSPACE_FILTER,FilterGroup::eSPACE_FILTER);

    //m_scene->addActor(*actor);

    return actor;
}
开发者ID:Ithos,项目名称:TTG,代码行数:27,代码来源:PhysicManager.cpp

示例3: createDrain

void SampleParticles::createDrain() 
{
	float lakeHeight = 5.5f;
	
	//Creates a drain plane for the particles. This is good practice to avoid unnecessary 
	//spreading of particles, which is bad for performance. The drain represents a lake in this case.
	{
		PxRigidStatic* actor = getPhysics().createRigidStatic(PxTransform(PxVec3(0.0f, lakeHeight - 1.0f, 0.0f), PxQuat(PxHalfPi, PxVec3(0,0,1))));
		runtimeAssert(actor, "PxPhysics::createRigidStatic returned NULL\n");
		PxShape* shape = actor->createShape(PxPlaneGeometry(), getDefaultMaterial());
		runtimeAssert(shape, "PxRigidStatic::createShape returned NULL\n");
		shape->setSimulationFilterData(collisionGroupDrain);
		shape->setFlags(PxShapeFlag::ePARTICLE_DRAIN | PxShapeFlag::eSIMULATION_SHAPE);
		getActiveScene().addActor(*actor);
		mPhysicsActors.push_back(actor);
	}
	
	//Creates the surface of the lake (the particles actually just collide with the underlaying drain).
	{
		PxBoxGeometry bg;
		bg.halfExtents = PxVec3(130.0f, lakeHeight + 1.0f, 130.0f);
		PxRigidStatic* actor = getPhysics().createRigidStatic(PxTransform(PxVec3(0.0f, 0.0f, 0.0f), PxQuat::createIdentity()));
		runtimeAssert(actor, "PxPhysics::createRigidStatic returned NULL\n");
		PxShape* shape = actor->createShape(bg, getDefaultMaterial());
		runtimeAssert(shape, "PxRigidStatic::createShape returned NULL\n");
		shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
		shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, false);
		getActiveScene().addActor(*actor);
		mPhysicsActors.push_back(actor);
		createRenderObjectsFromActor(actor, getMaterial(MATERIAL_LAKE));
	}
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:32,代码来源:SampleParticles.cpp

示例4: SetCollisionResponseForActor

void UDestructibleComponent::SetCollisionResponseForActor(const FCollisionResponse& ColResponse, PxRigidDynamic* Actor, int32 ChunkIdx)
{
	// Get collision channel and response
	PxFilterData PQueryFilterData, PSimFilterData;
	uint8 MoveChannel = GetCollisionObjectType();
	if(IsCollisionEnabled())
	{
		AActor* Owner = GetOwner();
		CreateShapeFilterData(MoveChannel, (Owner ? Owner->GetUniqueID() : 0), ColResponse.GetResponseContainer(), 0, ChunkIdxToBoneIdx(ChunkIdx), PQueryFilterData, PSimFilterData, BodyInstance.bUseCCD, BodyInstance.bNotifyRigidBodyCollision, false);		
		PQueryFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision;

		SCOPED_SCENE_WRITE_LOCK(Actor->getScene());

		TArray<PxShape*> Shapes;
		Shapes.AddUninitialized(Actor->getNbShapes());

		int ShapeCount = Actor->getShapes(Shapes.GetTypedData(), Shapes.Num());

		for (int32 i=0; i < ShapeCount; ++i)
		{
			PxShape* Shape = Shapes[i];

			Shape->setQueryFilterData(PQueryFilterData);
			Shape->setSimulationFilterData(PSimFilterData);
			Shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, true); 
			Shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true); 
			Shape->setFlag(PxShapeFlag::eVISUALIZATION, true);
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:30,代码来源:DestructibleComponent.cpp

示例5: createPizzaPickup

void PhysicsEngine::createPizzaPickup(physx::PxVec3 location, physx::PxF32 radius)
{
	PxBoxGeometry geometry(radius, radius, radius); 
	PxTransform transform(location, PxQuat::createIdentity());
	PxMaterial* material = physics->createMaterial(0.5f, 0.5f, 0.5f);

	PxRigidStatic* actor = PxCreateStatic(*physics, transform, geometry, *material);
	PxShape* shape;
	actor->getShapes(&shape, 1);
	shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
	shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
	shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, false);

	scene->addActor(*actor);
}
开发者ID:Scraniel,项目名称:bite-the-crust,代码行数:15,代码来源:PhysicsEngine.cpp

示例6:

PxRigidDynamic* SampleParticles::Raygun::createRayCapsule(bool enableCollision, PxFilterData filterData)
{
	PxRigidDynamic* actor = mSample->getPhysics().createRigidDynamic(PxTransform::createIdentity());
	mSample->runtimeAssert(actor, "PxPhysics::createRigidDynamic returned NULL\n");
	PxShape* shape = actor->createShape(PxCapsuleGeometry(0.1f, 150.0f), mSample->getDefaultMaterial());
	mSample->runtimeAssert(shape, "PxRigidDynamic::createShape returned NULL\n");
	shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, false);
	shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, enableCollision);
	shape->setSimulationFilterData(filterData);
	actor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);
	actor->setMass(1.0f);
	actor->setMassSpaceInertiaTensor(PxVec3(1.0f));
	mSample->getActiveScene().addActor(*actor);	
	return actor;
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:15,代码来源:SampleParticles.cpp

示例7: AddPhyObjects

// add some physics objects into the scene
void AddPhyObjects()
{
	PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 1, 0, 0), *gMaterial);
	gScene->addActor(*groundPlane);

	PxShape* shape = gPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
	PxTransform localTm(PxVec3(-3.0f, 5.0f, 0.f));
	PxRigidDynamic* body = gPhysics->createRigidDynamic(localTm);
	body->attachShape(*shape);
	PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
	gScene->addActor(*body);

	shape->release();

	shape = gPhysics->createShape(PxSphereGeometry(1.0f), *gMaterial);
	PxTransform localTmS(PxVec3(3.0f, 5.0f, 0.f));
	body = gPhysics->createRigidDynamic(localTmS);
	body->attachShape(*shape);
	PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
	gScene->addActor(*body);

	shape->release();

	PxRigidDynamic* dynamic = PxCreateDynamic(*gPhysics, PxTransform(PxVec3(0, 20, 20)), PxSphereGeometry(1), *gMaterial, 10.0f);
	dynamic->setAngularDamping(0.5f);
	dynamic->setLinearVelocity(PxVec3(0, -5, -10));
	gScene->addActor(*dynamic);

	// add capsule into the scene
	shape = gPhysics->createShape(PxCapsuleGeometry(1.0f, 3.0f), *gMaterial);
	PxTransform localTmC(PxVec3(3.0f, 5.0f, -3.f));
	body = gPhysics->createRigidDynamic(localTmC);
	body->attachShape(*shape);
	PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
	gScene->addActor(*body);

	// add a static box as the trigger
	shape = gPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
	PxTransform localTmTrigger(PxVec3(0.0f, 1.0f, -10.f));
	body = gPhysics->createRigidDynamic(localTmTrigger);
	shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
	shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
	body->attachShape(*shape);
	body->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
	gScene->addActor(*body);

	shape->release();
}
开发者ID:hanhonglei,项目名称:Course_GamePhysics,代码行数:49,代码来源:Physics.cpp

示例8: PxCreateKinematic

PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk, 
								  const PxTransform& transform, 
								  const PxGeometry& geometry, 
								  PxMaterial& material,
								  PxReal density,
								  const PxTransform& shapeOffset)
{
	PX_CHECK_AND_RETURN_NULL(transform.isValid(), "PxCreateKinematic: transform is not valid.");
	PX_CHECK_AND_RETURN_NULL(shapeOffset.isValid(), "PxCreateKinematic: shapeOffset is not valid.");

	bool isDynGeom = isDynamicGeometry(geometry);
	if(isDynGeom && density <= 0.0f)
	    return NULL;

	PxShape* shape;
	PxRigidDynamic* actor = setShape(sdk.createRigidDynamic(transform), geometry, material, shapeOffset, shape);
	
	if(actor)
	{
		actor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);

		if(isDynGeom)
			PxRigidBodyExt::updateMassAndInertia(*actor, density);
		else		
		{
			shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
			actor->setMass(1);
			actor->setMassSpaceInertiaTensor(PxVec3(1,1,1));
		}
	}
	return actor;
}
开发者ID:galek,项目名称:YR02_03_Physics,代码行数:32,代码来源:ExtSimpleFactory.cpp

示例9: SetCollisionResponseForActor

void UDestructibleComponent::SetCollisionResponseForActor(PxRigidDynamic* Actor, int32 ChunkIdx, const FCollisionResponseContainer* ResponseOverride /*= NULL*/)
{
#if WITH_APEX
	if (ApexDestructibleActor == NULL)
	{
		return;
	}

	// Get collision channel and response
	PxFilterData PQueryFilterData, PSimFilterData;
	uint8 MoveChannel = GetCollisionObjectType();
	if(IsCollisionEnabled())
	{
		UDestructibleMesh* TheDestructibleMesh = GetDestructibleMesh();
		AActor* Owner = GetOwner();
		bool bLargeChunk = IsChunkLarge(ChunkIdx);
		const FCollisionResponseContainer& UseResponse = ResponseOverride == NULL ? (bLargeChunk ? LargeChunkCollisionResponse.GetResponseContainer() : SmallChunkCollisionResponse.GetResponseContainer()) : *ResponseOverride;

		physx::PxU32 SupportDepth = TheDestructibleMesh->ApexDestructibleAsset->getChunkDepth(ChunkIdx);

		const bool bEnableImpactDamage = IsImpactDamageEnabled(TheDestructibleMesh, SupportDepth);
		CreateShapeFilterData(MoveChannel, GetUniqueID(), UseResponse, 0, ChunkIdxToBoneIdx(ChunkIdx), PQueryFilterData, PSimFilterData, BodyInstance.bUseCCD, bEnableImpactDamage, false);
		
		PQueryFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision;

		SCOPED_SCENE_WRITE_LOCK(Actor->getScene());

		TArray<PxShape*> Shapes;
		Shapes.AddUninitialized(Actor->getNbShapes());

		int ShapeCount = Actor->getShapes(Shapes.GetData(), Shapes.Num());

		for (int32 i=0; i < ShapeCount; ++i)
		{
			PxShape* Shape = Shapes[i];

			Shape->setQueryFilterData(PQueryFilterData);
			Shape->setSimulationFilterData(PSimFilterData);
			Shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, true); 
			Shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true); 
			Shape->setFlag(PxShapeFlag::eVISUALIZATION, true);
		}
	}
#endif
}
开发者ID:johndpope,项目名称:UE4,代码行数:45,代码来源:DestructibleComponent.cpp

示例10: createDynamicBox

PxRigidDynamic* CServer::createDynamicBox(const Vector3 &position, const Vector3 &dimensions, 
	                                      float mass, bool kinematic, bool trigger, int group, 
										  const IPhysics *component)
{
	assert(_scene);

	// Nota: PhysX coloca el sistema de coordenadas local en el centro de la caja, mientras
	// que la lógica asume que el origen del sistema de coordenadas está en el centro de la 
	// cara inferior. Para unificar necesitamos realizar una traslación en el eje Y.
	// Afortunadamente, el descriptor que se usa para crear el actor permite definir esta 
	// transformación local, por lo que la conversión entre sistemas de coordenadas es transparente. 

	// Crear un cubo dinámico
	PxTransform pose(Vector3ToPxVec3(position));
	PxBoxGeometry geom(Vector3ToPxVec3(dimensions));
	PxMaterial *material = _defaultMaterial;
	float density = mass / (dimensions.x * dimensions.y * dimensions.z);
	PxTransform localPose(PxVec3(0, dimensions.y, 0)); // Transformación de coordenadas lógicas a coodenadas de PhysX

	// Crear cubo dinámico o cinemático
	PxRigidDynamic *actor;
	if (kinematic)
		actor = PxCreateKinematic(*_physics, pose, geom, *material, density, localPose);
	else
		actor = PxCreateDynamic(*_physics, pose, geom, *material, density, localPose);
	
	// Transformarlo en trigger si es necesario
	if (trigger) {
		PxShape *shape;
		actor->getShapes(&shape, 1, 0);
		shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
		shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
	}

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

	// Establecer el grupo de colisión
	PxSetGroup(*actor, group);

	// Añadir el actor a la escena
	_scene->addActor(*actor);

	return actor;
}
开发者ID:NoisyBass,项目名称:Hulen,代码行数:45,代码来源:Server.cpp

示例11: setCCDActive

void SampleNorthPole::setCCDActive(PxShape& shape)
{
	
	shape.setFlag(PxShapeFlag::eUSE_SWEPT_BOUNDS,true);

	PxFilterData fd = shape.getSimulationFilterData();
	fd.word3 |= CCD_FLAG;
	shape.setSimulationFilterData(fd);
	
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:10,代码来源:SampleNorthPoleFilterShader.cpp

示例12: createDynamicSphere

physx::PxRigidDynamic* CPhysicManager::createDynamicSphere(const Vector3 &position, const float &radius, float mass, bool kinematic, bool trigger, int group, const Logic::Component::IPhysic *component)
{
    assert(m_scene);

    PxTransform pose(Vector3ToPxVec3(position));
    PxSphereGeometry geom(radius);
    PxMaterial *material = m_defaultMaterial;
    float density = mass / ((4/3) * Common::Util::Math::PI * radius * radius * radius);

    PxRigidDynamic *actor = nullptr;
    if(kinematic) {
        actor = PxCreateKinematic(*m_physics,pose,geom,*material,density);
    } else {
        actor = PxCreateDynamic(*m_physics,pose,geom,*material,density);
    }

    if(trigger) {
        PxShape *shape;
        actor->getShapes(&shape,1,0);
        shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
        shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
    }

    actor->userData = (void*)component;

    PxSetGroup(*actor,group);

    setupFiltering(actor,FilterGroup::eSPACE_FILTER,FilterGroup::eSPACE_FILTER);

    PxD6Joint* joint = PxD6JointCreate(*m_physics, actor, PxTransform::createIdentity(), nullptr, actor->getGlobalPose());
    joint->setMotion(PxD6Axis::eX,PxD6Motion::eFREE);
    joint->setMotion(PxD6Axis::eY,PxD6Motion::eLOCKED);
    joint->setMotion(PxD6Axis::eZ,PxD6Motion::eFREE);
    joint->setMotion(PxD6Axis::eSWING1,PxD6Motion::eFREE);
    joint->setMotion(PxD6Axis::eSWING2,PxD6Motion::eLOCKED);
    joint->setMotion(PxD6Axis::eTWIST,PxD6Motion::eLOCKED);
    //TODO release

    //m_scene->addActor(*actor);

    return actor;
}
开发者ID:Ithos,项目名称:TTG,代码行数:42,代码来源:PhysicManager.cpp

示例13: LoadTriangleMesh

void Apex::LoadTriangleMesh(int numVerts, PxVec3* verts, ObjectInfo info)
{
	PxRigidStatic* meshActor = mPhysics->createRigidStatic(PxTransform::createIdentity());
	PxShape* meshShape;
	if(meshActor)
	{
		
		PxTriangleMeshDesc meshDesc;
		meshDesc.points.count           = numVerts;
		meshDesc.points.stride          = sizeof(PxVec3);
		meshDesc.points.data            = verts;

		//meshDesc.triangles.count        = numInds/3.;
		//meshDesc.triangles.stride       = 3*sizeof(int);
		//meshDesc.triangles.data         = inds;

		PxToolkit::MemoryOutputStream writeBuffer;
		bool status = mCooking->cookTriangleMesh(meshDesc, writeBuffer);
		if(!status)
			return;

		PxToolkit::MemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());

		PxTriangleMeshGeometry triGeom;
		triGeom.triangleMesh = mPhysics->createTriangleMesh(readBuffer);
		triGeom.scale = PxMeshScale(PxVec3(info.sx,info.sy,info.sz),physx::PxQuat::createIdentity());
		
		meshShape = meshActor->createShape(triGeom, *defaultMaterial);
		meshShape->setLocalPose(PxTransform(PxVec3(info.x,info.y,info.z), PxQuat(info.ry, PxVec3(0.0f,1.0f,0.0f))));
		meshShape->setFlag(PxShapeFlag::eUSE_SWEPT_BOUNDS, true);


		meshShape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
		

		mScene[mCurrentScene]->addActor(*meshActor);
	}
}
开发者ID:schulchr,项目名称:Olympus,代码行数:38,代码来源:apex.cpp

示例14: createDynamicBox

PxRigidDynamic* CPhysicManager::createDynamicBox(const Vector3 &position, const Vector3 &dimensions,
        float mass, bool kinematic, bool trigger, int group,
        const IPhysic *component)
{
    assert(m_scene);

    PxTransform pose(Vector3ToPxVec3(position));
    PxBoxGeometry geom(Vector3ToPxVec3(dimensions));
    PxMaterial *material = m_defaultMaterial;
    float density = mass / (dimensions.x * dimensions.y * dimensions.z);
    PxTransform localPose(PxVec3(0, dimensions.y, 0));

    PxRigidDynamic *actor = nullptr;
    if(kinematic) {
        actor = PxCreateKinematic(*m_physics,pose,geom,*material,density,localPose);
    } else {
        actor = PxCreateDynamic(*m_physics,pose,geom,*material,density,localPose);
    }

    if(trigger) {
        PxShape *shape;
        actor->getShapes(&shape,1,0);
        shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
        shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
    }

    actor->userData = (void*)component;

    PxSetGroup(*actor,group);

    setupFiltering(actor,FilterGroup::eSPACE_FILTER,FilterGroup::eSPACE_FILTER);

    //m_scene->addActor(*actor);

    return actor;
}
开发者ID:Ithos,项目名称:TTG,代码行数:36,代码来源:PhysicManager.cpp

示例15: addSimpleObject

PxActor* addSimpleObject( PxScene* scene, 
                         PxPhysics* physics, 
                         PxTransform* transform, 
                         PxGeometry* geometry,
                         PxMaterial* material, 
                         bool isStatic, bool isKinematic )
{
    PxActor* actor;
    if( isStatic )
        actor = physics->createRigidStatic( *transform );
    else
    {
        actor = physics->createRigidDynamic( *transform );
        ((PxRigidDynamic*)(actor))->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, isKinematic);
    }

    PxShape* shape = ((PxRigidBody*)(actor))->createShape( *geometry, *material );

    if( isKinematic )
        shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);

    scene->addActor( *actor );
    return actor;
}
开发者ID:dexset,项目名称:physxwrap,代码行数:24,代码来源:wrap.cpp


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