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


C++ NxVec3函数代码示例

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


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

示例1: onSleep

	virtual void onSleep(NxActor** actors, NxU32 count)
	{
		while(count--)
		{
			NxActor *thisActor = *actors;
			// do whatever you need to do
			// with actors that have gone to sleep
			if(thisActor->userData)   //sleep 之后改变颜色
			{
				static_cast<UserData*>(thisActor->userData)->color = NxVec3(1.0f,1.0f,0.0f);
			}
			actors++;
		}
	}
开发者ID:flair2005,项目名称:Physx,代码行数:14,代码来源:ex3_terrain.cpp

示例2: assert

void CPhysicActor::AddPlaneShape (const Vect3f& normal, float distance, uint32 group)
{
	assert(m_pPhXActorDesc);

	// Add a plane shape to the actor descriptor
	NxPlaneShapeDesc *planeDesc = new NxPlaneShapeDesc();
	assert(planeDesc);
	planeDesc->group = group;
	m_vPlaneDesc.push_back(planeDesc);
	planeDesc->normal	= NxVec3( normal.x, normal.y, normal.z);
	planeDesc->d	 = distance;
	m_pPhXActorDesc->shapes.pushBack( planeDesc );

}
开发者ID:BGCX261,项目名称:zombigame-svn-to-git,代码行数:14,代码来源:PhysicActor.cpp

示例3: mSpeed

//---------------------------------------------------------------------------------------------------------
Vehicle::Vehicle(const std::string &fileName,Ogre::SceneManager* sm,
				 Ogre::RenderWindow* win, NxScene* ns, 
				 const Ogre::Vector3 pos, const Ogre::Quaternion ori):
                 mSpeed(0), mAngle(0),mAngleDelta(0),mTurnLeft(0),mTurnRight(0),mRollAngle(0)
{

	//初始化各种变量
	mSceneMgr		= sm;
	mWindow			= win;
	mOriginalPos	= pos;
	mOriginalQuat	= ori;
	mNxScene		= ns;
	//mVehicleInfo.loadFromFile("carinfo.cfg");	
	mDecalShadow = NULL;

	VehicleWheel vw;
	mWheels.push_back(vw);
	mWheels.push_back(vw);
	mWheels.push_back(vw);
	mWheels.push_back(vw);

	loadScene(fileName);

	//load parameter data from file
	Ogre::FileInfoListPtr fp = 
		Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Popular", fileName + ".vpf");
	Ogre::String total = fp->back().archive->getName() + "\\" + fileName + ".vpf";
	mVehicleParam.loadFromFile(total);
	refreshParameter();

	mCarNode = mBaseCarNode;

	//创建摄像机节点
	mCameraDerivedNode = mCarNode->createChildSceneNode(Ogre::Vector3(0.0f, mBoundingBox.getSize().y, -mBoundingBox.getSize().z*2));
	mVehicleCamer = new VehicleCamera(fileName + "VehicleCamera", mWindow, mSceneMgr);
	mVehicleCamer->setTarget(mCameraDerivedNode, mCarNode);
	mVehicleCamer->setTightness(2.5f);

	//获取VehicleCamera计算后得到的CameraNode
	mCameraNode = mVehicleCamer->getCameraNode();

	//创建车的附加物体外设
	createPeriphery();

	CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), "Radial Blur");
	CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), "Radial Blur", false);

	tforce = ttortue = NxVec3(0, 0, 0);
	isJet = false;
}
开发者ID:flair2005,项目名称:Racing-Game,代码行数:51,代码来源:Vehicle.cpp

示例4: CreateCube

