本文整理汇总了C++中Matrix34::SetIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix34::SetIdentity方法的具体用法?C++ Matrix34::SetIdentity怎么用?C++ Matrix34::SetIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix34
的用法示例。
在下文中一共展示了Matrix34::SetIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Reset
//------------------------------------------------------------------------
void CTracer::Reset(const Vec3 &pos, const Vec3 &dest)
{
m_pos.zero();
m_dest.zero();
m_startingPos=pos;
m_age=0.0f;
m_lifeTime=1.5f;
m_tracerFlags &= ~kTracerFlag_scaleToDistance;
m_startFadeOutTime = 0.0f;
m_slideFrac = 0.f;
if (IEntity *pEntity=gEnv->pEntitySystem->GetEntity(m_entityId))
{
pEntity->FreeSlot(TRACER_GEOM_SLOT);
pEntity->FreeSlot(TRACER_FX_SLOT);
Vec3 dir = dest - pos;
dir.Normalize();
Matrix34 tm;
tm.SetIdentity();
if(!dir.IsZero())
{
tm = Matrix33::CreateRotationVDir(dir);
}
tm.AddTranslation(pos);
pEntity->SetWorldTM(tm);
}
}
示例2: UpdateLaserGeometry
void CLaserBeam::UpdateLaserGeometry( IEntity& laserEntity )
{
// Scale the laser based on the distance.
const float assetLengthInv = 0.5f;
const float bias = g_pGameCVars->i_laser_hitPosOffset;
const float finalLaserLen = m_hasHitData ? max(0.f, m_lastLaserUpdatePosition.GetDistance(GetLastHit()) - bias) : 0.001f;
const float scale = finalLaserLen * assetLengthInv;
const float thickness = m_pLaserParams->laser_thickness[GetIndexFromGeometrySlot()];
const Quat inverseWorldQuat(laserEntity.GetWorldRotation().GetInverted());
Vec3 localSpaceDirection = inverseWorldQuat * m_lastLaserUpdateDirection;
const Vec3 finalHitPos = localSpaceDirection * finalLaserLen;
const Matrix34 localLaserMatrix = Matrix33::CreateOrientation(localSpaceDirection, Vec3(0.f, 0.f, 1.f), 0.f) *
Matrix34::CreateScale(Vec3(thickness, scale, thickness));
laserEntity.SetSlotLocalTM(m_laserGeometrySlot, localLaserMatrix);
// Set Dot matrix
if (m_hitSolid)
{
const Matrix34 mt = Matrix34::CreateTranslationMat(finalHitPos);
laserEntity.SetSlotLocalTM(m_laserDotSlot, mt);
}
else
{
Matrix34 scaleMatrix;
scaleMatrix.SetIdentity();
scaleMatrix.SetScale(Vec3(0.001f,0.001f,0.001f));
laserEntity.SetSlotLocalTM(m_laserDotSlot, scaleMatrix);
}
}
示例3: GetDestroyedGeometryTM
//------------------------------------------------------------------------
Matrix34 CVehiclePartAnimated::GetDestroyedGeometryTM(const char* pJointName, unsigned int index)
{
if (pJointName[0] && m_pCharInstanceDestroyed)
{
IDefaultSkeleton &rICharacterModelSkeletonDestroyed = m_pCharInstanceDestroyed->GetIDefaultSkeleton();
ISkeletonPose* pSkeletonDestroyed = m_pCharInstanceDestroyed->GetISkeletonPose();
CRY_ASSERT(pSkeletonDestroyed);
char buffer[256];
const char* pSuffix = !m_pSharedParameters->m_destroyedSuffix.empty() ? m_pSharedParameters->m_destroyedSuffix.c_str() : GetDestroyedGeometrySuffix(eVGS_Destroyed);
if (index == 0)
{
cry_sprintf(buffer, "%s%s", pJointName, pSuffix);
}
else
{
cry_sprintf(buffer, "%s_debris_%u", pJointName, index);
}
buffer[sizeof(buffer) - 1] = '\0';
int16 jointIdForDestroyed = rICharacterModelSkeletonDestroyed.GetJointIDByName(buffer);
if (jointIdForDestroyed > -1)
return Matrix34(pSkeletonDestroyed->GetAbsJointByID(jointIdForDestroyed));
}
Matrix34 identTM;
identTM.SetIdentity();
return identTM;
}
示例4: UpdateLaserScale
//-------------------------------------------------------------------
void CLam::UpdateLaserScale(float scaleLenght,IEntity* pLaserEntity)
{
if(pLaserEntity)
{
Matrix34 tm;
tm.SetIdentity();
tm.SetScale(Vec3(1.0f,scaleLenght,1.0f));
pLaserEntity->SetLocalTM(tm);
}
}
示例5: SpawnImpactEffect
void CBurnEffectManager::SpawnImpactEffect(const EventPhysCollision& pCollision, const char* effectName)
{
Vec3 surfaceNormal = pCollision.n;
Vec3 surfacePosition = pCollision.pt;
CItemParticleEffectCache& particleCache = g_pGame->GetGameSharedParametersStorage()->GetItemResourceCache().GetParticleEffectCache();
IParticleEffect* pParticleEffect = particleCache.GetCachedParticle(effectName);
if (pParticleEffect)
{
Matrix34 loc;
loc.SetIdentity();
loc.SetTranslation(surfacePosition);
loc.SetRotation33(OrthoNormalVector(surfaceNormal));
pParticleEffect->Spawn(false, loc);
}
}
示例6: AttachOnRope
//------------------------------------------------------------------------
void CVehicleActionDeployRope::AttachOnRope(IEntity *pEntity)
{
assert(pEntity);
if(!pEntity)
return;
IRopeRenderNode *pRopeUpper = GetRopeRenderNode(m_ropeUpperId);
if(!pRopeUpper)
return;
assert(pRopeUpper->GetPointsCount() >= 2);
IPhysicalEntity *pRopePhys = pRopeUpper->GetPhysics();
assert(pRopePhys);
typedef std::vector <Vec3> TVec3Vector;
TVec3Vector points;
int pointCount;
pe_status_rope ropeStatus;
if(pRopePhys->GetStatus(&ropeStatus))
pointCount = ropeStatus.nSegments + 1;
else
pointCount = 0;
if(pointCount < 2)
return;
points.resize(pointCount);
ropeStatus.pPoints = &points[0];
if(pRopePhys->GetStatus(&ropeStatus))
{
Matrix34 worldTM;
worldTM.SetIdentity();
worldTM = Matrix33(m_pVehicle->GetEntity()->GetWorldTM());
worldTM.SetTranslation(ropeStatus.pPoints[1]);
pEntity->SetWorldTM(worldTM);
}
pRopeUpper->LinkEndEntities(m_pVehicle->GetEntity()->GetPhysics(), pEntity->GetPhysics());
}
示例7: CreateBurnEffect
void CBurnEffectManager::CreateBurnEffect(const EventPhysCollision& pCollision, CBurnEffectManager::SBurnPoint* pBurnPoint)
{
Vec3 surfaceNormal = pCollision.n;
Vec3 hitDir(ZERO);
if (pCollision.vloc[0].GetLengthSquared() > 1e-6f)
{
hitDir = pCollision.vloc[0].GetNormalized();
}
Vec3 surfacePosition = pCollision.pt;
Vec3 halfVector = (surfaceNormal + (-hitDir)).GetNormalized();
CItemParticleEffectCache& particleCache = g_pGame->GetGameSharedParametersStorage()->GetItemResourceCache().GetParticleEffectCache();
IParticleEffect* pParticleEffect = particleCache.GetCachedParticle(pBurnPoint->m_pBurnParams->m_effectName);
if (pParticleEffect)
{
Matrix34 loc;
loc.SetIdentity();
loc.SetTranslation(surfacePosition);
loc.SetRotation33(OrthoNormalVector(surfaceNormal));
IParticleEmitter* pEffect = pParticleEffect->Spawn(false, loc);
if(pEffect)
{
pEffect->AddRef();
pBurnPoint->m_effect = pEffect;
const ParticleParams& particleParams = pParticleEffect->GetParticleParams();
pBurnPoint->m_attachType = particleParams.eAttachType;
pBurnPoint->m_attachForm = particleParams.eAttachForm;
}
UpdateBurnEffect(pBurnPoint);
}
UpdateBurnEffect(pBurnPoint);
}
示例8: CreateArticulatedCharacter
void CBoidObject::CreateArticulatedCharacter(SBoidContext &bc,const Vec3 &size,float mass)
{
Vec3 orgVelocity = m_speed*m_heading;
if(m_pPhysics && m_pPhysics->GetType() == PE_PARTICLE)
{
pe_params_particle pparams;
m_pPhysics->GetParams(&pparams);
orgVelocity = pparams.velocity*pparams.heading;
}
if(m_pPhysics)
{
m_pPhysics = 0;
}
IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entity);
if(!pEntity)
return;
Quat q(IDENTITY);
CalcOrientation(q);
pe_params_pos bodypos;
bodypos.pos = m_pos;
bodypos.q = q;
bodypos.scale = m_scale;
bodypos.iSimClass = 2;
SEntityPhysicalizeParams entityPhysParams;
entityPhysParams.type = PE_ARTICULATED;
entityPhysParams.nSlot = 0;
entityPhysParams.mass = mass;
entityPhysParams.nLod = 1;
pEntity->Physicalize(entityPhysParams);
// After physicalization reset entity slot matrix if present.
if(!bc.vEntitySlotOffset.IsZero())
{
Matrix34 tmIdent;
tmIdent.SetIdentity();
pEntity->SetSlotLocalTM(0,tmIdent);
}
m_pPhysics = pEntity->GetPhysics();
if(!m_pPhysics)
return;
m_pPhysics->SetParams(&bodypos);
//m_pPhysics = m_object->RelinquishCharacterPhysics();
pe_params_flags pf;
pf.flagsOR = pef_never_affect_triggers|pef_never_break;
m_pPhysics->SetParams(&pf);
pe_params_articulated_body pab;
pab.bGrounded = 0;
pab.bCheckCollisions = 1;
pab.bCollisionResp = 1;
m_pPhysics->SetParams(&pab);
pe_simulation_params symparams;
symparams.damping = 0.3f;
symparams.dampingFreefall = 0.2f;
m_pPhysics->SetParams(&symparams);
pe_params_buoyancy pb;
pb.waterDensity = 1000.0f;
pb.waterDamping = 1;
pb.waterResistance = 1000;
pb.waterPlane.n.Set(0,0,1);
//pb.waterPlane.origin.set(0,0,gEnv->p3DEngine->GetWaterLevel(&m_center));
pb.waterPlane.origin.Set(0,0,bc.waterLevel);
m_pPhysics->SetParams(&pb);
// Set original velocity on ragdoll.
pe_action_set_velocity psetvel;
psetvel.v = orgVelocity;
m_pPhysics->Action(&psetvel);
pe_params_part pp;
pp.flagsColliderOR=pp.flagsColliderAND = geom_colltype_debris;
pp.flagsAND = ~(geom_colltype_vehicle|geom_colltype6);
m_pPhysics->SetParams(&pp);
}
示例9: ProcessEvent
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
if (!pActInfo->pEntity)
return;
if (event == eFE_Activate && IsPortActive(pActInfo, IN_ACTIVATE))
{
pe_action_impulse action;
int ipart = GetPortInt( pActInfo, IN_PARTINDEX );
if (ipart>0)
action.ipart = ipart-1;
IEntity* pEntity = pActInfo->pEntity;
ECoordSys coordSys = (ECoordSys)GetPortInt( pActInfo, IN_COORDSYS );
if (coordSys==CS_PARENT && !pEntity->GetParent())
coordSys = CS_WORLD;
// When a "zero point" is set in the node, the value is left undefined and physics assume it is the CM of the object.
// but when the entity has a parent (is linked), then we have to use a real world coordinate for the point, because we have to apply the impulse to the highest entity
// on the hierarchy and physics will use the position of that entity instead of the position of the entity assigned to the node
bool bHaveToUseTransformedZeroPoint = false;
Vec3 transformedZeroPoint;
Matrix34 transMat;
switch (coordSys)
{
case CS_WORLD:
default:
{
transMat.SetIdentity();
bHaveToUseTransformedZeroPoint = pEntity->GetParent()!=NULL;
transformedZeroPoint = pEntity->GetWorldPos();
break;
}
case CS_PARENT:
{
transMat = pEntity->GetParent()->GetWorldTM();
bHaveToUseTransformedZeroPoint = pEntity->GetParent()->GetParent()!=NULL;
transformedZeroPoint = pEntity->GetParent()->GetWorldPos();
break;
}
case CS_LOCAL:
{
transMat = pEntity->GetWorldTM();
bHaveToUseTransformedZeroPoint = pEntity->GetParent()!=NULL;
transformedZeroPoint = pEntity->GetWorldPos();
break;
}
}
action.impulse = GetPortVec3( pActInfo, IN_IMPULSE );
action.impulse = transMat.TransformVector( action.impulse );
Vec3 angImpulse = GetPortVec3( pActInfo, IN_ANGIMPULSE );
if (!angImpulse.IsZero())
action.angImpulse = transMat.TransformVector( angImpulse );
Vec3 pointApplication = GetPortVec3( pActInfo, IN_POINT );
if (!pointApplication.IsZero())
action.point = transMat.TransformPoint( pointApplication );
else
{
if (bHaveToUseTransformedZeroPoint)
action.point = transformedZeroPoint;
}
// the impulse has to be applied to the highest entity in the hierarchy. This comes from how physics manage linked entities.
IEntity* pEntityImpulse = pEntity;
while (pEntityImpulse->GetParent())
{
pEntityImpulse = pEntityImpulse->GetParent();
}
IPhysicalEntity * pPhysEntity = pEntityImpulse->GetPhysics();
if (pPhysEntity)
pPhysEntity->Action( &action );
}
}
示例10: UpdateTPLaser
//.........这里部分代码省略.........
m_lastLaserHitViewPlane = false;
if (Intersect::Ray_Plane(ray, nearPlane, out))
{
float dist = Distance::Point_Point(lamPos, 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, lamPos);
hitPos = lamPos + 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);
}
float laserAIRange = 0.0f;
if (m_laserActivated && pLaserEntity)
{
// Orient the laser towards the point point.
Matrix34 parentTMInv;
parentTMInv = pRootEnt->GetWorldTM().GetInverted();
Vec3 localDir = parentTMInv.TransformPoint(hitPos);
float finalLaserLen = localDir.NormalizeSafe();
Matrix33 rot;
rot.SetIdentity();
rot.SetRotationVDir(localDir);
pLaserEntity->SetLocalTM(rot);
laserAIRange = finalLaserLen;
const float assetLength = 2.0f;
finalLaserLen = CLAMP(finalLaserLen,0.01f,m_lamparams.laser_max_len*dsg1Scale);
float scale = finalLaserLen / assetLength;
// Scale the laser based on the distance.
if (m_laserEffectSlot >= 0)
{
Matrix33 scl;
scl.SetIdentity();
scl.SetScale(Vec3(1,scale,1));
pLaserEntity->SetSlotLocalTM(m_laserEffectSlot, scl);
}
if (m_dotEffectSlot >= 0)
{
if (m_lastLaserHitSolid)
{
Matrix34 mt = Matrix34::CreateTranslationMat(Vec3(0,finalLaserLen,0));
if(m_lastLaserHitViewPlane)
mt.Scale(Vec3(0.2f,0.2f,0.2f));
pLaserEntity->SetSlotLocalTM(m_dotEffectSlot, mt);
}
else
{
Matrix34 scaleMatrix;
scaleMatrix.SetIdentity();
scaleMatrix.SetScale(Vec3(0.001f,0.001f,0.001f));
pLaserEntity->SetSlotLocalTM(m_dotEffectSlot, scaleMatrix);
}
}
}
float lightAIRange = 0.0f;
if (m_lightActivated)
{
float range = clamp(m_smoothLaserLength, 0.5f, m_lamparams.light_range[eIGS_ThirdPerson]);
lightAIRange = range * 1.5f;
if (m_lightID[eIGS_ThirdPerson] && m_smoothLaserLength > 0.0f)
{
CItem* pLightEffect = this;
if (IItem *pOwnerItem = m_pItemSystem->GetItem(GetParentId()))
pLightEffect = (CItem *)pOwnerItem;
pLightEffect->SetLightRadius(range, m_lightID[eIGS_ThirdPerson]);
}
}
if (laserAIRange > 0.0001f || lightAIRange > 0.0001f)
UpdateAILightAndLaser(lamPos, dir, lightAIRange, m_lamparams.light_fov[eIGS_ThirdPerson], laserAIRange);
}
示例11: Update
void CSmokeManager::Update(float dt)
{
PrefetchLine(m_smokeInstances, 0);
PrefetchLine(m_smokeInstances, 128);
const int kInitialNumActiveSmokeInstances = m_numActiveSmokeInstances;
//Update all smoke instances
for(int i = 0; i < kInitialNumActiveSmokeInstances; i++)
{
SSmokeInstance& smokeInstance = m_smokeInstances[i];
PrefetchLine(&smokeInstance, 128);
UpdateSmokeInstance(smokeInstance, dt);
}
#ifndef _RELEASE
DrawSmokeDebugSpheres();
#endif
//Remove any smoke instances marked for deletion
int iNumActiveSmokeInstances = kInitialNumActiveSmokeInstances;
for(int i = 0; i < iNumActiveSmokeInstances; i++)
{
SSmokeInstance& smokeInstance = m_smokeInstances[i];
//If this item is marked for deletion, copy the last element of the array
// over it
if(smokeInstance.state == eSIS_ForDeletion)
{
smokeInstance.RemoveObstructionObject();
const int iLastIndex = iNumActiveSmokeInstances - 1;
m_smokeInstances[i] = m_smokeInstances[iLastIndex];
m_smokeInstances[iLastIndex].state = eSIS_Unassigned;
m_smokeInstances[iLastIndex].pObstructObject = NULL;
iNumActiveSmokeInstances--;
i--;
}
}
m_numActiveSmokeInstances = iNumActiveSmokeInstances;
//Update smoke soundmood and screen effects for client
float insideSmokeFactor = 0.0f;
const bool clientInsideSmoke = ClientInsideSmoke(insideSmokeFactor);
SetSmokeSoundmood(clientInsideSmoke);
SetBlurredVision(insideSmokeFactor, dt);
if(clientInsideSmoke)
{
if(m_pInsideSmokeEmitter == NULL)
{
// Start smoke
Matrix34 spawnLocation;
spawnLocation.SetIdentity();
if (m_pInsideSmokeParticleEffect)
{
m_pInsideSmokeEmitter = m_pInsideSmokeParticleEffect->Spawn(false,spawnLocation);
if(m_pInsideSmokeEmitter)
{
m_pInsideSmokeEmitter->AddRef();
EntityId localActorId = g_pGame->GetIGameFramework()->GetClientActorId();
IEntity* pLocalActorEntity = gEnv->pEntitySystem->GetEntity(localActorId);
if(pLocalActorEntity)
{
m_pInsideSmokeEmitter->SetEntity(pLocalActorEntity,0);
}
}
}
}
if(m_pInsideSmokeEmitter && !m_pInsideSmokeEmitter->IsAlive())
{
m_pInsideSmokeEmitter->Activate(true);
}
}
else
{
if(m_pInsideSmokeEmitter && m_pInsideSmokeEmitter->IsAlive())
{
m_pInsideSmokeEmitter->SetEntity(NULL,0);
m_pInsideSmokeEmitter->Activate(false);
}
}
}
示例12: CalculateGlassBounds
//--------------------------------------------------------------------------------------------------
// Name: CalculateGlassBounds
// Desc: Calculates glass bounds from physics geometry
//--------------------------------------------------------------------------------------------------
void CBreakableGlassSystem::CalculateGlassBounds(const phys_geometry* const pPhysGeom, Vec3& size, Matrix34& matrix)
{
// Find thinnest axis of physics geometry
primitives::box bbox;
pPhysGeom->pGeom->GetBBox(&bbox);
Matrix33 basis = bbox.Basis.T();
Vec3 halfSize = bbox.size;
Vec3 center = bbox.center;
const uint thinAxis = idxmin3(&halfSize.x);
// Need to rotate so Z is our thin axis
if (thinAxis < 2)
{
float tempSize;
Matrix33 tempMat;
tempMat.SetIdentity();
// Calculate the rotation based on current facing dir
const Vec3 axes[2] =
{
Vec3Constants<float>::fVec3_OneX,
Vec3Constants<float>::fVec3_OneY
};
const Vec3& thinRow = bbox.Basis.GetRow(thinAxis);
const Vec3 localAxis = bbox.Basis.TransformVector(axes[thinAxis]);
float rot = (thinRow.Dot(localAxis) >= 0.0f) ? -gf_PI*0.5f : gf_PI*0.5f;
if (thinAxis == 0)
{
tempSize = halfSize.x;
halfSize.x = halfSize.z;
tempMat.SetRotationY(rot);
}
else
{
tempSize = halfSize.y;
halfSize.y = halfSize.z;
tempMat.SetRotationX(rot);
}
// Apply rotation to matrix and vectors
basis = basis * tempMat;
halfSize.z = tempSize;
}
// Assert minimum thickness
const float halfMinThickness = 0.004f;
halfSize.z = max(halfSize.z, halfMinThickness);
size = halfSize * 2.0f;
// Calculate locally offset bounds
matrix.SetIdentity();
matrix.SetTranslation(-halfSize);
matrix = basis * matrix;
matrix.AddTranslation(center);
}//-------------------------------------------------------------------------------------------------
示例13: if
//-----------------------------------------------
//This function is only executed on the server
void CC4Projectile::Stick(EventPhysCollision *pCollision)
{
assert(pCollision);
int trgId = 1;
IPhysicalEntity *pTarget = pCollision->pEntity[trgId];
if(pTarget == GetEntity()->GetPhysics())
{
trgId = 0;
pTarget = pCollision->pEntity[trgId];
}
//Do not stick to breakable glass
if(ISurfaceType *pSurfaceType = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceType(pCollision->idmat[trgId]))
{
if(pSurfaceType->GetBreakability()==1)
{
m_notStick = true;
return;
}
}
IEntity *pTargetEntity = pTarget ? gEnv->pEntitySystem->GetEntityFromPhysics(pTarget) : 0;
if(pTarget && (!pTargetEntity || (pTargetEntity->GetId() != m_ownerId)))
{
//Special cases
if(pTargetEntity)
{
//Stick to actors using a character attachment
CActor *pActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTargetEntity->GetId()));
//Not in MP
if(pActor && gEnv->bMultiplayer)
{
m_notStick = true;
return;
}
if(pActor && pActor->GetHealth()>0)
{
if(pActor->GetActorSpecies()!=eGCT_HUMAN)
{
m_notStick = true;
return;
}
if(StickToCharacter(true,pTargetEntity))
{
GetGameObject()->SetAspectProfile(eEA_Physics, ePT_None);
m_stuck = true;
}
m_notStick = true;
return;
}
//Do not stick to small objects...
if(!pActor)
{
pe_params_part pPart;
pPart.ipart = 0;
if(pTarget->GetParams(&pPart) && pPart.pPhysGeom && pPart.pPhysGeom->V<0.15f)
{
m_notStick = true;
return;
}
}
}
else if(pTarget->GetType()==PE_LIVING)
{
m_notStick = true;
return;
}
if(!pTargetEntity)
StickToStaticObject(pCollision,pTarget);
else
{
//Do not attach to items
if(g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pTargetEntity->GetId()))
{
m_notStick = true;
return;
}
Matrix34 mat = pTargetEntity->GetWorldTM();
mat.Invert();
Vec3 pos = mat.TransformPoint(pCollision->pt);
mat.SetIdentity();
mat.SetRotation33(Matrix33::CreateOrientation(-pCollision->n,GetEntity()->GetWorldTM().TransformVector(Vec3(0,0,1)),gf_PI));
mat.SetTranslation(pos);
//Dephysicalize and stick
GetGameObject()->SetAspectProfile(eEA_Physics, ePT_None);
//.........这里部分代码省略.........
示例14: 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);
}
}
}
示例15: UpdateSurfaceEffects
//.........这里部分代码省略.........
localTM.SetTranslation(worldTMInv * worldPos);
pEntity->SetSlotLocalTM(emitterIt->slot, localTM);
}
}
#if ENABLE_VEHICLE_DEBUG
if (DebugParticles() && m_pVehicle->IsPlayerDriving())
{
float color[] = {1,1,1,1};
ColorB red(255,0,0,255);
IRenderAuxGeom* pAuxGeom = gEnv->pRenderer->GetIRenderAuxGeom();
const char* effect = info.pParticleEmitter ? info.pParticleEmitter->GetName() : "";
const Matrix34& slotTM = m_pEntity->GetSlotWorldTM(emitterIt->slot);
Vec3 ppos = slotTM.GetTranslation();
pAuxGeom->DrawSphere(ppos, 0.2f, red);
pAuxGeom->DrawCone(ppos, slotTM.GetColumn1(), 0.1f, 0.5f, red);
gEnv->pRenderer->Draw2dLabel(50.f, (float)(400+10*emitterIt->slot), 1.2f, color, false, "<%s> water fx: slot %i [%s], speed %.1f, sizeScale %.2f, countScale %.2f (pos %.0f,%0.f,%0.f)", pEntity->GetName(), emitterIt->slot, effect, speed, sizeScale, countScale, ppos.x, ppos.y, ppos.z);
}
#endif
}
// generate water splashes
Vec3 wakePos;
if(m_pSplashPos)
{
wakePos = m_pSplashPos->GetWorldSpaceTranslation();
}
else
{
wakePos = worldTM.GetTranslation();
}
float wakeWaterLevel = gEnv->p3DEngine->GetWaterLevel(&wakePos);
const Vec3& localW = m_localSpeed;
if (localW.x >= 0.f)
m_diving = false;
if (!m_diving && localW.x < -0.03f && status.speed > 10.f && wakePos.z < m_lastWakePos.z && wakeWaterLevel+0.1f >= wakePos.z)
{
float speedRatio = min(1.f, status.speed/(m_maxSpeed*m_factorMaxSpeed));
m_diving = true;
if (m_pWaveEffect)
{
if (IParticleEmitter* pEmitter = pEntity->GetParticleEmitter(m_wakeSlot))
{
pEmitter->Activate(false);
pEntity->FreeSlot(m_wakeSlot);
m_wakeSlot = -1;
}
SpawnParams spawnParams;
spawnParams.fSizeScale = spawnParams.fCountScale = 0.5f + 0.25f*speedRatio;
spawnParams.fSizeScale += 0.4f*m_waveRandomMult;
spawnParams.fCountScale += cry_random(0.0f, 0.4f);
m_wakeSlot = pEntity->LoadParticleEmitter(m_wakeSlot, m_pWaveEffect, &spawnParams);
}
// handle splash sound
ExecuteTrigger(eSID_Splash);
SetSoundParam(eSID_Splash, "intensity", 0.2f*speedRatio + 0.5f*m_waveRandomMult);
if (m_rpmPitchDir == 0)
{
m_rpmPitchDir = -1;
m_waveSoundPitch = 0.f;
m_waveSoundAmount = 0.02f + m_waveRandomMult*0.08f;
}
}
if (m_wakeSlot != -1)
{
// update emitter local pos to short above waterlevel
Matrix34 tm;
if(m_pSplashPos)
m_pSplashPos->GetVehicleTM(tm);
else
tm.SetIdentity();
Vec3 pos = tm.GetTranslation();
pos.z = worldTMInv.TransformPoint(Vec3(wakePos.x,wakePos.y,wakeWaterLevel)).z + 0.2f;
tm.SetTranslation(pos);
pEntity->SetSlotLocalTM(m_wakeSlot, tm);
#if ENABLE_VEHICLE_DEBUG
if (IsProfilingMovement())
{
Vec3 wPos = worldTM * tm.GetTranslation();
ColorB col(128, 128, 0, 200);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(wPos, 0.4f, col);
gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(wPos, col, wPos+Vec3(0,0,1.5f), col);
}
#endif
}
m_lastWakePos = wakePos;
}