本文整理汇总了C++中LTRotation类的典型用法代码示例。如果您正苦于以下问题:C++ LTRotation类的具体用法?C++ LTRotation怎么用?C++ LTRotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LTRotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyCapsuleBuoyancy
//given a capsule specified with a transform, two points, and a radius, this will approximate how much is submerged
//and distribute that force to the appropriate points on the capsule
static bool ApplyCapsuleBuoyancy(const LTVector& vPt1, const LTVector& vPt2, float fLength, float fRadius,
const LTPlane& WSPlane, float& fVolume, LTVector& vApplyAt,
float& fSurfaceArea)
{
//convert the capsule to an OBB and apply it
//determine information about the main axis
LTVector vMainAxis = vPt2 - vPt1;
LTASSERT( fLength > 0.0f, "Invalid capsule length." );
LTVector vUnitAxis = vMainAxis / fLength;
//we can now build up a rotation given the plane normal and the axis to build our transform
LTVector vUp = WSPlane.Normal();
if(fabsf(vUp.Dot(vUnitAxis)) > 0.99f)
{
//too close to use, built an arbitrary orthonormal
vUp = vUnitAxis.BuildOrthonormal();
}
LTMatrix3x4 mTemp;
LTVector vRight = vUnitAxis.Cross(vUp);
vRight.Normalize( );
LTVector vTrueUp = vRight.Cross( vUnitAxis );
mTemp.SetBasisVectors(vRight, vTrueUp, vUnitAxis);
LTRotation rRot;
rRot.ConvertFromMatrix(mTemp);
//now we can form our transform
LTRigidTransform tTransform((vPt1 + vPt2) * 0.5f, rRot);
LTVector vHalfDims(fRadius, fRadius, fLength * 0.5f + fRadius);
return ApplyOBBBuoyancy(tTransform, vHalfDims, WSPlane, fVolume, vApplyAt, fSurfaceArea);
}
示例2: ASSERT
bool CClientWeaponDisc::CalculateControlDirection( LTVector *pvControlDirection )
{
//
// safety check
//
// params
ASSERT( 0 != pvControlDirection );
// globals
ASSERT( 0 != g_pLTClient );
ASSERT( 0 != g_pPlayerMgr );
//
// The control direction is the direction the player is facing
//
// get the camera
HOBJECT hCamera;
hCamera = g_pPlayerMgr->GetCamera();
ASSERT( 0 != hCamera );
// determine the orientation of the segment
LTRotation rRot;
g_pLTClient->GetObjectRotation( hCamera, &rRot );
// determine the direction of the segment
LTVector vForward;
*pvControlDirection = rRot.Forward();
return true;
}
示例3: SetNextUpdate
LTBOOL ScaleSprite::Update()
{
if (m_bStartOn)
{
g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, USRFLG_VISIBLE, USRFLG_VISIBLE);
g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
}
SetNextUpdate(UPDATE_NEVER);
// BUG - This isn't quite right. Sometimes this works (flipping the sprite)
// other times the sprite shouldn't be flipped...Not sure what the bug is.
// For some reason the sprites are sometimes backwards...Get the rotation
// so we can flip it...
LTRotation rRot;
LTVector vPos, vDir, vU, vR, vF;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
g_pLTServer->GetObjectRotation(m_hObject, &rRot);
vU = rRot.Up();
vR = rRot.Right();
vF = rRot.Forward();
if (m_bFlushWithWorld)
{
// Align the sprite to the surface directly behind the sprite
// (i.e., opposite the forward vector)...
VEC_NORM(vF);
VEC_MULSCALAR(vDir, vF, -1.0f);
// Determine where on the surface to place the sprite...
IntersectInfo iInfo;
IntersectQuery qInfo;
VEC_COPY(qInfo.m_From, vPos);
VEC_COPY(qInfo.m_Direction, vDir);
qInfo.m_Flags = IGNORE_NONSOLID | INTERSECT_OBJECTS | INTERSECT_HPOLY;
qInfo.m_FilterFn = LTNULL;
if (g_pLTServer->CastRay(&qInfo, &iInfo))
{
LTVector vTemp;
VEC_COPY(vPos, iInfo.m_Point);
VEC_COPY(vDir, iInfo.m_Plane.m_Normal);
// Place the sprite just above the surface...
VEC_MULSCALAR(vTemp, vDir, 1.0f);
VEC_ADD(vPos, vPos, vTemp);
g_pLTServer->SetObjectPos(m_hObject, &vPos);
}
}
return LTTRUE;
}
示例4: GetProps
bool CFallingStuffFX::Init(ILTClient *pClientDE, FX_BASEDATA *pBaseData, const CBaseFXProps *pProps)
{
// Perform base class initialisation
if (!CBaseFX::Init(pClientDE, pBaseData, pProps))
return false;
// Store the first position as the last position
m_vLastPos = pBaseData->m_vPos;
// If we have a parent object, get it and apply it's rotation
// to the plane direction
m_vPlaneDir = GetProps()->m_vPlaneDir;
if (m_hParent)
{
LTRotation orient;
m_pLTClient->GetObjectRotation(m_hParent, &orient);
LTMatrix mRot;
Mat_SetBasisVectors(&mRot, &orient.Right(), &orient.Up(), &orient.Forward());
LTVector vTmp = m_vPlaneDir;
MatVMul(&m_vPlaneDir, &mRot, &vTmp);
}
LTVector vUp;
vUp.x = 0.0f;
vUp.y = 1.0f;
vUp.z = 0.0f;
LTVector vTest = m_vPlaneDir;
vTest.x = (float)fabs(vTest.x);
vTest.y = (float)fabs(vTest.y);
vTest.z = (float)fabs(vTest.z);
if (vTest == vUp)
{
// Gotsta use another axis
vUp.x = -1.0f;
vUp.y = 0.0f;
vUp.z = 0.0f;
}
m_vRight = m_vPlaneDir.Cross(vUp);
m_vUp = m_vPlaneDir.Cross(m_vRight);
// Create the base object
CreateDummyObject();
// Success !!
return true;
}
示例5: VEC_SET
void CDestructibleModel::DoExplosion(char* pTargetName)
{
CWeapons weapons;
weapons.Init(m_hObject);
weapons.ObtainWeapon(m_nExplosionWeaponId);
weapons.ChangeWeapon(m_nExplosionWeaponId);
CWeapon* pWeapon = weapons.GetCurWeapon();
if (!pWeapon) return;
weapons.SetAmmo(pWeapon->GetAmmoId());
pWeapon->SetDamageFactor(m_fDamageFactor);
LTRotation rRot;
g_pLTServer->GetObjectRotation(m_hObject, &rRot);
LTVector vF, vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
vF = rRot.Forward();
// Just blow up in place if we're not supposed to fire along
// forward vector and we don't have a target...
if (!m_bFireAlongForward)
{
pWeapon->SetLifetime(0.0f);
VEC_SET(vF, 0.0f, -1.0f, 0.0f); // Fire down
}
// See if we have a target...If so, point at it.
if (pTargetName)
{
ObjArray <HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray;
g_pLTServer->FindNamedObjects(pTargetName, objArray);
if (objArray.NumObjects())
{
LTVector vObjPos;
g_pLTServer->GetObjectPos(objArray.GetObject(0), &vObjPos);
vF = vObjPos - vPos;
vF.Normalize();
rRot = LTRotation(vF, LTVector(0.0f, 1.0f, 0.0f));
g_pLTServer->SetObjectRotation(m_hObject, &rRot);
}
}
WeaponFireInfo weaponFireInfo;
weaponFireInfo.hFiredFrom = m_hObject;
weaponFireInfo.vPath = vF;
weaponFireInfo.vFirePos = vPos;
weaponFireInfo.vFlashPos = vPos;
pWeapon->Fire(weaponFireInfo);
}
示例6: INIT_OBJECTCREATESTRUCT
void GameBase::CreateBoundingBox()
{
if (m_hDimsBox) return;
if (!g_vtDimsAlpha.IsInitted())
{
g_vtDimsAlpha.Init(g_pLTServer, "DimsAlpha", LTNULL, 1.0f);
}
ObjectCreateStruct theStruct;
INIT_OBJECTCREATESTRUCT(theStruct);
LTVector vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
theStruct.m_Pos = vPos;
SAFE_STRCPY(theStruct.m_Filename, "Models\\1x1_square.abc");
SAFE_STRCPY(theStruct.m_SkinName, "Models\\1x1_square.dtx");
theStruct.m_Flags = FLAG_VISIBLE | FLAG_NOLIGHT | FLAG_GOTHRUWORLD;
theStruct.m_ObjectType = OT_MODEL;
HCLASS hClass = g_pLTServer->GetClass("BaseClass");
LPBASECLASS pModel = g_pLTServer->CreateObject(hClass, &theStruct);
if (pModel)
{
m_hDimsBox = pModel->m_hObject;
LTVector vDims;
g_pLTServer->GetObjectDims(m_hObject, &vDims);
LTVector vScale;
VEC_DIVSCALAR(vScale, vDims, 0.5f);
g_pLTServer->ScaleObject(m_hDimsBox, &vScale);
}
LTVector vOffset;
LTRotation rOffset;
vOffset.Init();
rOffset.Init();
HATTACHMENT hAttachment;
LTRESULT dRes = g_pLTServer->CreateAttachment(m_hObject, m_hDimsBox, LTNULL,
&vOffset, &rOffset, &hAttachment);
if (dRes != LT_OK)
{
g_pLTServer->RemoveObject(m_hDimsBox);
m_hDimsBox = LTNULL;
}
LTVector vColor = GetBoundingBoxColor();
g_pLTServer->SetObjectColor(m_hDimsBox, vColor.x, vColor.y, vColor.z, g_vtDimsAlpha.GetFloat());
}
示例7: LTRotation
bool WorldModel::AttachServerMark( CServerMark& mark, CLIENTWEAPONFX & theStruct)
{
LTransform globalTransform, parentTransform, localTransform;
ILTTransform *pTransformLT;
LTVector vParentPos, vOffset;
LTRotation rParentRot, rRot;
LTRotation rOffset;
pTransformLT = g_pLTServer->GetTransformLT();
// Attach the mark to the parent object...
// Figure out what the rotation we want is.
rOffset.Init();
rRot = LTRotation(theStruct.vSurfaceNormal, LTVector(0.0f, 1.0f, 0.0f));
// MD
// Ok, now we have the transform in global space but attachments are specified in
// local space (so they can move as the object moves and rotates).
// Set the global LTransform.
pTransformLT->Set(globalTransform, theStruct.vPos, rRot);
// Get the object's transform.
g_pLTServer->GetObjectPos( m_hObject, &vParentPos);
g_pLTServer->GetObjectRotation( m_hObject, &rParentRot);
parentTransform.m_Pos = vParentPos;
parentTransform.m_Rot = rParentRot;
parentTransform.m_Scale.Init(1,1,1);
globalTransform.m_Scale.Init(1,1,1);
// Get the offset.
pTransformLT->Difference(localTransform, globalTransform, parentTransform);
vOffset = localTransform.m_Pos;
rOffset = localTransform.m_Rot;
HATTACHMENT hAttachment = NULL;
LTRESULT dRes = g_pLTServer->CreateAttachment( m_hObject, mark.m_hObject, LTNULL,
&vOffset, &rOffset, &hAttachment);
if (dRes != LT_OK)
{
return false;
}
// Add to the attachment list.
LTObjRefNotifier ref( *this );
ref = mark.m_hObject;
m_AttachmentList.push_back( ref );
return true;
}
示例8: sprintf
void CCoin::RotateToRest()
{
if ( !m_bRotatedToRest )
{
char szSpawn[1024];
sprintf(szSpawn, "WeaponItem Gravity 0;AmmoAmount 1;WeaponType Coin;AmmoType Coin");
LTVector vPos;
g_pLTServer->GetObjectPos(m_hObject, &vPos);
vPos.y += 2.0f; // This offsets us from the floor a bit so we don't pop through when WeaponItem sets its dims.
LTRotation rRot;
rRot.Init();
BaseClass* pObj = SpawnObject(szSpawn, vPos, rRot);
if ( pObj && pObj->m_hObject )
{
g_pLTServer->SetAcceleration(pObj->m_hObject, <Vector(0,0,0));
g_pLTServer->SetVelocity(pObj->m_hObject, <Vector(0,0,0));
}
g_pLTServer->SetObjectFlags(m_hObject, g_pLTServer->GetObjectFlags(m_hObject)&~FLAG_VISIBLE);
}
CGrenade::RotateToRest();
if ( IsCharacter(m_hFiredFrom) )
{
LTVector vPosition;
g_pLTServer->GetObjectPos(m_hObject, &vPosition);
CCharacter* pCharacter = (CCharacter*)g_pLTServer->HandleToObject(m_hFiredFrom);
CharCoinInfo cinfo;
cinfo.fTime = g_pLTServer->GetTime();
cinfo.eSurfaceType = m_eLastHitSurface;
cinfo.vPosition = vPosition;
SURFACE* pSurf = g_pSurfaceMgr->GetSurface(m_eLastHitSurface);
_ASSERT(pSurf);
if (pSurf)
{
cinfo.fVolume = pSurf->fMovementNoiseModifier;
}
else
{
cinfo.fVolume = 1.0f;
}
pCharacter->SetLastCoinInfo(&cinfo);
}
}
示例9: CreateObject
LTBOOL CBaseParticleSystemFX::CreateObject(ILTClient *pClientDE)
{
if (!CSpecialFX::CreateObject(pClientDE)) return LTFALSE;
LTVector vPos = m_vPos;
LTRotation rRot;
rRot.Init();
// Use server object position if a position wasn't specified...
if (m_hServerObject)
{
LTVector vZero(0, 0, 0), vServObjPos;
if (vPos.Equals(vZero))
{
pClientDE->GetObjectPos(m_hServerObject, &vServObjPos);
vPos = vServObjPos;
}
else
{
m_basecs.bClientControlsPos = LTTRUE;
}
// Calculate our offset from the server object...
m_vPosOffset = vPos - vServObjPos;
}
// Use the specified rotation if applicable
if (!m_rRot.IsIdentity())
{
rRot = m_rRot;
}
ObjectCreateStruct createStruct;
INIT_OBJECTCREATESTRUCT(createStruct);
createStruct.m_ObjectType = OT_PARTICLESYSTEM;
createStruct.m_Flags = FLAG_VISIBLE | FLAG_UPDATEUNSEEN | FLAG_FOGDISABLE;
createStruct.m_Pos = vPos;
createStruct.m_Rotation = rRot;
m_hObject = m_pClientDE->CreateObject(&createStruct);
// Setup the ParticleSystem...
return SetupSystem();
}
示例10: SetRot
void CMuzzleFlashFX::SetRot(LTRotation rRot)
{
if (!m_pClientDE) return;
HOBJECT hObj;
if (m_bUsingParticles)
{
hObj = m_Particle.GetObject();
if (hObj)
{
if (g_vtReallyClose.GetFloat())
{
LTRotation rInitRot;
rInitRot.Init();
m_pClientDE->SetObjectRotation(hObj, &rInitRot);
}
else
{
m_pClientDE->SetObjectRotation(hObj, &rRot);
}
}
}
if (m_bUsingLight)
{
hObj = m_Light.GetObject();
if (hObj)
{
m_pClientDE->SetObjectRotation(hObj, &rRot);
}
}
if (m_bUsingScale)
{
hObj = m_Scale.GetObject();
if (hObj)
{
LTRotation rTempRot = rRot;
// Camera relative rotation...
if (m_cs.bPlayerView)
{
rTempRot.Init();
}
m_pClientDE->SetObjectRotation(hObj, &rTempRot);
}
}
}
示例11: FireWeapon
bool GunMount::FireWeapon( )
{
CWeapon* pWeapon = m_Arsenal.GetCurWeapon( );
if( !pWeapon )
return false;
// Get the direction we're firing.
LTRotation rot;
g_pLTServer->GetObjectRotation( m_hObject, &rot );
LTVector vDir = rot.Forward( );
LTVector vPos;
if( !GetFirePos( vPos ))
{
g_pLTServer->GetObjectPos( m_hObject, &vPos );
}
// Tell the weapon to fire.
WeaponFireInfo weaponFireInfo;
static uint8 s_nCount = GetRandom( 0, 255 );
s_nCount++;
weaponFireInfo.hFiredFrom = m_hObject;
weaponFireInfo.hFiringWeapon = pWeapon->GetModelObject( );
weaponFireInfo.vPath = vDir;
weaponFireInfo.vFirePos = vPos;
weaponFireInfo.vFlashPos = vPos;
weaponFireInfo.nSeed = (uint8)GetRandom( 2, 255 );
weaponFireInfo.nPerturbCount = s_nCount;
weaponFireInfo.nFireTimestamp = g_pLTServer->GetRealTimeMS( );
WeaponState eWeaponState = pWeapon->UpdateWeapon( weaponFireInfo, true );
if( eWeaponState == W_FIRED )
{
// Count the round as fired.
if( m_nRoundsToFire > 0 )
m_nRoundsToFire--;
}
// Keep ammo count up and clip loaded. The weapon could have refused
// firing due to weapon fire time limitations, but it still decrements
// ammo.
m_Arsenal.AddAmmo( pWeapon->GetAmmoRecord(), 10 );
pWeapon->ReloadClip( false );
return true;
}
示例12: INIT_OBJECTCREATESTRUCT
void SecurityCamera::CreateLight()
{
// Create the light...and attach it to the camera...
ObjectCreateStruct theStruct;
INIT_OBJECTCREATESTRUCT(theStruct);
theStruct.m_Pos = m_vPos;
g_pServerButeMgr->GetSecurityCameraString("GreenLight",
theStruct.m_Filename, ARRAY_LEN(theStruct.m_Filename));
theStruct.m_Flags = FLAG_VISIBLE | FLAG_GLOWSPRITE;
theStruct.m_Flags2 = FLAG2_ADDITIVE;
theStruct.m_ObjectType = OT_SPRITE;
HCLASS hClass = g_pLTServer->GetClass("BaseClass");
LPBASECLASS pSprite = g_pLTServer->CreateObject(hClass, &theStruct);
if (!pSprite) return;
m_hLight = pSprite->m_hObject;
LTVector vScale(1, 1, 1);
vScale.x = g_pServerButeMgr->GetSecurityCameraFloat("LightScale");
vScale.y = vScale.x;
g_pLTServer->ScaleObject(m_hLight, &vScale);
// Attach the sprite to the the camera...
LTVector vOffset(0, 0, 0);
LTRotation rOffset;
rOffset.Init();
HATTACHMENT hAttachment;
LTRESULT dRes = g_pLTServer->CreateAttachment(m_hObject, m_hLight, "Light",
&vOffset, &rOffset, &hAttachment);
if (dRes != LT_OK)
{
g_pLTServer->RemoveObject(m_hLight);
m_hLight = LTNULL;
return;
}
}
示例13: CalcBeamCoords
LTBOOL CLaserTriggerFX::CalcBeamCoords()
{
if (!m_hServerObject) return LTFALSE;
// The beam is relative to the server object's dims...
LTVector vPos;
g_pLTClient->GetObjectPos(m_hServerObject, &vPos);
LTRotation rRot;
g_pLTClient->GetObjectRotation(m_hServerObject, &rRot);
LTVector vU, vR, vF;
vU = rRot.Up();
vR = rRot.Right();
vF = rRot.Forward();
// Okay, the beam is always along the object's longest dim...
LTVector vDir = vF;
LTFLOAT fLongestDim = m_cs.vDims.z; // Assume forward first...
m_pls.fMaxWidth = (m_cs.vDims.x + m_cs.vDims.y); // Assume x/y are same...
if (m_cs.vDims.y > fLongestDim)
{
vDir = vU;
fLongestDim = m_cs.vDims.y;
m_pls.fMaxWidth = (m_cs.vDims.x + m_cs.vDims.z);
}
if (m_cs.vDims.x > fLongestDim)
{
vDir = vR;
fLongestDim = m_cs.vDims.x;
m_pls.fMaxWidth = (m_cs.vDims.y + m_cs.vDims.z);
}
m_pls.vStartPos = vPos + (vDir * fLongestDim);
m_pls.vEndPos = vPos - (vDir * fLongestDim);
return LTTRUE;
}
示例14: SetupBodySpaceData
bool ConstraintWheel::SetupBodySpaceData(const LTRigidTransform& tInvBody1, const LTRigidTransform& tInvBody2)
{
//get the position of our object which will serve as the constraint point
LTVector vConstraintPos;
if(g_pLTServer->GetObjectPos(m_hObject, &vConstraintPos) != LT_OK)
return false;
LTRotation rConstraintOr;
if(g_pLTServer->GetObjectRotation(m_hObject, &rConstraintOr) != LT_OK)
return false;
m_vPivotPt1 = tInvBody1 * vConstraintPos;
m_vPivotPt2 = tInvBody2 * vConstraintPos;
m_vRotation1 = tInvBody1.m_rRot.RotateVector(rConstraintOr.Forward());
m_vRotation2 = tInvBody2.m_rRot.RotateVector(rConstraintOr.Forward());
m_vSuspension2 = tInvBody2.m_rRot.RotateVector(rConstraintOr.Up());
return true;
}
示例15:
void CFlashLight3rdPerson::GetLightPositions(LTVector& vStartPos, LTVector& vEndPos, LTVector& vUOffset, LTVector& vROffset)
{
if ( !m_hObj ) return;
HMODELSOCKET hSocket;
if ( LT_OK == g_pModelLT->GetSocket(m_hObj, "LeftHand", hSocket) )
{
LTransform tf;
if ( LT_OK == g_pModelLT->GetSocketTransform(m_hObj, hSocket, tf, LTTRUE) )
{
LTVector vPos = tf.m_Pos;
LTRotation rRot = tf.m_Rot;
LTVector vRight, vUp, vForward;
vRight = rRot.Right();
vUp = rRot.Up();
vForward = rRot.Forward();
//vStartPos = vPos - vUp*4.0f + vForward*8.0f;
//vEndPos = vPos + vForward*200.0f;
//vUOffset = vUp;
//vROffset = vRight;
vStartPos = vPos;
vEndPos = vPos + (vForward * g_cvarFLLightOffsetForward.GetFloat());
vROffset = (vRight * g_cvarFLLightOffsetRight.GetFloat());
vUOffset = (vUp * g_cvarFLLightOffsetUp.GetFloat());
// Update the Start/End position to addjust for any offset...
vEndPos += vROffset;
vEndPos += vUOffset;
vStartPos += vROffset;
vStartPos += vUOffset;
}
}
}