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


C++ VectorRotate函数代码示例

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


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

示例1: RotateFaceTexture

void RotateFaceTexture(face_t* f, int nAxis, float fDeg)
{
	vec3_t p1,p2,p3, rota;   
  p1[0] = p1[1] = p1[2] = 0;
  VectorCopy(p1, p2);
  VectorCopy(p1, p3);
  VectorCopy(p1, rota);
	ComputeAbsolute(f, p1, p2, p3);

  
  rota[nAxis] = fDeg;
  VectorRotate(p1, rota, select_origin, p1);
  VectorRotate(p2, rota, select_origin, p2);
  VectorRotate(p3, rota, select_origin, p3);

  plane_t normal2;
  vec3_t vNormal;
  vNormal[0] = f->plane.normal[0];
  vNormal[1] = f->plane.normal[1];
  vNormal[2] = f->plane.normal[2];
  VectorRotate(vNormal, rota, vNormal);
  normal2.normal[0] = vNormal[0];
  normal2.normal[1] = vNormal[1];
  normal2.normal[2] = vNormal[2];
	AbsoluteToLocal(normal2, f, p1, p2 ,p3);

}
开发者ID:Hasimir,项目名称:jedi-outcast-1,代码行数:27,代码来源:select.cpp

示例2: ter

void cCamera::UpdateInput(float deltaTime)
{
	cVector3df ter(0.0f,0.0f,-m_speed *deltaTime), ter2(-m_speed *deltaTime,0.0f,0.0f),ter3(m_speed *deltaTime,0.0f,0.0f),ter4(0.0f,0.0f,m_speed *deltaTime);
	cVector3df Front,Left,Right,Back;
	VectorRotate(ter,ENGINE->m_activeCamera->Camera,Front);
	VectorRotate(ter2,ENGINE->m_activeCamera->Camera,Left);
	VectorRotate(ter3,ENGINE->m_activeCamera->Camera,Right);
	VectorRotate(ter4,ENGINE->m_activeCamera->Camera,Back);
	if(INPUT->getMouseButtonState(LEFT_MOUSE_BUTTON))
		setEnabledMouse();
	if(!INPUT->getMouseButtonState(LEFT_MOUSE_BUTTON))
		setDisabledMouse();
	if(INPUT->getKey('W')||INPUT->getKey('w'))
		move(Front);
	if(INPUT->getKey('S')||INPUT->getKey('s'))
		move(Back);
	if(INPUT->getKey('A')||INPUT->getKey('a'))
		move(Left);
	if(INPUT->getKey('D')||INPUT->getKey('d'))
		move(Right);
	if(INPUT->getKey('R')||INPUT->getKey('r'))
		move(cVector3df(0,0.1f,0));
	if(INPUT->getKey('F')||INPUT->getKey('f'))
		move(cVector3df(0,-0.1f,0));
	

}
开发者ID:iliescu6,项目名称:GLT,代码行数:27,代码来源:Camera.cpp

示例3: RotateFaceTexture

void RotateFaceTexture( face_s* f, int nAxis, float fDeg )
{
	edVec3_c p1, p2, p3, rota;
	p1.clear();
	p2.clear();
	p3.clear();
	rota.clear();
	ComputeAbsolute( f, p1, p2, p3 );
	
	rota[nAxis] = fDeg;
	VectorRotate( p1, rota, select_origin, p1 );
	VectorRotate( p2, rota, select_origin, p2 );
	VectorRotate( p3, rota, select_origin, p3 );
	
	edPlane_c normal2;
	edVec3_c vNormal;
	vNormal[0] = f->plane.normal[0];
	vNormal[1] = f->plane.normal[1];
	vNormal[2] = f->plane.normal[2];
	VectorRotate( vNormal, rota, vNormal );
	normal2.normal[0] = vNormal[0];
	normal2.normal[1] = vNormal[1];
	normal2.normal[2] = vNormal[2];
	AbsoluteToLocal( normal2, f, p1, p2 , p3 );
	
}
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:26,代码来源:Select.cpp

示例4: UTIL_PlayerByIndex

