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


C++ PxRigidActor类代码示例

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


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

示例1: GetActorFromHandle

void PhysX3::ApplyActionAtPoint(PintObjectHandle handle, PintActionType action_type, const Point& action, const Point& pos)
{
	PxRigidActor* RigidActor = GetActorFromHandle(handle);
	if(!RigidActor)
	{
		PxShape* Shape = GetShapeFromHandle(handle);
		ASSERT(Shape);
#ifdef SUPPORT_SHARED_SHAPES
		RigidActor = Shape->getActor();
#else
		RigidActor = &Shape->getActor();
#endif
	}

	if(RigidActor->getConcreteType()==PxConcreteType::eRIGID_DYNAMIC)
	{
		PxRigidDynamic* RigidDynamic = static_cast<PxRigidDynamic*>(RigidActor);
		if(!(RigidDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC))
		{
			PxForceMode::Enum mode;
			if(action_type==PINT_ACTION_FORCE)
				mode = PxForceMode::eFORCE;
			else if(action_type==PINT_ACTION_IMPULSE)
				mode = PxForceMode::eIMPULSE;
			else ASSERT(0);

			PxRigidBodyExt::addForceAtPos(*RigidDynamic, ToPxVec3(action), ToPxVec3(pos), mode);
		}
	}
}
开发者ID:DevO2012,项目名称:PEEL,代码行数:30,代码来源:PINT_CommonPhysX3.cpp

示例2: PxScaleRigidActor