static void CreateCube(const NxVec3& pos, const NxVec3 * vel = 0)
	{
	// Avoid creating one compound within another
	NxBounds3 bounds;
	bounds.setCenterExtents(pos, NxVec3(10.0f, 10.0f, 10.0f));
	if(gScene->checkOverlapAABB(bounds))
		return;

	// Create cube made up of 6 individual boxes as its faces, with each box having a different material
	NxActorDesc actorDesc;
	NxBodyDesc bodyDesc;
	bodyDesc.linearVelocity.set(0,5,0);
	if (vel)
		bodyDesc.linearVelocity += *vel;

	bodyDesc.angularVelocity.set(NxMath::rand(0.0f,10.0f),NxMath::rand(0.0f,10.0f),NxMath::rand(0.0f,10.0f));	//throw up the ball with a random initial angular vel as if to roll dice.
	
	NxBoxShapeDesc boxDesc[6];
	boxDesc[0].dimensions.set(4,4,1);
	boxDesc[0].localPose.t.set(0,0,4);
	boxDesc[0].materialIndex	= defaultMaterialIndex;
	actorDesc.shapes.pushBack(&boxDesc[0]);
	boxDesc[1].dimensions.set(4,4,1);
	boxDesc[1].localPose.t.set(0,0,-4);
	boxDesc[1].materialIndex	= somewhatBouncyMaterialIndex;
	actorDesc.shapes.pushBack(&boxDesc[1]);
	boxDesc[2].dimensions.set(4,1,4);
	boxDesc[2].localPose.t.set(0,4,0);
	boxDesc[3].materialIndex	= veryBouncyMaterialIndex;
	actorDesc.shapes.pushBack(&boxDesc[2]);
	boxDesc[3].dimensions.set(4,1,4);
	boxDesc[3].localPose.t.set(0,-4,0);
	boxDesc[3].materialIndex	= defaultMaterialIndex;
	actorDesc.shapes.pushBack(&boxDesc[3]);
	boxDesc[4].dimensions.set(1,4,4);
	boxDesc[4].localPose.t.set(4,0,0);
	boxDesc[4].materialIndex	= frictionlessMaterialIndex;
	actorDesc.shapes.pushBack(&boxDesc[4]);
	boxDesc[5].dimensions.set(1,4,4);
	boxDesc[5].localPose.t.set(-4,0,0);
	boxDesc[5].materialIndex	= highFrictionMaterialIndex;
	actorDesc.shapes.pushBack(&boxDesc[5]);

	
	
	actorDesc.body			= &bodyDesc;
	actorDesc.density		= 10.0f;
	actorDesc.globalPose.t  = pos;
	gScene->createActor(actorDesc);
	}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:50,代码来源:NxMaterials.cpp

示例5: ProcessCameraKeys

