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


C++ NxVec3::normalize方法代码示例

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


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

示例1: updateAnimation

void Jumper::StandingJump::update(float dt)
{
    updateAnimation( dt );
    _clump->getFrame()->getLTM();

    if( _actionTime < _blendTime ) return;

    if( _actionTime > _blendTime + ( FRAMETIME(245) - FRAMETIME(225) ) )
    {
        if( _phActor->isSleeping() )
        {
            Matrix4f sampleLTM = Jumper::getCollisionFF( _clump )->getFrame()->getLTM();
            _phActor->setGlobalPose( wrap( sampleLTM ) );
            _phActor->wakeUp();
            NxVec3 velH = wrap( _clump->getFrame()->getAt() );
            velH.normalize();
            velH *= 3.0f;
            NxVec3 velV = wrap( _clump->getFrame()->getUp() );
            velV.normalize();
            velV *= 1.5f;
            _phActor->setLinearVelocity( velH + velV );
            _jumper->initOverburdenCalculator( velH + velV );
        }
        else
        {
            _clump->getFrame()->setMatrix( _matrixConversion->convert( wrap( _phActor->getGlobalPose() ) ) );
        }
		if( _jumper->getSpinalCord()->modifier) _endOfAction = true;
    }

    if( _clump->getAnimationController()->isEndOfAnimation( 0 ) )
    {
        _endOfAction = true;
    }
}
开发者ID:AndreMeijer86,项目名称:base-pro-edition,代码行数:35,代码来源:jumper_standingjump.cpp

示例2: CollisionResponse

	NX_INLINE void CollisionResponse(NxExtendedVec3& target_position, const NxExtendedVec3& current_position, const NxVec3& current_dir, const NxVec3& hit_normal, NxF32 bump, NxF32 friction, bool normalize=false)
	{
		// Compute reflect direction
		NxVec3 ReflectDir;
		ComputeReflexionVector(ReflectDir, current_dir, hit_normal);
		ReflectDir.normalize();

		// Decompose it
		NxVec3 NormalCompo, TangentCompo;
		DecomposeVector(NormalCompo, TangentCompo, ReflectDir, hit_normal);

		// Compute new destination position
		const Extended Amplitude = target_position.distance(current_position);

		target_position = current_position;
		if(bump!=0.0f)
		{
			if(normalize)	NormalCompo.normalize();
			target_position += NormalCompo*float(bump*Amplitude);
		}
		if(friction!=0.0)
		{
			if(normalize)	TangentCompo.normalize();
			target_position += TangentCompo*float(friction*Amplitude);
		}
	}
开发者ID:gbaumgart,项目名称:vt,代码行数:26,代码来源:CharacterController.cpp

示例3: Frame

void DXApp::Frame()
{
    UINT64 CurrentTime;
    UINT64 DeltaCount;
    QueryPerformanceCounter((LARGE_INTEGER*)&CurrentTime);
    DeltaCount = CurrentTime - OldCount;
    OldCount = CurrentTime;

    DeltaTime = (double)DeltaCount/(double)Frequency;

    {
        NxVec3 Temp;
        Cam.location+=Cam.ViewDir*40*fFoward;

        Temp = Cam.ViewDir;
        Temp.y = 0;
        Temp.normalize();
        Temp = Temp.cross(NxVec3(0.0f, 1.0f, 0.0f));
        Cam.location+=Temp*40*fStrafe;;
    }

    if(!bPaused)
    {
        DoParticles();
        _p_scene->simulate(_time_step);
        _p_scene->flushStream();
    }
    RenderFrame();
    if(!bPaused)
        _p_scene->fetchResults(NX_RIGID_BODY_FINISHED, true);

}
开发者ID:Arelius,项目名称:TestMotionBlur,代码行数:32,代码来源:DXApp.cpp

示例4: MotionCallback

