本文整理汇总了C++中VMatrix::ApplyRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ VMatrix::ApplyRotation方法的具体用法?C++ VMatrix::ApplyRotation怎么用?C++ VMatrix::ApplyRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VMatrix
的用法示例。
在下文中一共展示了VMatrix::ApplyRotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDebugName
void CNPC_SecobModportal1::Touch( CBaseEntity *pOther )
{
BaseClass::Touch( pOther );
// Did the player touch me?
if ( pOther->IsPlayer() )
{
const char *PlayerSteamID = engine->GetPlayerNetworkIDString(pOther->edict()); //Finds the current players Steam ID.
if( PlayerSteamID == NULL)
return;
char Portal2Name[ 512 ];
Q_strncpy( Portal2Name, "Portal2_" ,sizeof(Portal2Name));
Q_strncat( Portal2Name, PlayerSteamID,sizeof(Portal2Name), COPY_ALL_CHARACTERS );
// We look for Portal2 for our teleport point because we are Portal1.
CBaseEntity *pEnt = NULL;
pEnt = gEntList.FindEntityByName( pEnt, Portal2Name, NULL, pOther, pOther );
if (!pEnt )
{
return;
}
EmitSound( "PortalPlayer.EnterPortal" );
//PORTAL TRIGGER CODE.
// Don't touch entities that came through us and haven't left us yet.
/*EHANDLE hHandle;
hHandle = pOther;
if ( m_hDisabledForEntities.Find(hHandle) != m_hDisabledForEntities.InvalidIndex() )
{
Msg(" IGNORED\n", GetDebugName(), pOther->GetDebugName() );
return;
}
Pickup_ForcePlayerToDropThisObject( pOther );*/
pOther->SetGroundEntity( NULL );
// Build a this --> remote transformation
VMatrix matMyModelToWorld, matMyInverse;
matMyModelToWorld = pOther->EntityToWorldTransform();
MatrixInverseGeneral ( matMyModelToWorld, matMyInverse );
// Teleport our object
VMatrix matRemotePortalTransform = pEnt->EntityToWorldTransform();
Vector ptNewOrigin, vLook, vRight, vUp, vNewLook;
pOther->GetVectors( &vLook, &vRight, &vUp );
// Move origin
ptNewOrigin = matMyInverse * pOther->GetAbsOrigin();
ptNewOrigin = matRemotePortalTransform * Vector( ptNewOrigin.x, -ptNewOrigin.y, ptNewOrigin.z );
// Re-aim camera
vNewLook = matMyInverse.ApplyRotation( vLook );
vNewLook = matRemotePortalTransform.ApplyRotation( Vector( -vNewLook.x, -vNewLook.y, vNewLook.z ) );
// Reorient the physics
Vector vVelocity, vOldVelocity;
pOther->GetVelocity( &vOldVelocity );
vVelocity = matMyInverse.ApplyRotation( vOldVelocity );
vVelocity = matRemotePortalTransform.ApplyRotation( Vector( -vVelocity.x, -vVelocity.y, vVelocity.z ) );
QAngle qNewAngles;
VectorAngles( vNewLook, qNewAngles );
if ( pOther->IsPlayer() )
{
((CBasePlayer*)pOther)->SnapEyeAngles(qNewAngles);
}
Vector vecOldPos = pOther->WorldSpaceCenter();
// place player at the new destination
pOther->Teleport( &ptNewOrigin, &qNewAngles, &vVelocity );
// test collision on the new teleport location
Vector vMin, vMax, vCenter;
pOther->CollisionProp()->WorldSpaceAABB( &vMin, &vMax );
vCenter = (vMin + vMax) * 0.5f;
vMin -= vCenter;
vMax -= vCenter;
Vector vStart, vEnd;
vStart = ptNewOrigin;
vEnd = ptNewOrigin;
Ray_t ray;
ray.Init( vStart, vEnd, vMin, vMax );
trace_t tr;
this->TestCollision( ray, pOther->PhysicsSolidMaskForEntity(), tr );
// Teleportation caused us to hit something, deal with it.
if ( tr.DidHit() )
{
}
//.........这里部分代码省略.........
示例2: Touch
//-----------------------------------------------------------------------------
// Purpose: Upon touching a non-filtered entity, CTriggerPortal teleports them to it's
// remote portal location.
// Input : *pOther -
//-----------------------------------------------------------------------------
void CTriggerPortal::Touch( CBaseEntity *pOther )
{
// If we are enabled, and allowed to react to the touched entity
if ( PassesTriggerFilters(pOther) )
{
// If we somehow lost our pointer to the remote portal, get a new one
if ( m_hRemotePortal == NULL )
{
Disable();
return;
}
bool bDebug = portal_debug.GetBool();
if ( bDebug )
{
Msg("%s TOUCH: for %s\n", GetDebugName(), pOther->GetDebugName() );
}
// Don't touch entities that came through us and haven't left us yet.
EHANDLE hHandle;
hHandle = pOther;
if ( m_hDisabledForEntities.Find(hHandle) != m_hDisabledForEntities.InvalidIndex() )
{
Msg(" IGNORED\n", GetDebugName(), pOther->GetDebugName() );
return;
}
Pickup_ForcePlayerToDropThisObject( pOther );
// de-ground this entity
pOther->SetGroundEntity( NULL );
// Build a this --> remote transformation
VMatrix matMyModelToWorld, matMyInverse;
matMyModelToWorld = this->EntityToWorldTransform();
MatrixInverseGeneral ( matMyModelToWorld, matMyInverse );
// Teleport our object
VMatrix matRemotePortalTransform = m_hRemotePortal->EntityToWorldTransform();
Vector ptNewOrigin, vLook, vRight, vUp, vNewLook;
pOther->GetVectors( &vLook, &vRight, &vUp );
// Move origin
ptNewOrigin = matMyInverse * pOther->GetAbsOrigin();
ptNewOrigin = matRemotePortalTransform * Vector( ptNewOrigin.x, -ptNewOrigin.y, ptNewOrigin.z );
// Re-aim camera
vNewLook = matMyInverse.ApplyRotation( vLook );
vNewLook = matRemotePortalTransform.ApplyRotation( Vector( -vNewLook.x, -vNewLook.y, vNewLook.z ) );
// Reorient the physics
Vector vVelocity, vOldVelocity;
pOther->GetVelocity( &vOldVelocity );
vVelocity = matMyInverse.ApplyRotation( vOldVelocity );
vVelocity = matRemotePortalTransform.ApplyRotation( Vector( -vVelocity.x, -vVelocity.y, vVelocity.z ) );
QAngle qNewAngles;
VectorAngles( vNewLook, qNewAngles );
if ( pOther->IsPlayer() )
{
((CBasePlayer*)pOther)->SnapEyeAngles(qNewAngles);
}
Vector vecOldPos = pOther->WorldSpaceCenter();
if ( bDebug )
{
NDebugOverlay::Box( pOther->GetAbsOrigin(), pOther->WorldAlignMins(), pOther->WorldAlignMaxs(), 255,0,0, 8, 20 );
NDebugOverlay::Axis( pOther->GetAbsOrigin(), pOther->GetAbsAngles(), 10.0f, true, 50 );
}
// place player at the new destination
CTriggerPortal *pPortal = m_hRemotePortal.Get();
pPortal->DisableForIncomingEntity( pOther );
pOther->Teleport( &ptNewOrigin, &qNewAngles, &vVelocity );
if ( bDebug )
{
NDebugOverlay::Box( pOther->GetAbsOrigin(), pOther->WorldAlignMins(), pOther->WorldAlignMaxs(), 0,255,0, 8, 20 );
NDebugOverlay::Line( vecOldPos, pOther->WorldSpaceCenter(), 0,255,0, true, 20 );
NDebugOverlay::Axis( pOther->GetAbsOrigin(), pOther->GetAbsAngles(), 10.0f, true, 50 );
Msg("%s TELEPORTED: %s\n", GetDebugName(), pOther->GetDebugName() );
}
// test collision on the new teleport location
Vector vMin, vMax, vCenter;
pOther->CollisionProp()->WorldSpaceAABB( &vMin, &vMax );
vCenter = (vMin + vMax) * 0.5f;
vMin -= vCenter;
vMax -= vCenter;
Vector vStart, vEnd;
vStart = ptNewOrigin;
vEnd = ptNewOrigin;
//.........这里部分代码省略.........
示例3: SetupMatrixAxisRot
if(sv_surface_rotate.GetBool())
{
angle = view->GetViewSetup()->angles.y+180.0f;
//ConMsg("Angle = %f\n", angle);
pRenderContext->Rotate(angle, 0.0f, 0.0f, 1.0f);
//VMatrix rotationMatrix2 = SetupMatrixAngles(view->GetViewSetup()->angles);
//pRenderContext->MultMatrix(rotationMatrix2);
//VMatrix rotationMatrix = rotationMatrix2.InverseTR(); //SetupMatrixAngles(-(view->GetViewSetup()->angles));
rotationMatrix = SetupMatrixAxisRot(Vector(0.0f, 0.0f, 1.0f), -angle);
invRotationMatrix = SetupMatrixAxisRot(Vector(0.0f, 0.0f, 1.0f), angle);
Vector eye = view->GetViewSetup()->origin;
transformedEye = (eye-center)*(1.0f/m_flRadius);
transformedEye = rotationMatrix.ApplyRotation(transformedEye);
}
else
{
rotationMatrix.Identity();
invRotationMatrix.Identity();
transformedEye.Init();
angle = 0.0f;
}
if(sv_surface_use_tiler.GetBool())
{
tiler->beginFrame(Point3D(0.0f, 0.0f, 0.0f), (void*)&pRenderContext, !(sv_surface_draw_margin.GetBool()));
}
else
{