void ProcessCameraKeys()
{
	NxReal deltaTime;

    if (bPause) deltaTime = 0.02; else deltaTime = gDeltaTime;   

	// Process camera keys
	for (int i = 0; i < MAX_KEYS; i++)
	{	
		if (!gKeys[i])  { continue; }

		switch (i)
		{
			// Camera controls
			case 'w':{ gCameraPos += gCameraForward*gCameraSpeed*deltaTime; break; }
			case 's':{ gCameraPos -= gCameraForward*gCameraSpeed*deltaTime; break; }
			case 'a':{ gCameraPos -= gCameraRight*gCameraSpeed*deltaTime; break; }
			case 'd':{ gCameraPos += gCameraRight*gCameraSpeed*deltaTime; break; }
			case 'z':{ gCameraPos -= NxVec3(0,1,0)*gCameraSpeed*deltaTime; break; }
			case 'q':{ gCameraPos += NxVec3(0,1,0)*gCameraSpeed*deltaTime; break; }
		}
	}
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:23,代码来源:Lesson1005.cpp

示例6: assert

CPhysicUserData* CPhysicsManager::RaycastClosestActorShoot ( const Vect3f _vPosRay, const Vect3f& _vDirRay, uint32 _uiImpactMask, SCollisionInfo& _Info, float _fPower )
{
  
  //NxUserRaycastReport::ALL_SHAPES
	assert(m_pScene != NULL);

	NxRay ray; 
	ray.dir =  NxVec3 ( _vDirRay.x, _vDirRay.y, _vDirRay.z );
	ray.orig = NxVec3 ( _vPosRay.x, _vPosRay.y, _vPosRay.z );

	NxRaycastHit hit;
	NxShape* closestShape = NULL;

	closestShape = m_pScene->raycastClosestShape ( ray, NX_ALL_SHAPES, hit, _uiImpactMask );
	if (!closestShape) 
	{
		//No hemos tocado a ningún objeto físico de la escena.
		return NULL;
	}
	NxActor* actor = &closestShape->getActor();
	CPhysicUserData* impactObject =(CPhysicUserData*)actor->userData;
	//Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData
	assert(impactObject);

	_Info.m_fDistance		= hit.distance;
	_Info.m_Normal			= Vect3f(hit.worldNormal.x, hit.worldNormal.y, hit.worldNormal.z ); 
	_Info.m_CollisionPoint	= Vect3f(hit.worldImpact.x, hit.worldImpact.y, hit.worldImpact.z ); 

	Vect3f l_vDirection( _vDirRay.x-_vPosRay.x,_vDirRay.y-_vPosRay.y,_vDirRay.z-_vPosRay.z );
	l_vDirection.Normalize();

	NxVec3 l_vDirectionVec( _vDirRay.x, _vDirRay.y, _vDirRay.z ); 
	NxF32 coeff = actor->getMass() * _fPower;
	actor->addForceAtLocalPos ( l_vDirectionVec*coeff, NxVec3(0,0,0), NX_IMPULSE,true );

	return impactObject;
}
开发者ID:kusku,项目名称:red-forest,代码行数:37,代码来源:PhysicsManager.cpp

示例7: TumblingBody

void TumblingRobot::Create(){
	if(this->pScene == NULL){
#ifdef _DEBUG
		std::cout<< "pScene == NULL at TumblingRobot::Create()" << std::endl;
#endif	//_DEBUG
		return;
	}
	TumblingBody*	body = new TumblingBody(pScene, position);
	TumblingArm*	leftArm = new TumblingArm(pScene, position, NxVec3(-2, 0, 0), NxQuat(-10, NxVec3(0, 1, 0)) );
	TumblingArm*	rightArm = new TumblingArm(pScene, position, NxVec3(2, 0, 0),	NxQuat(10, NxVec3(0, 1, 0)) );

	NxRevoluteJointDesc leftJointDesc;
	leftJointDesc.setToDefault();
	leftJointDesc.actor[0] = body->getActor();
	leftJointDesc.actor[1] = leftArm->getActor();
	leftJointDesc.setGlobalAnchor(position + NxVec3(2, 0, 0));
	leftJointDesc.setGlobalAxis(NxMat33(leftArm->getLocalOrientation()) * NxVec3(1, 0, 0));
	NxJoint* leftJoint = pScene->createJoint( leftJointDesc );

	NxRevoluteJointDesc rightJointDesc;
	rightJointDesc.setToDefault();
	rightJointDesc.actor[0] = body->getActor();
	rightJointDesc.actor[1] = rightArm->getActor();
	rightJointDesc.setGlobalAnchor(position + NxVec3(2, 0, 0));
	rightArm->getLocalOrientation();
	rightJointDesc.setGlobalAxis(NxMat33(rightArm->getLocalOrientation()) * NxVec3(1, 0, 0));
	NxJoint* rightJoint = pScene->createJoint( rightJointDesc );

	//Register Parts
	this->parts.push_back(body);
	this->parts.push_back(leftArm);
	this->parts.push_back(rightArm);

	//Register Joints
	this->joints.push_back(leftJoint);
	this->joints.push_back(rightJoint);

	WalkControl*		cWalk = new WalkControl(pHost);
	ArmControl*			cLeftArm = new ArmControl(pHost);
	ArmControl*			cRightArm = new ArmControl(pHost);

	cWalk->addTarget(cLeftArm);
	cWalk->addTarget(cRightArm);

	clients.push_back(cWalk);
	clients.push_back(cLeftArm);
	clients.push_back(cRightArm);

	pHost->addClient(cWalk);
	pHost->addClient(cLeftArm);
	pHost->addClient(cRightArm);

	leftArm->setClient(cLeftArm);
	rightArm->setClient(cRightArm);
	
	return;
}
开发者ID:RozKen,项目名称:SubsumptionRobotEnvironment,代码行数:57,代码来源:TumblingRobot.cpp

示例8: NxVec3

	bool CPhysBody::Create(AABB boundingbox, Vec3 position, bool dynamic)
	{
		NxActorDesc actorDesc;
		NxBodyDesc bodyDesc;

		NxBoxShapeDesc boxDesc;
		//set size
		//boxDesc.dimensions.set(boundingbox.GetExtent(0), boundingbox.GetExtent(1), boundingbox.GetExtent(2));
		boxDesc.dimensions.set((boundingbox.max.x - boundingbox.min.x)/2, (boundingbox.max.y - boundingbox.min.y)/2, (boundingbox.max.z - boundingbox.min.z)/2);
		//set local position within the body
		boxDesc.localPose.t = NxVec3(boundingbox.GetCenter(0), boundingbox.GetCenter(1), boundingbox.GetCenter(2));
		//boxDesc.localPose.t = NxVec3(0.0f, 0.0f, 0.0f);
		actorDesc.shapes.pushBack(&boxDesc);

		if(dynamic) actorDesc.body = &bodyDesc;
		else actorDesc.body = 0;

		//set actor's global position
		actorDesc.globalPose.t = NxVec3(position.x, position.y, position.z);
		actorDesc.density = 10;
		m_pActor = g_pPhysScene->createActor(actorDesc);
		m_pActor->userData = new sNxActorUserData;
		return true;
	}
开发者ID:k3a,项目名称:Panther3D-2,代码行数:24,代码来源:PhysBody.cpp

示例9: RenderCallback

void RenderCallback()
{
    if (gScene && !bPause)
	{
		StartPhysics();	
		GetPhysicsResults();
	}

    // Clear buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	ProcessInputs();
	ProcessCameraKeys();
	SetupCamera();

 	RenderActors(bShadows);

    // Render all the cloths in the scene
	for (MyCloth **cloth = gCloths.begin(); cloth != gCloths.end(); cloth++)
	{
		glColor4f(1.0f, 0.0f, 0.0f,1.0f);
		(*cloth)->draw(bShadows);
	}

	if (bForceMode)
		DrawForce(gSelectedActor, gForceVec, NxVec3(1,1,0));
	else
		DrawForce(gSelectedActor, gForceVec, NxVec3(0,1,1));
	gForceVec = NxVec3(0,0,0);

	// Render HUD
	hud.Render();

    glFlush();
    glutSwapBuffers();
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:36,代码来源:Lesson1006.cpp

示例10: NxMat34

void Simulation::buildModelBall(int indexScene){
	NxBall* ball = Simulation::gScenes[indexScene]->ball;
	ball->ball = Simulation::getActorBall(indexScene);
	//velocidade maxima permitida segundo as rule 2010 (10m/s)
	//A bola pode atingir velocidade maior pq tem o caso de esta sendo usada pelo driblador, mas a principio consideremos isso
	ball->ball->setMaxAngularVelocity(10000./21.5);
	//0.031 medido da bola do lab
	//46g a bola da rules 2010
	//estimativa da bola do laboratorio 31g
	ball->ball->setMass(0.046); //PLUGIN TAH COM PROBLEMA XML ERRADO 

	//TODO: LEVANTAR INERTIA TENSOR, CMASS, DAMPINGS
	//float teste = ball->ball->getAngularDamping();
	//ball->ball->setCMassOffsetGlobalPosition(NxVec3(0, 0, 0));
	ball->ball->setCMassOffsetLocalPose( NxMat34( NxMat33(NxVec3(8.37673, 0, 0), NxVec3(0, 8.37673, 0), NxVec3(0, 0, 8.37673)), NxVec3(0, 0, 0) ) );
	ball->ball->setAngularDamping(0.5);
	ball->ball->setLinearDamping(0.5);
	ball->ball->setMassSpaceInertiaTensor(/*ball->ball->getMassSpaceInertiaTensor()*100000.*/ NxVec3(8.37673, 8.37673, 8.37673) );

	ball->initialPose = ball->ball->getGlobalPose();
	ball->indexScene = indexScene;

	ball->ball->putToSleep();
}
开发者ID:roboime,项目名称:legacy-roboime,代码行数:24,代码来源:NxBall.cpp

示例11: idle

void idle()
{
	calcFPS();
	glCheckError("idle");

	static Timer t;
	double dt = t.elapsed_time();

	if(IS_KEY_DOWN('w') || IS_KEY_DOWN('W'))
		g_CameraPos += g_CameraForward*g_Speed*dt;
	if(IS_KEY_DOWN('s') || IS_KEY_DOWN('S'))
		g_CameraPos -= g_CameraForward*g_Speed*dt;
	if(IS_KEY_DOWN('q') || IS_KEY_DOWN('Q'))
		g_CameraPos +=NxVec3(0.0f,1.0f,0.0f)*g_Speed*dt;
	if(IS_KEY_DOWN('e') || IS_KEY_DOWN('E'))
		g_CameraPos -=NxVec3(0.0f,1.0f,0.0f)*g_Speed*dt;
	if(IS_KEY_DOWN('a') || IS_KEY_DOWN('A'))
		g_CameraPos -= g_CameraRight*g_Speed*dt;
	if(IS_KEY_DOWN('d') || IS_KEY_DOWN('D'))
		g_CameraPos += g_CameraRight*g_Speed*dt;

	t.reset();
	glutPostRedisplay();
}
开发者ID:flair2005,项目名称:Physx,代码行数:24,代码来源:ex3_terrain.cpp

示例12: CreateScenario

bool CreateScenario()
{
	DestroyScenario();

	// Create the scene
	NxSceneDesc sceneDesc;
	sceneDesc.gravity = gDefaultGravity;
	sceneDesc.simType = bHWScene? NX_SIMULATION_HW : NX_SIMULATION_SW;
	gScene = gPhysicsSDK->createScene(sceneDesc);	
	if(0 == gScene)
	{ 
		bHWScene = !bHWScene;
		sceneDesc.simType = bHWScene? NX_SIMULATION_HW : NX_SIMULATION_SW;
		gScene = gPhysicsSDK->createScene(sceneDesc);  
		if(0 == gScene) return false;
	}

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	// Create the plane in primary scene
	groundPlane = CreateGroundPlane();

	// Create compartment(HSM, managed hardware scene) attached to this scene
	NxCompartmentDesc desc;
	desc.type = NX_SCT_RIGIDBODY;
	desc.deviceCode = NxU32(NX_DC_PPU_0);
	gCompartmentHW = gScene->createCompartment(desc);

	desc.deviceCode = NxU32(NX_DC_CPU);
	gCompartmentSW = gScene->createCompartment(desc);

	// Create objects
	boxHW = CreateManagedBox(NxVec3(6, 0, 0), NxVec3(0.5, 1, 0.5), 20, gCompartmentHW);
	boxSW = CreateManagedBox(NxVec3(3, 0, 0), NxVec3(0.5, 1, 0.5), 20, gCompartmentSW);
	sphereHW = CreateManagedSphere(NxVec3(-6,0,0), 1, 10, gCompartmentHW);
	sphereHW = CreateManagedSphere(NxVec3(-3,0,0), 1, 10, gCompartmentSW);
	capsule = CreateManagedCapsule(NxVec3(0,0,0), 2, 1, 5, 0);

	gSelectedActor = boxHW;

	// Initialize HUD
	InitializeHUD();

	// Start the first frame of the simulation
	StartPhysics();
	return true;
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:51,代码来源:Lesson801.cpp

示例13: NxVec3

void CPhysicActor::SetLinearVelocity (const Vect3f& velocity)
{
	if (m_pPhXActor)
	{
		if (velocity != v3fZERO)
		{
			m_pPhXActor->setLinearVelocity( NxVec3( velocity.x, velocity.y, velocity.z) );
		}
	}
	else
	{
		//TODO log de error...

	}
}
开发者ID:BGCX261,项目名称:zombigame-svn-to-git,代码行数:15,代码来源:PhysicActor.cpp

示例14: DrawEllipse

void DrawEllipse(NxU32 nbSegments, const NxMat34& matrix, const NxVec3& color, const NxF32 radius1, const NxF32 radius2, const bool semicircle)
{
	NxF32 step = NxTwoPiF32/NxF32(nbSegments);
	NxU32 segs = nbSegments;
	if(semicircle)
	{
		segs /= 2;
	}

	for(NxU32 i=0;i<segs;i++)
	{
		NxU32 j=i+1;
		if(j==nbSegments)	j=0;

		NxF32 angle0 = NxF32(i)*step;
		NxF32 angle1 = NxF32(j)*step;

		NxVec3 p0,p1;
		matrix.multiply(NxVec3(radius1 * sinf(angle0), radius2 * cosf(angle0), 0.0f), p0);
		matrix.multiply(NxVec3(radius1 * sinf(angle1), radius2 * cosf(angle1), 0.0f), p1);

		DrawLine(p0, p1, color);
	}
}
开发者ID:bitllorent,项目名称:CompAnim_P3,代码行数:24,代码来源:DrawObjects.cpp

示例15: call

void NPCAssist::onUpdate(float dt)
{
    // follow cat toy until it is roaming
    if( getNPC()->getCatToy()->getPhase() == ::jpRoaming )
    {
        call( new NPCFollow( getNPC(), 75.0f ) );
    }
    // pull and drop ward's pilotchute
    else if( _ward && !_ward->getFreefallActor()->isSleeping() )
    {
        // pilotchute pull frame
        Vector3f pp = Jumper::getLineHandJoint( getNPC()->getJumper()->getClump() )->getPos();
        Vector3f py = _ward->getClump()->getFrame()->getPos() - getNPC()->getJumper()->getClump()->getFrame()->getPos(); py.normalize();
        Vector3f px; px.cross( py, Vector3f(0,1,0) ); px.normalize();
        Vector3f pz; py.cross( px, py ); pz.normalize();

        // check wind
        float windSpeed = 0.5f * ( getNPC()->getScene()->getLocation()->getWindAmbient() +
                                   getNPC()->getScene()->getLocation()->getWindBlast() );
        Vector3f wardAt = _ward->getClump()->getFrame()->getAt();
        wardAt.normalize();
        if( windSpeed < 2.0f || Vector3f::dot( wardAt, getNPC()->getScene()->getLocation()->getWindDirection() ) < 0 )
        {
            // connect pilot chute
            _ward->getPilotchuteSimulator()->connect( 
                _ward->getFreefallActor(), 
                Jumper::getBackBone( _ward->getClump() ), 
                _ward->getLocalPilotAnchor() 
            );

            // pull pilotchute
            _ward->getPilotchuteSimulator()->pull( Matrix4f(
                px[0], px[1], px[2], 0.0f,
                py[0], py[1], py[2], 0.0f,
                pz[0], pz[1], pz[2], 0.0f,
                pp[0], pp[1], pp[2], 1.0f
            ) );
            _ward->getPilotchuteSimulator()->updateActivity( 0.0f );

            // and drop
            _ward->getPilotchuteSimulator()->drop( NxVec3( 0,0,0 ) );
            _ward->getPilotchuteSimulator()->setInflation( 0.25f );
        }

        // and no longer track the ward happiness :)
        _ward = NULL;
    }
}
开发者ID:Jan123457,项目名称:d3basejumper,代码行数:48,代码来源:npcassist.cpp


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