void NDebugOverlay::BoxAngles(const Vector &origin, const Vector &mins, const Vector &maxs, const QAngle &angles, int r, int g, int b, int a, float duration)
{
	// --------------------------------------------------------------
	// Have to do clip the boxes before sending so we 
	// don't overflow the client message buffer 
	// --------------------------------------------------------------
	CBasePlayer *player = UTIL_PlayerByIndex(1);
	if ( !player )
		return;

	// ------------------------------------
	// Clip boxes that are far away
	// ------------------------------------
	if ((player->GetAbsOrigin() - origin).LengthSqr() > MAX_OVERLAY_DIST_SQR) 
		return;

	// ------------------------------------
	// Clip boxes that are behind the client 
	// ------------------------------------
	Vector clientForward;
	player->EyeVectors( &clientForward );

	// Build a rotation matrix from orientation
	matrix3x4_t fRotateMatrix;
	AngleMatrix(angles, fRotateMatrix);
	
	// Transform the mins and maxs
	Vector tmins, tmaxs;
	VectorRotate( mins, fRotateMatrix, tmins);
	VectorAdd(tmins,origin,tmins);
	VectorRotate( maxs, fRotateMatrix, tmaxs);
	VectorAdd(tmaxs,origin,tmaxs);

	Vector toMins  = tmins - player->GetAbsOrigin();
	Vector toMaxs  = tmaxs - player->GetAbsOrigin();
 	float  dotMins	 = DotProduct(clientForward,toMins);
 	float  dotMaxs	 = DotProduct(clientForward,toMaxs);
	if (dotMins < 0 && dotMaxs < 0)
		return;

	CSingleUserRecipientFilter user( player );

	MessageBegin( user, SVC_DEBUG_BOX_OVERLAY );
		WRITE_VEC3COORD(origin);
		WRITE_VEC3COORD(mins);
		WRITE_VEC3COORD(maxs);
		WRITE_ANGLES(angles); 
		WRITE_SHORT(r);
		WRITE_SHORT(g);
		WRITE_SHORT(b);
		WRITE_SHORT(a);
		WRITE_FLOAT(duration);
	MessageEnd();

}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:55,代码来源:ndebugoverlay.cpp

示例5: VectorRotate

inline void VectorRotate(const Vector &i, const Angle &angles, Vector &o)
{
	matrix3x4 matrix;

	AngleMatrix(angles, matrix);
	VectorRotate(i, matrix, o);
}
开发者ID:TSM-Dev,项目名称:nh30,代码行数:7,代码来源:vector.hpp

示例6: GetEntryTarget

