本文整理汇总了C++中Matrix34::Scale方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix34::Scale方法的具体用法?C++ Matrix34::Scale怎么用?C++ Matrix34::Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix34
的用法示例。
在下文中一共展示了Matrix34::Scale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetGeometry
//------------------------------------------------------------------------
void CTracer::SetGeometry(const char *name, float scale)
{
if (IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entityId))
{
m_geometrySlot = pEntity->LoadGeometry(TRACER_GEOM_SLOT, name);
if (scale != 1.0f)
{
Matrix34 tm = Matrix34::CreateIdentity();
tm.Scale(Vec3(scale, scale, scale));
pEntity->SetSlotLocalTM(m_geometrySlot, tm);
}
}
}
示例2: SetEffect
//------------------------------------------------------------------------
void CTracer::SetEffect(const char *name, float scale)
{
IParticleEffect *pEffect = gEnv->pParticleManager->FindEffect(name);
if (!pEffect)
{
return;
}
if (IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entityId))
{
int slot = pEntity->LoadParticleEmitter(TRACER_FX_SLOT, pEffect, 0, true);
if (scale != 1.0f)
{
Matrix34 tm = Matrix34::CreateIdentity();
tm.Scale(Vec3(scale, scale, scale));
pEntity->SetSlotLocalTM(slot, tm);
}
}
}
示例3: SetGeometry
//.........这里部分代码省略.........
pCharacter = GetEntity()->GetCharacter(eIGS_Arms);
}
else if(m_pForcedArms)
{
pCharacter = m_pForcedArms;
}
else
{
int armsId=m_stats.hand==eIH_Right?0:1;
pCharacter = GetOwnerActor()?GetOwnerActor()->GetFPArms(armsId):0;
}
if(pCharacter)
{
pCharacter->SetFlags(pCharacter->GetFlags()&(~CS_FLAG_UPDATE));
SetCharacterAttachment(eIGS_FirstPerson, ITEM_ARMS_ATTACHMENT_NAME, pCharacter, 0);
}
}
break;
case eIGS_FirstPerson:
case eIGS_ThirdPerson:
default:
{
if(!name || forceReload)
{
GetEntity()->FreeSlot(slot);
#ifndef ITEM_USE_SHAREDSTRING
m_geometry[slot].resize(0);
#else
m_geometry[slot].reset();
#endif
}
DestroyAttachmentHelpers(slot);
if(name && name[0])
{
if(m_geometry[slot] != name)
{
const char *ext = PathUtil::GetExt(name.c_str());
if((stricmp(ext, "chr") == 0) || (stricmp(ext, "cdf") == 0) || (stricmp(ext, "cga") == 0))
GetEntity()->LoadCharacter(slot, name, 0);
else
GetEntity()->LoadGeometry(slot, name, 0, 0);
changedfp=slot==eIGS_FirstPerson;
}
CreateAttachmentHelpers(slot);
SetDefaultIdleAnimation(slot, g_pItemStrings->idle);
}
if(slot == eIGS_FirstPerson)
{
ICharacterInstance *pCharacter = GetEntity()->GetCharacter(eIGS_FirstPerson);
if(pCharacter)
{
pCharacter->SetFlags(pCharacter->GetFlags()&(~CS_FLAG_UPDATE));
}
}
else if(slot == eIGS_Destroyed)
DrawSlot(eIGS_Destroyed, false);
}
break;
}
Matrix34 slotTM;
slotTM = Matrix34::CreateRotationXYZ(aoffset);
slotTM.Scale(Vec3(scale, scale, scale));
slotTM.SetTranslation(poffset);
GetEntity()->SetSlotLocalTM(slot, slotTM);
if(changedfp && m_stats.mounted)
{
PlayAction(m_idleAnimation[eIGS_FirstPerson], 0, true);
ForceSkinning(true);
if(!m_mountparams.pivot.empty())
{
Matrix34 tm=GetEntity()->GetSlotLocalTM(eIGS_FirstPerson, false);
Vec3 pivot = GetSlotHelperPos(eIGS_FirstPerson, m_mountparams.pivot.c_str(), false);
tm.AddTranslation(pivot);
GetEntity()->SetSlotLocalTM(eIGS_FirstPerson, tm);
}
GetEntity()->InvalidateTM();
}
m_geometry[slot] = name ? name : "";
ReAttachAccessories();
return true;
}
示例4: UpdateTPLaser
//------------------------------------------------------------------
void CLam::UpdateTPLaser(float frameTime, CItem* parent)
{
FUNCTION_PROFILER(GetISystem(), PROFILE_GAME);
const int frameId = gEnv->pRenderer->GetFrameID();
if (s_lastUpdateFrameId != frameId)
{
// Check how many LAMs to update this frame.
float dt = frameTime; // + s_laserUpdateTimeError;
const int n = s_lasers.size();
int nActive = 0;
for (int i = 0; i < n; ++i)
{
if (!s_lasers[i]->IsLaserActivated() && !s_lasers[i]->IsLightActivated())
continue;
nActive++;
}
float updatedPerSecond = (nActive / LASER_UPDATE_TIME) + s_laserUpdateTimeError;
int updateCount = (int)floorf(updatedPerSecond * dt);
if(dt==0.0f)
s_laserUpdateTimeError = 0.0f;
else
s_laserUpdateTimeError = updatedPerSecond - updateCount/dt;
s_curLaser %= n;
for (int i = 0, j = 0; i < n && j < updateCount ; ++i)
{
s_curLaser = (s_curLaser + 1) % n;
if (!s_lasers[s_curLaser]->IsLaserActivated() && !s_lasers[s_curLaser]->IsLightActivated())
continue;
s_lasers[s_curLaser]->SetAllowUpdate();
++j;
}
s_lastUpdateFrameId = frameId;
}
IEntity* pRootEnt = GetEntity();
if (!pRootEnt)
return;
IEntity *pLaserEntity = m_pEntitySystem->GetEntity(m_pLaserEntityId);
// if(!pLaserEntity)
// return;
const CCamera& camera = gEnv->pRenderer->GetCamera();
Vec3 lamPos = pRootEnt->GetWorldPos(); //pLaserEntity->GetParent()->GetWorldPos();
Vec3 dir = pRootEnt->GetWorldRotation().GetColumn1(); //pLaserEntity->GetParent()->GetWorldRotation().GetColumn1();
bool charNotVisible = false;
float dsg1Scale = 1.0f;
//If character not visible, laser is not correctly updated
if(parent)
{
if(CActor* pOwner = parent->GetOwnerActor())
{
ICharacterInstance* pCharacter = pOwner->GetEntity()->GetCharacter(0);
if(pCharacter && !pCharacter->IsCharacterVisible())
charNotVisible = true;
}
if(parent->GetEntity()->GetClass()==CItem::sDSG1Class)
dsg1Scale = 3.0f;
}
// if (!pLaserEntity->GetParent())
// return;
Vec3 hitPos(0,0,0);
float laserLength = 0.0f;
// HACK??: Use player movement controller locations, or else the laser
// pops all over the place when character out of the screen.
CActor *pActor = parent->GetOwnerActor();
if (pActor && (!pActor->IsPlayer() || charNotVisible))
{
if (IMovementController* pMC = pActor->GetMovementController())
{
SMovementState state;
pMC->GetMovementState(state);
if(!charNotVisible)
lamPos = state.weaponPosition;
else
{
float oldZPos = lamPos.z;
lamPos = state.weaponPosition;
if(m_lastZPos>0.0f)
lamPos.z = m_lastZPos; //Stabilize somehow z position (even if not accurate)
else
lamPos.z = oldZPos;
}
const float angleMin = DEG2RAD(3.0f);
const float angleMax = DEG2RAD(7.0f);
//.........这里部分代码省略.........
示例5: UpdateTPLaser
//.........这里部分代码省略.........
Vec3 hitPos(0,0,0);
float laserLength = 0.0f;
if(allowUpdate)
{
IPhysicalEntity* pSkipEntity = NULL;
if(GetOwner())
pSkipEntity = GetOwner()->GetPhysics();
const float range = m_LaserRangeTP;
// Use the same flags as the AI system uses for visibility.
const int objects = ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_independent; //ent_living;
const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit);
ray_hit hit;
if (gEnv->pPhysicalWorld->RayWorldIntersection(pos, dir*range, objects, flags,
&hit, 1, &pSkipEntity, pSkipEntity ? 1 : 0))
{
laserLength = hit.dist;
m_lastLaserHitPt = hit.pt;
m_lastLaserHitSolid = true;
}
else
{
m_lastLaserHitSolid = false;
m_lastLaserHitPt = pos + dir * range;
laserLength = range + 0.1f;
}
// Hit near plane
if (dir.Dot(camera.GetViewdir()) < 0.0f)
{
Plane nearPlane;
nearPlane.SetPlane(camera.GetViewdir(), camera.GetPosition());
nearPlane.d -= camera.GetNearPlane()+0.15f;
Ray ray(pos, dir);
Vec3 out;
m_lastLaserHitViewPlane = false;
if (Intersect::Ray_Plane(ray, nearPlane, out))
{
float dist = Distance::Point_Point(pos, out);
if (dist < laserLength)
{
laserLength = dist;
m_lastLaserHitPt = out;
m_lastLaserHitSolid = true;
m_lastLaserHitViewPlane = true;
}
}
}
hitPos = m_lastLaserHitPt;
}
else
{
laserLength = Distance::Point_Point(m_lastLaserHitPt, pos);
hitPos = pos + dir * laserLength;
}
if (m_smoothLaserLength < 0.0f)
m_smoothLaserLength = laserLength;
else
{
if (laserLength < m_smoothLaserLength)
m_smoothLaserLength = laserLength;
else
m_smoothLaserLength += (laserLength - m_smoothLaserLength) * min(1.0f, 10.0f * frameTime);
}
const float assetLength = 2.0f;
m_smoothLaserLength = CLAMP(m_smoothLaserLength,0.01f,m_LaserRangeTP);
float scale = m_smoothLaserLength / assetLength;
// Scale the laser based on the distance.
Matrix34 scl;
scl.SetIdentity();
scl.SetScale(Vec3(1,scale,1));
scl.SetTranslation(offset);
GetEntity()->SetSlotLocalTM( eIGS_Aux1, scl);
if (m_dotEffectSlot >= 0)
{
if (m_lastLaserHitSolid)
{
Matrix34 dotMatrix = Matrix34::CreateTranslationMat(Vec3(0,m_smoothLaserLength,0));
dotMatrix.AddTranslation(offset);
if(m_lastLaserHitViewPlane)
dotMatrix.Scale(Vec3(0.2f,0.2f,0.2f));
GetEntity()->SetSlotLocalTM(m_dotEffectSlot,dotMatrix);
}
else
{
Matrix34 scaleMatrix;
scaleMatrix.SetIdentity();
scaleMatrix.SetScale(Vec3(0.001f,0.001f,0.001f));
GetEntity()->SetSlotLocalTM(m_dotEffectSlot, scaleMatrix);
}
}
}
示例6: UpdateDotEffect
//=========================================
void CRocketLauncher::UpdateDotEffect(float frameTime)
{
Vec3 laserPos, dir;
CCamera& camera = gEnv->pSystem->GetViewCamera();
laserPos = camera.GetPosition();
dir = camera.GetMatrix().GetColumn1();
dir.Normalize();
const float nearClipPlaneLimit = 10.0f;
Vec3 hitPos(0,0,0);
float laserLength = 0.0f;
float dotScale=1.0f;
{
IPhysicalEntity* pSkipEntity = NULL;
if(GetOwner())
pSkipEntity = GetOwner()->GetPhysics();
const int objects = ent_all;
const int flags = (geom_colltype_ray << rwi_colltype_bit) | rwi_colltype_any | (10 & rwi_pierceability_mask) | (geom_colltype14 << rwi_colltype_bit);
ray_hit hit;
if (gEnv->pPhysicalWorld->RayWorldIntersection(laserPos, dir*m_LaserRange, objects,
flags, &hit, 1, &pSkipEntity, pSkipEntity?1:0))
{
//Clamp distance below near clip plane limits, if not dot will be overdrawn during rasterization
if(hit.dist>nearClipPlaneLimit)
{
laserLength = nearClipPlaneLimit;
hitPos = laserPos + (nearClipPlaneLimit*dir);
}
else
{
laserLength = hit.dist;
hitPos = hit.pt;
}
if(GetOwnerActor() && GetOwnerActor()->GetActorParams())
dotScale *= GetOwnerActor()->GetActorParams()->viewFoVScale;
}
else
{
hitPos = laserPos - (3.0f*dir);
laserLength = 3.0f;
}
}
if (m_dotEffectSlot>=0)
{
Matrix34 worldMatrix = GetEntity()->GetWorldTM();
if(laserLength<=0.7f)
hitPos = laserPos+(0.7f*dir);
if(IsWeaponLowered())
{
hitPos = laserPos+(2.0f*dir);
laserLength = 2.0f;
}
if(laserLength<=2.0f)
dotScale *= min(1.0f,(0.35f + ((laserLength-0.7f)*0.5f)));
Matrix34 localMatrix = worldMatrix.GetInverted()*Matrix34::CreateTranslationMat(hitPos-(0.2f*dir));
localMatrix.Scale(Vec3(dotScale,dotScale,dotScale));
GetEntity()->SetSlotLocalTM(m_dotEffectSlot, localMatrix);
}
}