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


C++ NxActor类代码示例

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


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

示例1: assert

//----------------------------------------------------------------------------
// ReleaseAllActors : Alliberem tots els actors de l'escena de PhysX 
//----------------------------------------------------------------------------
bool CPhysicsManager::ReleaseAllActors ( void ) //EUserDataFlag _eFlags )
{
	assert ( m_pScene != NULL );
	assert ( m_pPhysicsSDK != NULL );

	bool isOk = true;

	NxActor** l_ppActorList = m_pScene->getActors();
	NxU32 l_TotalActors		= m_pScene->getNbActors();

	while ( l_TotalActors -- )
	{
		NxActor* nxActor = *l_ppActorList;
		if ( nxActor != 0)
		{
			NxArray<NxCCDSkeleton*> skeletons;
			for (NxU32 i = 0; i < nxActor->getNbShapes(); i++) 
			{
				NxShape* shape = nxActor->getShapes()[i];
				if (shape->getCCDSkeleton() != NULL) {
					skeletons.pushBack(shape->getCCDSkeleton());
				}
			}

			for (NxU32 i = 0; i < skeletons.size(); i++) 
			{
				m_pPhysicsSDK->releaseCCDSkeleton(*skeletons[i]);
			}
			m_pScene->releaseActor(*nxActor);
			nxActor = 0;
		}
	}
	
	return isOk;
}
开发者ID:kusku,项目名称:red-forest,代码行数:38,代码来源:PhysicsManager.cpp

示例2: assert

bool CPhysicsManager::ReleasePhysicActor (CPhysicActor* actor)
{
	assert(actor != NULL);
	assert(m_pScene != NULL);
	assert(m_pPhysicsSDK != NULL);

	bool isOk = false;
	NxActor* nxActor = actor->GetPhXActor();

	if( nxActor != 0)
	{
		NxArray<NxCCDSkeleton*> skeletons;
		for (NxU32 i = 0; i < nxActor->getNbShapes(); i++) 
		{
			NxShape* shape = nxActor->getShapes()[i];
			if (shape->getCCDSkeleton() != NULL) {
				skeletons.pushBack(shape->getCCDSkeleton());
			}
		}

		for (NxU32 i = 0; i < skeletons.size(); i++) 
		{
			m_pPhysicsSDK->releaseCCDSkeleton(*skeletons[i]);
		}
		m_pScene->releaseActor(*nxActor);
		nxActor = 0;
	}
	
	return true;
}
开发者ID:ivantarruella,项目名称:TheOtherSide,代码行数:30,代码来源:PhysicsManager.cpp

示例3: SetupTearingScene