//-----------------------------------------------------------------------------
// Purpose: Get the absolute position of the desired attachment point
//-----------------------------------------------------------------------------
void CAI_PassengerBehaviorZombie::GetAttachmentPoint( Vector *vecPoint )
{
	Vector vecEntryOffset, vecFinalOffset;
	GetEntryTarget( &vecEntryOffset, NULL );
	VectorRotate( vecEntryOffset, m_hVehicle->GetAbsAngles(), vecFinalOffset );
	*vecPoint = ( m_hVehicle->GetAbsOrigin() + vecFinalOffset );
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:10,代码来源:ai_behavior_passenger_zombie.cpp

示例7: GetPositionMatrix

void CPhysicsObject::LocalToWorldVector( Vector &worldVector, const Vector &localVector )
{
	matrix3x4_t matrix;
	GetPositionMatrix( matrix );
	// copy in case the src == dest
	VectorRotate( Vector(localVector), matrix, worldVector );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:7,代码来源:physics_object.cpp

示例8: VectorRotate

void VectorRotate (vec3_t vIn, vec3_t vRotation, vec3_t vOrigin, vec3_t out)
{
  vec3_t vTemp, vTemp2;
  VectorSubtract(vIn, vOrigin, vTemp);
  VectorRotate(vTemp, vRotation, vTemp2);
  VectorAdd(vTemp2, vOrigin, out);
}
开发者ID:5Quintessential,项目名称:jedioutcast,代码行数:7,代码来源:mathlib.cpp

示例9: GetPositionMatrix

void CPhysicsObject::LocalToWorldVector(Vector *worldVector, const Vector &localVector) const {
	if (!worldVector) return;

	matrix3x4_t matrix;
	GetPositionMatrix(&matrix);
	VectorRotate(localVector, matrix, *worldVector);
}
开发者ID:jombo23,项目名称:Gmod-vphysics,代码行数:7,代码来源:Physics_Object.cpp

示例10: ComputeAbsolute

void ComputeAbsolute(face_t* f, vec3_t& p1, vec3_t& p2, vec3_t& p3)
{
	vec3_t ex,ey,ez;	        // local axis base

#ifdef _DEBUG
	if (g_qeglobals.m_bBrushPrimitMode)
		Sys_Printf("Warning : illegal call of ComputeAbsolute in brush primitive mode\n");
#endif

	// compute first local axis base
	TextureAxisFromPlane(&f->plane, ex, ey);
	CrossProduct(ex, ey, ez);

	vec3_t aux;
	VectorCopy(ex, aux);
	VectorScale(aux, -f->texdef.shift[0], aux);
	VectorCopy(aux, p1);
	VectorCopy(ey, aux);
	VectorScale(aux, -f->texdef.shift[1], aux);
	VectorAdd(p1, aux, p1);
	VectorCopy(p1, p2);
	VectorAdd(p2, ex, p2);
	VectorCopy(p1, p3);
	VectorAdd(p3, ey, p3);
	VectorCopy(ez, aux);
	VectorScale(aux, -f->texdef.rotate, aux);
	VectorRotate(p1, aux, p1);
	VectorRotate(p2, aux, p2);
	VectorRotate(p3, aux, p3);
	// computing rotated local axis base
	vec3_t rex,rey;
	VectorCopy(ex, rex);
	VectorRotate(rex, aux, rex);
	VectorCopy(ey, rey);
	VectorRotate(rey, aux, rey);

	ComputeScale(rex,rey,p1,f);
	ComputeScale(rex,rey,p2,f);
	ComputeScale(rex,rey,p3,f);

	// project on normal plane
	// along ez 
	// assumes plane normal is normalized
	ProjectOnPlane(f->plane.normal,f->plane.dist,ez,p1);
	ProjectOnPlane(f->plane.normal,f->plane.dist,ez,p2);
	ProjectOnPlane(f->plane.normal,f->plane.dist,ez,p3);
};
开发者ID:chenbk85,项目名称:3dlearn,代码行数:47,代码来源:SELECT.CPP

示例11: Rotate

			/**
			 * Method is used to rotate solid by vectors and angle.
			 * @param	a is rotate vector.
			 * @param	b is rotate vector.
			 * @param	angle is rotate angle value.
			 */
			void Rotate(const Vector& a, const Vector& b, float angle)
			{
				for(unsigned i = 0; i < vertices.size(); i++)
				{
					Vector v = vertices[i];
					v = VectorRotate(v, a, b, angle);
					vertices[i] = v;
				}
			}
开发者ID:veldrinlab,项目名称:ayumiEngine,代码行数:15,代码来源:Solid.hpp

示例12: ComputeAbsolute

void ComputeAbsolute( face_s* f, edVec3_c& p1, edVec3_c& p2, edVec3_c& p3 )
{
	edVec3_c ex, ey, ez;          // local axis base
	
#ifdef _DEBUG
	if ( g_qeglobals.m_bBrushPrimitMode )
		Sys_Printf( "Warning : illegal call of ComputeAbsolute in brush primitive mode\n" );
#endif
		
	// compute first local axis base
	TextureAxisFromPlane( f->plane, ex, ey );
	ez.crossProduct( ex, ey );
	
	edVec3_c aux = ex * -f->texdef.shift[0];
	p1 = aux;
	aux = ey * -f->texdef.shift[1];
	p1 += aux;
	p2 = p1;
	p2 += ex;
	p3 = p1;
	p3 += ey;
	aux = ez;
	aux *= -f->texdef.rotate;
	VectorRotate( p1, aux, p1 );
	VectorRotate( p2, aux, p2 );
	VectorRotate( p3, aux, p3 );
	// computing rotated local axis base
	edVec3_c rex = ex;
	VectorRotate( rex, aux, rex );
	edVec3_c rey = ey;
	VectorRotate( rey, aux, rey );
	
	ComputeScale( rex, rey, p1, f );
	ComputeScale( rex, rey, p2, f );
	ComputeScale( rex, rey, p3, f );
	
	// project on normal plane
	// along ez
	// assumes plane normal is normalized
	f->plane.projectOnPlane( ez, p1 );
	f->plane.projectOnPlane( ez, p2 );
	f->plane.projectOnPlane( ez, p3 );
};
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:43,代码来源:Select.cpp

示例13: VectorRotate

void DBrush::Rotate(vec3_t vOrigin, vec3_t vRotation)
{
    for(list<DPlane *>::const_iterator rotPlane=faceList.begin(); rotPlane!=faceList.end(); rotPlane++)
    {
        for(int i = 0; i < 3; i++)
            VectorRotate((*rotPlane)->points[i], vRotation, vOrigin);

        (*rotPlane)->Rebuild();
    }
}
开发者ID:ChunHungLiu,项目名称:GtkRadiant,代码行数:10,代码来源:DBrush.cpp

示例14: CreateSpotlightEntities

void CAI_Spotlight::UpdateSpotlightDirection( void )
{
	if ( !m_hSpotlight )
	{
		CreateSpotlightEntities();
	}

	// Compute the current beam direction
	Vector vTargetDir;
	VectorSubtract( m_vSpotlightTargetPos, m_hSpotlight->GetAbsStartPos(), vTargetDir ); 
	VectorNormalize(vTargetDir);
	ConstrainToCone( &vTargetDir );

	// Compute the amount to rotate
	float flDot = DotProduct( vTargetDir, m_vSpotlightDir );
	flDot = clamp( flDot, -1.0f, 1.0f );
	float flAngle = AngleNormalize( RAD2DEG( acos( flDot ) ) );
	float flClampedAngle = clamp( flAngle, 0.0f, 45.0f );
	float flBeamTurnRate = SimpleSplineRemapVal( flClampedAngle, 0.0f, 45.0f, 10.0f, 45.0f );
	if ( fabs(flAngle) > flBeamTurnRate * gpGlobals->frametime )
	{
		flAngle = flBeamTurnRate * gpGlobals->frametime;
	}

	// Compute the rotation axis
	Vector vecRotationAxis;
	CrossProduct( m_vSpotlightDir, vTargetDir, vecRotationAxis );
	if ( VectorNormalize( vecRotationAxis ) < 1e-3 )
	{
		vecRotationAxis.Init( 0, 0, 1 );
	}

	// Compute the actual rotation amount, using quat slerp blending
	Quaternion desiredQuat, resultQuat;
	AxisAngleQuaternion( vecRotationAxis, flAngle, desiredQuat );
	QuaternionSlerp( m_vAngularVelocity, desiredQuat, QUAT_BLEND_FACTOR, resultQuat );
	m_vAngularVelocity = resultQuat;

	// If we're really close, and we're not moving very quickly, slam.
	float flActualRotation = AngleNormalize( RAD2DEG(2 * acos(m_vAngularVelocity.w)) );
	if (( flActualRotation < 1e-3 ) && (flAngle < 1e-3 ))
	{
		m_vSpotlightDir = vTargetDir;
		m_vAngularVelocity.Init( 0, 0, 0, 1 );
		return;
	}

	// Update the desired direction
	matrix3x4_t rot;
	Vector vecNewDir;
	QuaternionMatrix( m_vAngularVelocity, rot );
	VectorRotate( m_vSpotlightDir, rot, vecNewDir );
	m_vSpotlightDir = vecNewDir;
	VectorNormalize(m_vSpotlightDir);
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:55,代码来源:ai_spotlight.cpp

示例15: DEG2RAD

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : flConvergencePerc - 
//			vecBasis - 
//-----------------------------------------------------------------------------
void CNPC_Combine_Cannon::UpdateAncillaryBeams( float flConvergencePerc, const Vector &vecOrigin, const Vector &vecBasis )
{
	// Multiple beams deviate from the basis direction by a certain number of degrees and "converge" 
	// at the basis vector over a duration of time, the position in that duration expressed by 
	// flConvergencePerc.  The beams are most deviated at 0 and fully converged at 1.

	float flRotationOffset = (2*M_PI)/(float)NUM_ANCILLARY_BEAMS; // Degrees separating each beam, in radians
	float flDeviation = DEG2RAD(90) * ( 1.0f - flConvergencePerc );
	float flOffset;
	Vector vecFinal;
	Vector vecOffset;
	
	matrix3x4_t matRotate;
	QAngle vecAngles;
	VectorAngles( vecBasis, vecAngles );
	vecAngles[PITCH] += 90.0f;
	AngleMatrix( vecAngles, vecOrigin, matRotate );

	trace_t	tr;

	float flScale = LINE_LENGTH * flDeviation;

	// For each beam, find its offset and trace outwards to place its endpoint
	for ( int i = 0; i < NUM_ANCILLARY_BEAMS; i++ )
	{
		if ( flConvergencePerc >= 0.99f )
		{
			m_pAncillaryBeams[i]->TurnOn();
			continue;
		}

		m_pAncillaryBeams[i]->TurnOff();

		// Find the number of radians offset we are
		flOffset = (float) i * flRotationOffset + DEG2RAD( 30.0f );
		flOffset += (M_PI/8.0f) * sin( gpGlobals->curtime * 3.0f );
		
		// Construct a circle that's also offset by the line's length
		vecOffset.x = cos( flOffset ) * flScale;
		vecOffset.y = sin( flOffset ) * flScale;
		vecOffset.z = LINE_LENGTH;

		// Rotate this whole thing into the space of the basis vector
		VectorRotate( vecOffset, matRotate, vecFinal );
		VectorNormalize( vecFinal );

		// Trace a line down that vector to find where we'll eventually stop our line
		UTIL_TraceLine( vecOrigin, vecOrigin + ( vecFinal * LINE_LENGTH ), MASK_SHOT, this, COLLISION_GROUP_NONE, &tr );

		// Move the beam to that position
		m_pAncillaryBeams[i]->SetBrightness( static_cast<int>(255.0f * flConvergencePerc) );
		m_pAncillaryBeams[i]->SetEndPos( tr.startpos );
		m_pAncillaryBeams[i]->SetStartPos( tr.endpos );
	}
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:60,代码来源:npc_combine_cannon.cpp


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