static void MotionCallback(int x, int y)
{
    int dx = gMouseX - x;
    int dy = gMouseY - y;

    gDir.normalize();		//カメラの視線ベクトルを正規化
    gViewY.cross(gDir, NxVec3(0,1,0));	//

    if( gMouseButton[0] && gMouseButton[1] ) {
        //Zoom: Left + Center Buttons Drag
        gEye -= gDir * 0.5f * dy;
    } else {
        if( gMouseButton[0] ) {
            //Rotate: Left Button Drag
            NxQuat qx(NxPiF32 * dx * 10/ 180.0f, NxVec3(0,1,0));
            qx.rotate(gDir);
            NxQuat qy(NxPiF32 * dy * 10/ 180.0f, gViewY);
            qy.rotate(gDir);
        } else if( gMouseButton[1] ) {
            //Move: Center Button Drag
            gEye += 0.1f * (gViewY * dx - NxVec3(0, 1, 0) * dy);
        }
    }
    gMouseX = x;
    gMouseY = y;
    glutPostRedisplay();
}
开发者ID:RozKen,项目名称:IntroPhysX,代码行数:27,代码来源:glutCallBacks.cpp

示例5: KeyboardCallback

static void KeyboardCallback(unsigned char key, int x, int y)
	{
	switch (key)
		{
		case 27:	exit(0); break;
		case '1':			CreateCube(NxVec3(-40.0f, 60.0f, -18.0f)); break;
		case '2':			CreateCube(NxVec3(0.0f, 60.0f, -18.0f)); break;
		case '3':			CreateCube(NxVec3(40.0f, 60.0f, -18.0f)); break;

		case '4':			CreateCube(NxVec3(-40.0f, 60.0f, 40.0f)); break;
		case '5':			CreateCube(NxVec3(0.0f, 60.0f, 40.0f)); break;
		case '6':			CreateCube(NxVec3(40.0f, 60.0f, 40.0f)); break;

		case 'p':			gPause = !gPause; break;
		case 101: 			Eye += Dir * 2.0f; break;
		case 103: 			Eye -= Dir * 2.0f; break;
		case 100: 			Eye -= N * 2.0f; break;
		case 102: 			Eye += N * 2.0f; break;
		case 'w':
			{
			NxVec3 t = Eye;
			NxVec3 Vel = Dir;
			Vel.normalize();
			Vel*=100.0f;
			CreateCube(t, &Vel);
			}
			break;
		}
	
	}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:30,代码来源:NxMaterials.cpp

示例6: KeyboardCallback