void SetupTearingScene()
{
    sprintf(gTitleString, "Tearing Demo");

	// Create the objects in the scene
	groundPlane = CreateGroundPlane();
	NxActor* bar = CreateBox(NxVec3(0,12,0), NxVec3(3,0.5,0.5), 0);
	NxActor* box = CreateBox(NxVec3(-2.3,4.0,0), NxVec3(0.5,0.5,0.5), 10); 

	// Cloth
	NxClothDesc clothDesc;
	clothDesc.globalPose.t = NxVec3(2.5,12,0);
	clothDesc.globalPose.M.rotX(-NxHalfPiF32);
	clothDesc.thickness = 0.1;
	clothDesc.tearFactor = 2;
	clothDesc.flags |= NX_CLF_BENDING;
	clothDesc.flags |= NX_CLF_COLLISION_TWOWAY;
	clothDesc.flags |= NX_CLF_TEARABLE | NX_CLF_VISUALIZATION; // Tearable cloth

	if (gHardwareCloth)
		clothDesc.flags |= NX_CLF_HARDWARE;

	MyCloth* regularCloth = new MyCloth(gScene, clothDesc, 5, 8, 0.1, "rug512.bmp", gTearLines);
	gCloths.push_back(regularCloth);

	regularCloth->getNxCloth()->attachToShape(*bar->getShapes(), 0);
	regularCloth->getNxCloth()->attachToShape(*box->getShapes(), NX_CLOTH_ATTACHMENT_TWOWAY);
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:28,代码来源:Lesson1006.cpp

示例4: GravitateToGravitators

void GravitateToGravitators()
{
	NxU32 nbActors = gScene->getNbActors();
	NxActor** actors = gScene->getActors();
	NxReal m1,m2,G=gUniversalBigG,R;
	NxVec3 r,F;
	while (nbActors--)
	{
		NxActor* actor = *actors++;
		const char* name=actor->getName();
		if (strcmp(name,"~lander")==0)
		{
			F.zero();
			m1=actor->getMass();
			for (int k=0; k<gRavitators.size(); k++)
			{
				r = (gRavitators[k]->getCMassGlobalPosition() - actor->getCMassGlobalPosition());
				R = r.magnitudeSquared();
				m2= gRavitators[k]->getMass();
				F = r;
				F.setMagnitude(G*m1*m2/R);
				actor->addForce(F);
			}
		}
	}
}
开发者ID:nmovshov,项目名称:ARSS_win,代码行数:26,代码来源:pods.cpp

示例5: MyCreateCapsule

void World::SetupFlagScene()
{
	NxActor* capsule = MyCreateCapsule(NxVec3(0.0f,-0.2f,0.0f), 10, 0.2f, 0);

	// Create Cloth
	NxClothDesc clothDesc;
	clothDesc.globalPose.t = NxVec3(0,10,0);
	clothDesc.globalPose.M.rotX(-NxHalfPiF32);
	clothDesc.thickness = 0.2;
	clothDesc.bendingStiffness = 0.5;
	clothDesc.dampingCoefficient = 1;
	clothDesc.flags |= NX_CLF_BENDING;
	//clothDesc.flags |= NX_CLF_DAMPING | NX_CLF_COMDAMPING;
	clothDesc.flags |= NX_CLF_COLLISION_TWOWAY | NX_CLF_VISUALIZATION;
	clothDesc.windAcceleration = NxVec3(-20, 20, 0);	// set wind

	MyCloth* regularCloth = new MyCloth(gScene, clothDesc, 5, 5, 0.15, "nvidia.bmp");

	if (!regularCloth->getNxCloth())
	{
		printf("Error: Cloth creation failed.\n");
		delete regularCloth;
	}
	else
	{
		gCloths.push_back(regularCloth);
		regularCloth->getNxCloth()->attachToShape(*capsule->getShapes(), NX_CLOTH_ATTACHMENT_TWOWAY);
	}
}
开发者ID:binly,项目名称:TestPhysx,代码行数:29,代码来源:MyCreateCloth.cpp

示例6: DrawLanders

void DrawLanders()
{
	// draw the landers in 2 colors
	NxU32 nbActors = gScene->getNbActors();
	NxActor** actors = gScene->getActors();
	while (nbActors--)
	{
		NxActor* actor = *actors++;
		const char *name=actor->getName();
		if (strcmp(name,"~lander")==0) {
			NxShape*const* shapes;
			shapes = actor->getShapes();
			NxU32 nShapes = actor->getNbShapes();
			//glDisable(GL_LIGHTING);
			char sname[256]="";
			while (nShapes--)
			{
				sprintf(sname,"%s",shapes[nShapes]->getName());
				if      (strcmp(sname,"upside")==0)
					glColor4f(0.0f,1.0f,0.0f,1.0f);
				else if (strcmp(sname,"downside")==0)
					glColor4f(1.0f,0.0f,0.0f,1.0f);
				else if (strcmp(sname,"U1")==0)
					glColor4f(1.0f,0.0f,0.0f,1.0f);
				else if (strcmp(sname,"U2")==0)
					glColor4f(0.0f,1.0f,0.0f,1.0f);
				else if (strcmp(sname,"U3")==0)
					glColor4f(0.0f,0.0f,1.0f,1.0f);
				DrawShape(shapes[nShapes], false);
			}
			//glEnable(GL_LIGHTING);
		}
	}
}
开发者ID:nmovshov,项目名称:ARSS_win,代码行数:34,代码来源:pods.cpp

示例7: while

//################################################################
//
// Body functions
//
pRigidBody*PhysicManager::getBody(const char*name,int flags/* =0 */)
{

	for (pWorldMapIt it  = getWorlds()->Begin(); it!=getWorlds()->End(); it++)
	{
		pWorld *w = *it;
		if(w)
		{
			int nbActors = w->getScene()->getNbActors();
			NxActor** actors = w->getScene()->getActors();
			while(nbActors--)
			{
				NxActor* actor = *actors++;
				if(actor->userData != NULL)
				{
					if (!strcmp(actor->getName(),name) )
					{

						pRigidBody* body =static_cast<pRigidBody*>(actor->userData);
						if (body)
						{
							return body;
						}
					}
				}
			}
		}
	}
	return 0;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:34,代码来源:PhysicManagerBody.cpp

示例8: CreateCube

static void CreateCube(const NxVec3& pos, int size=2, const NxVec3* initial_velocity=NULL, bool kinematic = false, bool Static = false)
{
	// Create body
	NxBodyDesc BodyDesc;
	BodyDesc.angularDamping	= 0.5f;
	//	BodyDesc.maxAngularVelocity	= 10.0f;
	if(initial_velocity)	BodyDesc.linearVelocity = *initial_velocity;

	NxBoxShapeDesc BoxDesc;
	BoxDesc.dimensions		= NxVec3(float(size), float(size), float(size));

	NxActorDesc ActorDesc;
	//	ActorDesc.userData		= (void*)size;
	ActorDesc.shapes.pushBack(&BoxDesc);
	if (!Static)
		ActorDesc.body			= &BodyDesc;
	ActorDesc.density		= 10.0f;
	ActorDesc.globalPose.t  = pos;
	ActorDesc.userData = (void*)size;

	NxActor* actor = gMyPhysX.getScene()->createActor(ActorDesc);

	if (kinematic) {
		KinematicActor k;
		k.actor = actor;
		actor->raiseBodyFlag(NX_BF_KINEMATIC);
		if (initial_velocity) {
			k.vel = *initial_velocity;
		} else {
			k.vel.set(0,0,0);
		}
		gKinematicActors.pushBack(k);
	}

}
开发者ID:flair2005,项目名称:Physx,代码行数:35,代码来源:SampleTrigger.cpp

示例9: CreateBoard

NxActor* CreateBoard(const NxVec3& pos)
{
	NxActor* actor = CreateBox(pos + NxVec3(0,0.5,0), NxVec3(1,0.25,0.5), 10);
	actor->raiseBodyFlag(NX_BF_FROZEN_ROT_X);
	actor->setAngularDamping(0.5);

	// Left wheel
	NxWheelDesc wheelDesc;
	//wheelDesc.wheelAxis.set(0,0,1);
	//wheelDesc.downAxis.set(0,-1,0);
    wheelDesc.wheelApproximation = 10;
	wheelDesc.wheelRadius = 0.5;
	wheelDesc.wheelWidth = 0.1;
	wheelDesc.wheelSuspension = 0.5;
//	wheelDesc.wheelSuspension = 1.0;
	wheelDesc.springRestitution = 7000;
	wheelDesc.springDamping = 0;
	wheelDesc.springBias = 0;  
//	wheelDesc.springRestitution = 20;
//	wheelDesc.springDamping = 0.5;
//	wheelDesc.springBias = 0; 
	wheelDesc.maxBrakeForce = 1;
	wheelDesc.frictionToFront = 0.1;
	wheelDesc.frictionToSide = 0.99;
	wheelDesc.position = NxVec3(1.5,0.5,0);
	wheelDesc.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
		                   NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;

    wheel1 = AddWheelToActor(actor, &wheelDesc);

	// Right wheel
	NxWheelDesc wheelDesc2;
	//wheelDesc2.wheelAxis.set(0,0,1);
	//wheelDesc2.downAxis.set(0,-1,0);
    wheelDesc2.wheelApproximation = 10;
	wheelDesc2.wheelRadius = 0.5;
	wheelDesc2.wheelWidth = 0.1;
	wheelDesc2.wheelSuspension = 0.5;
//	wheelDesc2.wheelSuspension = 1.0;  
	wheelDesc2.springRestitution = 7000;
	wheelDesc2.springDamping = 0;
	wheelDesc2.springBias = 0;
//	wheelDesc2.springRestitution = 20;
//	wheelDesc2.springDamping = 0.5;
//	wheelDesc2.springBias = 0;  
	wheelDesc2.maxBrakeForce = 1;
	wheelDesc2.frictionToFront = 0.1;
	wheelDesc2.frictionToSide = 0.99;
	wheelDesc2.position = NxVec3(-1.5,0.5,0);
	wheelDesc2.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
		                    NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;

    wheel2 = AddWheelToActor(actor, &wheelDesc2);

	return actor;
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:56,代码来源:Lesson702.cpp

示例10: KeyboardUpCallback

void KeyboardUpCallback(unsigned char key, int x, int y)
{
	gKeys[key] = false;

	switch (key)
	{
		case 'p': { bPause = !bPause; 
					if (bPause)
						hud.SetDisplayString(2, "Paused - Hit \"p\" to Unpause", 0.3f, 0.55f);
					else
						hud.SetDisplayString(2, "", 0.0f, 0.0f);	
					break; }
		case 'x': { bShadows = !bShadows; break; }
		case 'b': { bDebugWireframeMode = !bDebugWireframeMode; break; }		
		case 'f': { bForceMode = !bForceMode; break; }

		case 'o': 
		{     
			NxCloth** cloths = gScene->getCloths();
			for (NxU32 i = 0; i < gScene->getNbCloths(); i++) 
			{
				cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_BENDING_ORTHO);
			}
			break;
		}

		case 'g': 
		{     
			NxCloth** cloths = gScene->getCloths();
			for (NxU32 i = 0; i < gScene->getNbCloths(); i++) 
			{
				cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_GRAVITY);
			}
			break;
		}

		case 'y': 
		{
			NxCloth** cloths = gScene->getCloths();
			for (NxU32 i = 0; i < gScene->getNbCloths(); i++) 
			{
				cloths[i]->setFlags(cloths[i]->getFlags() ^ NX_CLF_BENDING);
			}	            
			break;
		}
		case ' ': 
		{
			NxActor* sphere = CreateSphere(gCameraPos, 1, 1);
			sphere->setLinearVelocity(gCameraForward * 20);
			break; 
		}
		case 27 : { exit(0); break; }
		default : { break; }
	}
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:55,代码来源:Lesson1005.cpp

示例11: AssertFatal

void PxWorld::_releaseQueues()
{
   AssertFatal( mScene, "PhysXWorld::_releaseQueues() - The scene is null!" );

   // We release joints still pending in the queue 
   // first as they depend on the actors.
   for ( S32 i = 0; i < mReleaseJointQueue.size(); i++ )
   {
      NxJoint *currJoint = mReleaseJointQueue[i];
      mScene->releaseJoint( *currJoint );
   }
   
   // All the joints should be released, clear the queue.
   mReleaseJointQueue.clear();

   // Now release any actors still pending in the queue.
   for ( S32 i = 0; i < mReleaseActorQueue.size(); i++ )
   {
      NxActor *currActor = mReleaseActorQueue[i];
      
      bool isStatic = !currActor->isDynamic();

      mScene->releaseActor( *currActor );

      if ( isStatic )
         PhysicsStatic::smDeleteSignal.trigger();
   }

   // All the actors should be released, clear the queue.
   mReleaseActorQueue.clear();

   // Now release any cloth still pending in the queue.
   for ( S32 i = 0; i < mReleaseClothQueue.size(); i++ )
   {
      NxCloth *currCloth = mReleaseClothQueue[i];
      mScene->releaseCloth( *currCloth );
   }

   // All the actors should be released, clear the queue.
   mReleaseClothQueue.clear();

   // Release heightfields that don't still have references.
   for ( S32 i = 0; i < mReleaseHeightFieldQueue.size(); i++ )
   {
      NxHeightField *currHeightfield = mReleaseHeightFieldQueue[i];
      
      if ( currHeightfield->getReferenceCount() == 0 )
      {
         gPhysicsSDK->releaseHeightField( *currHeightfield );      
         mReleaseHeightFieldQueue.erase_fast( i );
         i--;
      }
   }
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:54,代码来源:pxWorld.cpp

示例12: IdentifyGravitators

void IdentifyGravitators()
{
	gRavitators.clear();
	NxU32 nbActors = gScene->getNbActors();
	NxActor** actors = gScene->getActors();
	while (nbActors--)
	{
		NxActor* actor = *actors++;
		if (actor->getMass()>gRavitatorThresholdMass)
			gRavitators.push_back(actor);
	}
}
开发者ID:nmovshov,项目名称:ARSS_win,代码行数:12,代码来源:pods.cpp

示例13: NxVec3

void World::SetupAnimalScene()
{
	// Create the objects in the scene
	NxSoftBodyDesc softBodyDesc;
	softBodyDesc.globalPose.t		= NxVec3(0.0f, 3.0f, 0.0f);
	softBodyDesc.particleRadius		= 0.2f;
	softBodyDesc.volumeStiffness	= 0.5f;
	softBodyDesc.stretchingStiffness= 1.0f;
	softBodyDesc.friction			= 1.0f;
	softBodyDesc.attachmentResponseCoefficient = 0.1f;
	softBodyDesc.solverIterations	= 5;

	char *fileName = "froggyNormalized";

	char tetFileName[256], objFileName[256], s[256];
	sprintf(tetFileName, "%s.tet", fileName);
	sprintf(objFileName, "%s.obj", fileName);

	ObjMesh *objMesh = new ObjMesh();
	objMesh->loadFromObjFile(FindMediaFile(objFileName, s));
	gObjMeshes.pushBack(objMesh);

	if(objMesh == NULL)
	{
		printf("objMesh %s\n");
	}

	NxMat33 rot;
	rot.rotX(NxHalfPiF32);

	for (int i = 0; i < 5; i++)
	{
		softBodyDesc.globalPose.t	= NxVec3(0, 3+i*3, 0);
		MySoftBody *softBody		= new MySoftBody(gScene, softBodyDesc, FindMediaFile(tetFileName, s), objMesh);
		assert(softBody);
		if (!softBody->getNxSoftBody())
		{
			printf("Error: unable to create the softbody for the current scene.\n");
			delete softBody;
		}
		else
		{
			gSoftBodies.pushBack(softBody);
			NxActor *caps = MyCreateCapsule(NxVec3(0.0f, 3.0f + i*3.0f, -0.3f), 1.0f, 0.73f, 1.0f);
			caps->userData = (void*)&gInvisible;
			caps->setGlobalOrientation(rot);
			softBody->getNxSoftBody()->attachToShape(caps->getShapes()[0], NX_SOFTBODY_ATTACHMENT_TWOWAY);
		}
	}
}
开发者ID:binly,项目名称:TestPhysx,代码行数:50,代码来源:MyPhysx.cpp

示例14: onTrigger

void myTrigger::onTrigger(NxShape& triggerShape, NxShape& otherShape, NxTriggerFlag status){

	if ( ! triggerShape.getActor().userData && ! otherShape.getActor().userData )
	{
		return;
	}
	
	if (status & NX_TRIGGER_ON_ENTER)
	{
		// A body just entered the trigger area
		NxActor* triggerActor = &triggerShape.getActor();
		String name = triggerActor->getName();
		int thisTarget = StringConverter::parseInt(name);
		creditTarget(thisTarget);
	}
	
}
开发者ID:bytewrench,项目名称:NxOgre-Pinball,代码行数:17,代码来源:trigger.cpp

示例15: handle

	virtual bool handle( const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
	{
		osgViewer::Viewer *viewer=dynamic_cast<osgViewer::Viewer*>(&aa);
		if(!viewer) return false;

		switch(ea.getEventType())
		{
		case osgGA::GUIEventAdapter::FRAME:
			{
				//printf("Time %f\n",ea.getTime());
				gMyPhysX.simulate(1.0f/60.0f);
				int nbActors = gMyPhysX.getScene()->getNbActors();
				NxActor** actors = gMyPhysX.getScene()->getActors();
				//int userdateNum = 0;
				while(nbActors--)
				{
					NxActor* actor = *actors++;
					if(!actor->userData) continue;
					osg::MatrixTransform *mt = static_cast<osg::MatrixTransform*>(actor->userData);
					if (mt)
					{
						float glmat[16];      
						actor->getGlobalPose().getColumnMajor44(glmat);//得到角色的世界位置			

						osg::Matrix mat;
						mat.set(glmat);
						mt->setMatrix(mat);
						//userdateNum+=1;
						//printf("userdateNum = %d\n",userdateNum);
					}
				}				
				return false;
			}
		case(osgGA::GUIEventAdapter::KEYDOWN):
			{
				if(ea.getKey()=='w'||ea.getKey()=='W')
				{
					CreateCubeFromEye(2,viewer->getCamera());
				}
				return false;
			}
		default:
			return false;
		}
	}
开发者ID:flair2005,项目名称:Physx,代码行数:45,代码来源:OSGPHYSX_Tutorial.cpp


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