void PxScaleRigidActor(PxRigidActor& actor, PxReal scale, bool scaleMassProps)
{
	PX_CHECK_AND_RETURN(scale > 0,
		"PxScaleRigidActor requires that the scale parameter is greater than zero");

	Ps::InlineArray<PxShape*, 64> shapes;
	shapes.resize(actor.getNbShapes());
	actor.getShapes(shapes.begin(), shapes.size());

	for(PxU32 i=0;i<shapes.size();i++)
	{
		shapes[i]->setLocalPose(scalePosition(shapes[i]->getLocalPose(), scale));		
		PxGeometryHolder h = shapes[i]->getGeometry();

		switch(h.getType())
		{
		case PxGeometryType::eSPHERE:	
			h.sphere().radius *= scale;			
			break;
		case PxGeometryType::ePLANE:
			break;
		case PxGeometryType::eCAPSULE:
			h.capsule().halfHeight *= scale;
			h.capsule().radius *= scale;
			break;
		case PxGeometryType::eBOX:
			h.box().halfExtents *= scale;
			break;
		case PxGeometryType::eCONVEXMESH:
			h.convexMesh().scale.scale *= scale;
			break;
		case PxGeometryType::eTRIANGLEMESH:
			h.triangleMesh().scale.scale *= scale;
			break;
		case PxGeometryType::eHEIGHTFIELD:
			h.heightField().heightScale *= scale;
			h.heightField().rowScale *= scale;
			h.heightField().columnScale *= scale;
			break;
		case PxGeometryType::eINVALID:
		case PxGeometryType::eGEOMETRY_COUNT:
		default:
			PX_ASSERT(0);
		}
		shapes[i]->setGeometry(h.any());
	}

	if(!scaleMassProps)
		return;

	PxRigidDynamic* dynamic = (&actor)->is<PxRigidDynamic>();
	if(!dynamic)
		return;

	PxReal scale3 = scale*scale*scale;
	dynamic->setMass(dynamic->getMass()*scale3);
	dynamic->setMassSpaceInertiaTensor(dynamic->getMassSpaceInertiaTensor()*scale3*scale*scale);
	dynamic->setCMassLocalPose(scalePosition(dynamic->getCMassLocalPose(), scale));
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:59,代码来源:ExtSimpleFactory.cpp

示例3: setMatrix

void PhysXInterface::setMatrix( int id, const osg::Matrix& matrix )
{
    PxReal d[16];
    for ( int i=0; i<16; ++i ) d[i] = *(matrix.ptr() + i);
    
    PxRigidActor* actor = _actors[id];
    if ( actor ) actor->setGlobalPose( PxTransform(PxMat44(d)) );
}
开发者ID:512400330,项目名称:osgRecipes,代码行数:8,代码来源:PhysXInterface.cpp

示例4: PxVec3

        int RayCastManagerImpl::CastSweep(const XMFLOAT3& p_origin, XMFLOAT3& p_direction, float p_width, const float& p_range, int& o_flag)
        {
            if(p_range <= 0.0f)
            {
                cout << "Physcs. Raytracer. Sweep. Range of sweep was zero or below" << endl;
                return -1;
            }
            // Cast directx things to physx
            PxVec3 origin = PxVec3(p_origin.x, p_origin.y, p_origin.z);
            PxVec3 direction = PxVec3(p_direction.x, p_direction.y, p_direction.z);
            direction.normalize();
            PxSweepBuffer hit; // Used to save the hit
            /// Paramters for the sweep
            // PxGeometry* geometry
            bool status = m_utils.m_worldScene->sweep(PxSphereGeometry(p_width), PxTransform(origin), direction, p_range, hit, PxHitFlag::eMESH_BOTH_SIDES);
            // hit.block.position;
            if(!status && !hit.hasBlock)
            {
                // No hit detected, return -1 TODOKO Maybee i should return something better?
                return -1;
            }

            // Start with checking static and dynamic rigid bodies
            unordered_map<PxRigidActor*, int> idsByRigidBody = m_utils.m_rigidBodyManager->GetIDsByBodies();
            if(idsByRigidBody.find(hit.block.actor) != idsByRigidBody.end())
            {
                PxRigidActor* actorAsRigic = (PxRigidActor*)hit.block.actor;
                if(actorAsRigic->isRigidDynamic())
                {
                    PxRigidDynamic* actorsAsDynamic = (PxRigidDynamic*)hit.block.actor;
                    if(actorsAsDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC)
                    {
                        o_flag = 0;
                    }
                }
                else if(actorAsRigic->isRigidStatic())
                {
                    o_flag = 3;
                }
                return idsByRigidBody.find(hit.block.actor)->second;
            }
            else
            {
                // Nothing
            }
            // Now comes the difficult task of checking vs character controllers
            unordered_map<PxController*, int> idsByCharacterController = m_utils.m_characterControlManager->GetIdsByControllers();
            for(auto pairs : idsByCharacterController) // Loop through every pair in the list
            {
                if(pairs.first->getActor() == hit.block.actor) // The first part contains the actor pointer
                {
                    o_flag = 1;
                    return pairs.second; // If this is true we found a hit vs character controller, second contains ID
                }
            }

            return -1;
        }
开发者ID:Meraz,项目名称:doremi,代码行数:58,代码来源:RayCastManagerImpl.cpp

示例5: PxSetGroupsMask

void physx::PxSetGroupsMask(const PxRigidActor& actor, const PxGroupsMask& mask)
{
	PxFilterData tmp;
	PxFilterData fd = convert(mask);

	if (actor.getNbShapes() == 1)
	{
		PxShape* shape = NULL;
		actor.getShapes(&shape, 1);

		// retrieve current group
		tmp = shape->getSimulationFilterData();
		fd.word0 = tmp.word0;

		// set new filter data
		shape->setSimulationFilterData(fd);
	}
	else
	{
		PxShape* shape;
		PxU32 numShapes = actor.getNbShapes();
		shdfnd::InlineArray<PxShape*, 64> shapes;
		if(numShapes > 64)
		{
			shapes.resize(64);
		}
		else
		{
			shapes.resize(numShapes);
		}

		PxU32 iter = 1 + numShapes/64;

		for(PxU32 i=0; i < iter; i++)
		{
			PxU32 offset = i * 64;
			PxU32 size = numShapes - offset;
			if(size > 64)
				size = 64;

			actor.getShapes(shapes.begin(), size, offset);

			for(PxU32 j = size; j--;)
			{
				// retrieve current group mask
				shape = shapes[j];
				// retrieve current group
				tmp = shape->getSimulationFilterData();
				fd.word0 = tmp.word0;

				// set new filter data
				shape->setSimulationFilterData(fd);

			}
		}
	}
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:57,代码来源:ExtDefaultSimulationFilterShader.cpp

示例6: PxSetGroup

void physx::PxSetGroup(const PxRigidActor& actor, const PxU16 collisionGroup)
{	
	PX_CHECK_AND_RETURN(collisionGroup < 32,"Collision group must be less than 32");

	PxFilterData fd;
	
	if (actor.getNbShapes() == 1)
	{
		PxShape* shape = NULL;
		actor.getShapes(&shape, 1);

		// retrieve current group mask
		fd = shape->getSimulationFilterData();
		fd.word0 = collisionGroup;
		
		// set new filter data
		shape->setSimulationFilterData(fd);
	}
	else
	{
		PxShape* shape;
		PxU32 numShapes = actor.getNbShapes();
		shdfnd::InlineArray<PxShape*, 64> shapes;
		if(numShapes > 64)
		{
			shapes.resize(64);
		}
		else
		{
			shapes.resize(numShapes);
		}

		PxU32 iter = 1 + numShapes/64;

		for(PxU32 i=0; i < iter; i++)
		{
			PxU32 offset = i * 64;
			PxU32 size = numShapes - offset;
			if(size > 64)
				size = 64;

			actor.getShapes(shapes.begin(), size, offset);

			for(PxU32 j = size; j--;)
			{
				// retrieve current group mask
				shape = shapes[j];
				fd = shape->getSimulationFilterData();
				fd.word0 = collisionGroup;

				// set new filter data
				shape->setSimulationFilterData(fd);
			}
		}
	}
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:56,代码来源:ExtDefaultSimulationFilterShader.cpp

示例7:

void 
PhysXRigidManager::move(std::string scene, float * transform) {
	if (rigidBodies.find(scene) != rigidBodies.end()) {
		PxRigidActor * actor = rigidBodies[scene].info.actor->is<PxRigidActor>();
		if (actor) {
			rigidBodies[scene].info.extInfo.transform = transform;
			actor->setGlobalPose(PxTransform(PxMat44(transform)));
		}
	}
}
开发者ID:david-leal,项目名称:nau,代码行数:10,代码来源:physXRigidManager.cpp

示例8: PxGetGroupsMask

PxGroupsMask physx::PxGetGroupsMask(const PxRigidActor& actor)
{
	PX_CHECK_AND_RETURN_VAL(actor.getNbShapes() >= 1,"At least one shape must be in actor",PxGroupsMask());

	PxShape* shape = NULL;
	actor.getShapes(&shape, 1);

	PxFilterData fd = shape->getSimulationFilterData();
	
	return convert(fd);
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:11,代码来源:ExtDefaultSimulationFilterShader.cpp

示例9: PxGetGroup

PxU16 physx::PxGetGroup(const PxRigidActor& actor)
{
	PX_CHECK_AND_RETURN_NULL(actor.getNbShapes() >= 1,"There must be a shape in actor");

	PxShape* shape = NULL;
	actor.getShapes(&shape, 1);

	PxFilterData fd = shape->getSimulationFilterData();

	return (PxU16)fd.word0;
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:11,代码来源:ExtDefaultSimulationFilterShader.cpp

示例10: computeCameraTarget

PxExtendedVec3 SampleNorthPoleCameraController::computeCameraTarget()
{
	PxRigidActor* characterActor = mCCT.getActor();
	PxShape* shape;
	characterActor->getShapes(&shape,1);
	PxCapsuleGeometry geom;
	shape->getCapsuleGeometry(geom);

	const PxExtendedVec3 headPos = PxExtendedVec3(0,geom.halfHeight+geom.radius,0);
	return mCCT.getPosition() + headPos;
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:11,代码来源:SampleNorthPoleCameraController.cpp

示例11: getMatrix

osg::Matrix PhysXInterface::getMatrix( int id )
{
    PxRigidActor* actor = _actors[id];
    if ( actor )
    {
        float m[16];
        PxMat44 pxMat( actor->getGlobalPose() );
        for ( int i=0; i<16; ++i ) m[i] = *(pxMat.front() + i);
        return osg::Matrix(&m[0]);
    }
    return osg::Matrix();
}
开发者ID:512400330,项目名称:osgRecipes,代码行数:12,代码来源:PhysXInterface.cpp

示例12: PxU16

void PhysXHeightfield::InitHeightfield(PxPhysics* physics, PxScene* scene, const char* filename)
{
	float xScale = 0.0025f;
	float yScale = 0.0025f;
	float zScale = 10.00f;

	
	// NOTE: Assuming that heightfield texture has B8G8R8A8 format.
	if(LoadHeightfield(filename)) 
	{
		PxU16 nbColumns = PxU16(mHeightfield.width);
		PxU16 nbRows = PxU16(mHeightfield.height);

		PxHeightFieldDesc heightFieldDesc;
        heightFieldDesc.format             = PxHeightFieldFormat::eS16_TM;
		heightFieldDesc.nbColumns = nbColumns;
		heightFieldDesc.nbRows = nbRows;
		heightFieldDesc.samples.data = mHeightfield.data;
		heightFieldDesc.samples.stride = sizeof(PxHeightFieldSample);
		//heightFieldDesc.convexEdgeThreshold = 0;

		PxHeightField* heightField = physics->createHeightField(heightFieldDesc);
		// create shape for heightfield		
		PxTransform pose(PxVec3(-((PxReal)nbRows*yScale) / 2.0f, 
								0.0f, 
								-((PxReal)nbColumns*xScale) / 2.0f),  
						PxQuat::createIdentity());
       // PxTransform pose = PxTransform::createIdentity();
	    pose.p = PxVec3(-((nbColumns/2)*xScale),0.0,-((nbColumns/2)*xScale));

		PxRigidActor* hf = physics->createRigidStatic(pose);
        if(!hf) 
		    return;

		const PxMaterial* mMat = physics->createMaterial(0.9f, 0.9f, 0.001f);
		//PxShape* shape = hf->createShape((PxHeightFieldGeometry(heightField, PxMeshGeometryFlags(), yScale, xScale, xScale)), *mMat);

		//PxHeightFieldGeometry hfGeom(heightField, PxMeshGeometryFlags(), heightScale, rowScale, colScale);
		//PxShape* aHeightFieldShape = aHeightFieldActor->createShape(hfGeom, aMaterialArray, nbMaterials);

        PxHeightFieldGeometry hfGeom(heightField, PxMeshGeometryFlags(), yScale, xScale, xScale);
	    PxShape* hfShape = hf->createShape(hfGeom, *mMat);
	    if(!hfShape) 
		    return;

		//shape->setFlag(PxShapeFlag::ePARTICLE_DRAIN, false);
		//shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
		//shape->setFlag(PxShapeFlag::eUSE_SWEPT_BOUNDS, true);
		// add actor to the scene
		scene->addActor(*hf);
	}
}
开发者ID:clucasa,项目名称:Olympus,代码行数:52,代码来源:PhysXHeightField.cpp

示例13: computeCameraRay

bool Picking::pick(int x, int y)
{
	PxScene& scene = mFrame.getActiveScene();

	PxVec3 rayOrig, rayDir, pickOrig;
	computeCameraRay(rayOrig, rayDir, pickOrig, x, y);

	// raycast rigid bodies in scene
	PxRaycastHit hit; hit.shape = NULL;
	PxRaycastBuffer hit1;
	scene.raycast(rayOrig, rayDir, PX_MAX_F32, hit1, PxHitFlag::ePOSITION);
	hit = hit1.block;

	if(hit.shape)
	{ 
		const char* shapeName = hit.shape->getName();
		if(shapeName)
			printf("Picked shape name: %s\n", shapeName);

		PxRigidActor* actor = hit.actor;
		PX_ASSERT(actor);
		mSelectedActor = static_cast<PxRigidActor*>(actor->is<PxRigidDynamic>());
		if(!mSelectedActor)
			mSelectedActor = static_cast<PxRigidActor*>(actor->is<PxArticulationLink>());

		//ML::this is very useful to debug some collision problem
		PxTransform t = actor->getGlobalPose();

	//	printf("id = %i\n PxTransform transform(PxVec3(%f, %f, %f), PxQuat(%f, %f, %f, %f))\n", (int)actor->userData, t.p.x, t.p.y, t.p.z, t.q.x, t.q.y, t.q.z, t.q.w);
	}
	else
	{
		mSelectedActor = 0;
	}

	if(mSelectedActor)
	{
		printf("Actor '%s' picked! (userData: %p)\n", mSelectedActor->getName(), mSelectedActor->userData);

		//if its a dynamic rigid body, joint it for dragging purposes:
		grabActor(hit.position, rayOrig);
	}

#ifdef VISUALIZE_PICKING_RAYS
	Ray ray;
	ray.origin = rayOrig;
	ray.dir = rayDir;
	mRays.push_back(ray);
#endif
	return true;
}
开发者ID:gabrielarabelo,项目名称:KarlSims,代码行数:51,代码来源:Picking.cpp

示例14: grabActor

void Picking::grabActor(const PxVec3& worldImpact, const PxVec3& rayOrigin)
{
	if(!mSelectedActor 
		|| (mSelectedActor->getType() != PxActorType::eRIGID_DYNAMIC 
		&& mSelectedActor->getType() != PxActorType::eARTICULATION_LINK))
		return;

	PxScene& scene = mFrame.getActiveScene();
	PxPhysics& physics = scene.getPhysics();

	//create a shape less actor for the mouse
	{
		mMouseActor = physics.createRigidDynamic(PxTransform(worldImpact, PxQuat::createIdentity()));
		mMouseActor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true); 
		mMouseActor->setMass(1.0f);
		mMouseActor->setMassSpaceInertiaTensor(PxVec3(1.0f, 1.0f, 1.0f));

		scene.addActor(*mMouseActor);

		mFrame.addPhysicsActors(mMouseActor);
	}
	PxRigidActor* pickedActor = static_cast<PxRigidActor*>(mSelectedActor);

#if USE_D6_JOINT_FOR_MOUSE
	mMouseJoint = PxD6JointCreate(		physics,
										mMouseActor,
										PxTransform::createIdentity(),
										pickedActor,
										PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact)));
#elif USE_SPHERICAL_JOINT_FOR_MOUSE
	mMouseJoint = PxSphericalJointCreate(physics,
										mMouseActor,
										PxTransform::createIdentity(),
										pickedActor,
										PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact)));
#else
	mMouseJoint = PxDistanceJointCreate(physics, 
										mMouseActor, 
										PxTransform::createIdentity(),
										pickedActor,
										PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact)));
	mMouseJoint->setMaxDistance(0.0f);
	mMouseJoint->setMinDistance(0.0f);
	mMouseJoint->setDistanceJointFlags(PxDistanceJointFlag::eMAX_DISTANCE_ENABLED);
#endif

	mDistanceToPicked = (worldImpact - rayOrigin).magnitude();
}
开发者ID:akurt5,项目名称:AIEShit,代码行数:48,代码来源:Picking.cpp

示例15: GetActorFromHandle

void PhysX::AddWorldImpulseAtWorldPos(PintObjectHandle handle, const Point& world_impulse, const Point& world_pos)
{
	PxRigidActor* RigidActor = GetActorFromHandle(handle);
	if(!RigidActor)
	{
		PxShape* Shape = GetShapeFromHandle(handle);
		ASSERT(Shape);
		RigidActor = &Shape->getActor();
	}

	if(RigidActor->getConcreteType()==PxConcreteType::eRIGID_DYNAMIC)
	{
		PxRigidDynamic* RigidDynamic = static_cast<PxRigidDynamic*>(RigidActor);
		PxRigidBodyExt::addForceAtPos(*RigidDynamic, ToPxVec3(world_impulse), ToPxVec3(world_pos), PxForceMode::eIMPULSE);
	}
}
开发者ID:Pierre-Terdiman,项目名称:PEEL,代码行数:16,代码来源:PINT_PhysX32.cpp


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