static void KeyboardCallback(unsigned char key, int x, int y)
{
	static Random random;
	int sceneIndex = random.rand()&1;

	switch (key)
	{
	case 27:	exit(0); break;
	case ' ':			CreateCube(sceneIndex, NxVec3(0.0f, 20.0f, 0.0f), 1+(rand()&3)); break;
	case 's':			CreateStack(sceneIndex, 10); break;
	case 'b':			CreateStack(sceneIndex, 30); break;
	case 't':			CreateTower(sceneIndex, 30); break;
	case 'x':			gShadows = !gShadows; break;
	case 'p':			gPause = !gPause; break;
	case 101: case '8':	Eye += Dir * 2.0f; break;
	case 103: case '2':	Eye -= Dir * 2.0f; break;
	case 100: case '4':	Eye -= N * 2.0f; break;
	case 102: case '6':	Eye += N * 2.0f; break;
	case 'w':
		{
		NxVec3 t = Eye;
		NxVec3 Vel = Dir;
		Vel.normalize();
		Vel*=200.0f;
		CreateCube(sceneIndex, t, 8, &Vel);
		}
		break;
	}
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:29,代码来源:NxMultipleScenes.cpp

示例7: MotionCallback

void MotionCallback(int x, int y)
{
	int dx = mx - x;
	int dy = my - y;

	if (gMouseSphere) // Move the mouse sphere
	{
		NxVec3 pos;
		ViewUnProject(x,y, gMouseDepth, pos);
		gMouseSphere->setGlobalPosition(pos);
		gHitActor->wakeUp();
	}
	else if (gHitCloth) // Attach the cloth vertex
	{
		NxVec3 pos; 
		ViewUnProject(x,y, gMouseDepth, pos);
		gHitCloth->attachVertexToGlobalPosition(gHitClothVertex, pos);
	}
	else if (bLeftMouseButtonPressed) // Set camera
	{   
		gCameraForward.normalize();
		gCameraRight.cross(gCameraForward,NxVec3(0,1,0));

		NxQuat qx(NxPiF32 * dx * 20 / 180.0f, NxVec3(0,1,0));
		qx.rotate(gCameraForward);
		NxQuat qy(NxPiF32 * dy * 20 / 180.0f, gCameraRight);
		qy.rotate(gCameraForward);
	}

    mx = x;
    my = y;
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:32,代码来源:Lesson1006.cpp

示例8: computeBasis

static void computeBasis(const NxVec3& dir, NxVec3& right, NxVec3& up)
{
	// Derive two remaining vectors
	if(fabsf(dir.y)>0.9999f)	right = NxVec3(1.0f, 0.0f, 0.0f);
	else						right = (NxVec3(0.0f, 1.0f, 0.0f) ^ dir);
	right.normalize();
	up = dir ^ right;
}
开发者ID:bitllorent,项目名称:CompAnim_P3,代码行数:8,代码来源:DrawObjects.cpp

示例9: CreateCubeFromEye

void PhysX::CreateCubeFromEye(float cubeSize)
{
	NxVec3 t = m_Eye;
	NxVec3 vel = m_Dir;
	vel.normalize();
	vel*=200.0f;
	CreateCube(t, cubeSize, DENSITY, &vel);
}
开发者ID:justinlm,项目名称:PhysXBoxes,代码行数:8,代码来源:PhysX.cpp

示例10: CreateCubeFromEye

void CreateCubeFromEye(int size)
{
	NxVec3 t = g_CameraPos;
	NxVec3 vel = g_CameraForward;
	vel.normalize();
	vel*=200.0f;
	CreateCube(t, size, &vel);
}
开发者ID:flair2005,项目名称:Physx,代码行数:8,代码来源:ex3_terrain.cpp

示例11: CreateSphereFromEye

void PhysX::CreateSphereFromEye(int radius)
{
	NxVec3 t = m_Eye;
	NxVec3 vel = m_Dir;
	vel.normalize();
	vel *= 200.0f;
	CreateSphere(t, radius, DENSITY , &vel);
}
开发者ID:justinlm,项目名称:PhysXBoxes,代码行数:8,代码来源:PhysX.cpp

示例12: getWheelCapsule

void pWheel1::_tick(float dt)
{

	if(!hasGroundContact())
		updateContactPosition();
	
	//################################################################
	//
	// Calculate the wheel rotation around the roll axis
	//
	updateAngularVelocity(dt*0.001f, false);

	float motorTorque=0.0;

	if(getWheelFlag(WF_Accelerated)) 
	{
		/*if (handBrake && getWheelFlag(NX_WF_AFFECTED_BY_HANDBRAKE)) 
		{
			// Handbrake, blocking!
		}*/
		
		if (hasGroundContact()) 
		{
			// Touching, force applies
			NxVec3 steeringDirection;
			getSteeringDirection(steeringDirection);
			steeringDirection.normalize();
			NxReal localTorque = motorTorque;
			NxReal wheelForce = localTorque / _radius;
			steeringDirection *= wheelForce;
			wheelCapsule->getActor().addForceAtPos(steeringDirection, contactInfo->contactPosition);
			if(contactInfo->otherActor->isDynamic())
				contactInfo->otherActor->addForceAtPos(-steeringDirection, contactInfo->contactPosition);
		} 
	}
	
	NxMat34& wheelPose = getWheelCapsule()->getGlobalPose();
	NxMat33 rot, axisRot, rollRot;
	rot.rotY( _angle );
	axisRot.rotY(0);
	rollRot.rotX(_turnAngle);
	wheelPose.M = rot * wheelPose.M * axisRot * rollRot;

	float a = _angle;
	float b = getWheelRollAngle();

	
	setWheelPose(wheelPose);
	//setWheelOrientation(wheelPose.M);


	contactInfo->reset();
}
开发者ID:gbaumgart,项目名称:vt,代码行数:53,代码来源:pWheel1.cpp

示例13: updateAnimation

void Jumper::RunningJump::update(float dt)
{
    updateAnimation( dt );
    _clump->getFrame()->getLTM();

    if( _actionTime < _blendTime ) 
    {
        Vector3f dir = _clump->getFrame()->getAt();
        dir.normalize();
        _clump->getFrame()->setPos( _clump->getFrame()->getPos() + dir * dt * _vel );            
        return;
    }

    if( _phActor->isSleeping() )
    {
        // setup physics
        Matrix4f sampleLTM = Jumper::getCollisionFF( _clump )->getFrame()->getLTM();
        _phActor->setGlobalPose( wrap( sampleLTM ) );
        _phActor->wakeUp();
        NxVec3 velH = wrap( _clump->getFrame()->getAt() );
        velH.normalize();
        velH *= _vel * 0.01f;
        NxVec3 velV = wrap( _clump->getFrame()->getUp() );
        velV.normalize();
        velV *= 1.5f;
        _phActor->setLinearVelocity( velH + velV + wrap(_clump->getFrame()->getAt() * 600.0f * dt)) ;
        _jumper->initOverburdenCalculator( velH + velV );


    }
    else
    {
        _clump->getFrame()->setMatrix( _matrixConversion->convert( wrap( _phActor->getGlobalPose() ) ) );
    }

    if( _clump->getAnimationController()->isEndOfAnimation( 0 ) )
    {
        _endOfAction = true;
    }
}
开发者ID:AndreMeijer86,项目名称:base-pro-edition,代码行数:40,代码来源:jumper_runningjump.cpp

示例14: if

void pWheel1::tick(bool handbrake, float motorTorque, float brakeTorque, float dt)
{

	if(getWheelFlag(WF_Accelerated)) 
	{
		if (handbrake && getWheelFlag(WF_AffectedByHandbrake)) 
		{
			// Handbrake, blocking!
		}
		else if (hasGroundContact()) 
		{
			// Touching, force applies
			NxVec3 steeringDirection;
			getSteeringDirection(steeringDirection);
			steeringDirection.normalize();
			NxReal localTorque = motorTorque;
			NxReal wheelForce = localTorque / _radius;
			steeringDirection *= wheelForce;
			wheelCapsule->getActor().addForceAtPos(steeringDirection, contactInfo->contactPosition);
			if(contactInfo->otherActor->isDynamic())
				contactInfo->otherActor->addForceAtPos(-steeringDirection, contactInfo->contactPosition);
		} 
	}

	NxReal OneMinusBreakPedal = 1-brakeTorque;

	/*
	if(handBrake && getWheelFlag(WF_AffectedByHandbrake)) 
	{
	material->setDynamicFrictionV(1);
	material->setStaticFrictionV(4);
	material->setDynamicFriction(0.4f);
	material->setStaticFriction(1.0f);
	} 
	else 
	{
	NxReal newv = OneMinusBreakPedal * _frictionToFront + brakeTorque;
	NxReal newv4= OneMinusBreakPedal * _frictionToFront + brakeTorque*4;
	material->setDynamicFrictionV(newv);
	material->setDynamicFriction(_frictionToSide);

	material->setStaticFrictionV(newv*4);
	material->setStaticFriction(2);
	}*/

	if(!hasGroundContact())
		updateContactPosition();
	updateAngularVelocity(dt, handbrake);

	contactInfo->reset();
}
开发者ID:gbaumgart,项目名称:vt,代码行数:51,代码来源:pWheel1.cpp

示例15: MotionCallback

void MotionCallback(int x, int y)
{
	int dx = mx - x;
	int dy = my - y;

	gCameraForward.normalize();
	gCameraRight.cross(gCameraForward,NxVec3(0,1,0));

	NxQuat qx(NxPiF32 * dx * 20 / 180.0f, NxVec3(0,1,0));
	qx.rotate(gCameraForward);
	NxQuat qy(NxPiF32 * dy * 20 / 180.0f, gCameraRight);
	qy.rotate(gCameraForward);

	mx = x;
	my = y;
}
开发者ID:daher-alfawares,项目名称:xr.desktop,代码行数:16,代码来源:Lesson904.cpp


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