Ejemplo n.º 1
0
static LTVector GetNodeModelColor(ModelsDB::HNODE hModelNode)
{
	LTVector vColor(1, 1, 1);

	switch ( g_pModelsDB->GetNodeLocation( hModelNode ))
	{
		case HL_HEAD :
			vColor = LTVector(1, 0, 0);
		break;

		case HL_TORSO :
			vColor = LTVector(1, 1, 0);
		break;

		case HL_ARM_LEFT :
		case HL_ARM_RIGHT :
			vColor = LTVector(0, 1, 0);
		break;

		case HL_LEG_LEFT :
		case HL_LEG_RIGHT :
			vColor = LTVector(0, 0, 1);
		break;
	}

	return vColor;
}
Ejemplo n.º 2
0
void CPolygonDebrisFX::SetDebrisPos(int i, LTVector vPos)
{
	if (i < 0 || i >= m_ds.nNumDebris) return;
	if (i >= m_nNumPolies) return;
	if (m_Polies[i] == LTNULL) return;

	// Instead of moving the current poly, add another one at the
	// new position if we're showing a trail..

	if (m_cs.PolyDebrisFX.bShowTrail)
	{
		PLFXLINESTRUCT ls;

        LTVector vLength = (m_cs.vDir * GetRandom(m_cs.PolyDebrisFX.fMinLength, m_cs.PolyDebrisFX.fMaxLength)) / 2.0f;

		ls.vStartPos = vPos - vLength;

		// Get the last vert position...

		PolyLineList* pLines = m_Polies[i]->GetLines();
		if (pLines->GetLength() > 0)
		{
			PolyLine** pLine = pLines->GetItem(TLIT_LAST);
			if (pLine && *pLine)
			{
				PolyVertStruct** pVert = (*pLine)->list.GetItem(TLIT_LAST);
				if (pVert && *pVert)
				{
					ls.vStartPos = m_Polies[i]->GetVertPos((*pVert));
				}
			}
		}

        LTVector vMinC1 = m_cs.PolyDebrisFX.vMinColor1;
        LTVector vMaxC1 = m_cs.PolyDebrisFX.vMaxColor1;
        LTVector vMinC2 = m_cs.PolyDebrisFX.vMinColor2;
        LTVector vMaxC2 = m_cs.PolyDebrisFX.vMaxColor2;

		ls.vEndPos				= vPos;
        ls.vInnerColorStart     = LTVector(GetRandom(vMinC1.x, vMaxC1.x), GetRandom(vMinC1.y, vMaxC1.y), GetRandom(vMinC1.z, vMaxC1.z));
        ls.vInnerColorEnd       = LTVector(GetRandom(vMinC2.x, vMaxC2.x), GetRandom(vMinC2.y, vMaxC2.y), GetRandom(vMinC2.z, vMaxC2.z));
		ls.fAlphaStart			= m_cs.PolyDebrisFX.fInitialAlpha;
		ls.fAlphaEnd			= m_cs.PolyDebrisFX.fFinalAlpha;
        //ls.fLifeTime            = m_fDebrisLife[i] - (g_pLTClient->GetTime() - m_fStartTime);
		ls.fLifeTime			= g_cvarPolyDebrisTrailTime.GetFloat();
		ls.fLifeTime			= ls.fLifeTime < 0.0f ? 0.0f : ls.fLifeTime;
		ls.fAlphaLifeTime		= ls.fLifeTime;

		m_Polies[i]->AddLine(ls);
	}
	else
	{
		m_Polies[i]->SetPos(vPos);
	}
}
Ejemplo n.º 3
0
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, &LTVector(0,0,0));
			g_pLTServer->SetVelocity(pObj->m_hObject, &LTVector(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);
	}
}
Ejemplo n.º 4
0
bool CTrackedNodeMgr::SetNodeConstraints(	HTRACKEDNODE ID,
											float fXDiscomfortAngle,
											float fYDiscomfortAngle,
											float fXMaxAngle,
											float fYMaxAngle,
											float fMaxAngVel
										)
{
	//just forward this onto the more elaborate version
	return SetNodeConstraints(ID,	LTVector(0.0f, 1.0f, 0.0f), LTVector(-1.0f, 0.0f, 0.0f), 
									fXDiscomfortAngle, fYDiscomfortAngle,
									fXMaxAngle, fYMaxAngle,
									fMaxAngVel);
}
Ejemplo n.º 5
0
CPrefabRef *CPrefabMgr::CreateUnboundRef(CEditRegion *pRegion, CWorldNode *pParent, const char *pFilename, const char *pName)
{
	CPrefabRef *pResult = new CPrefabRef;
	// Set the object's name correctly
	pResult->SetName(pName);
	// Set its filename
	pResult->SetPrefabFilename(pFilename);
	// Clear out the position and orientation
	pResult->SetPos(LTVector(0.0f, 0.0f, 0.0f));
	pResult->SetOr(LTVector(0.0f, 0.0f, 0.0f));
	// Add it to the tree
	no_InitializeNewNode(pRegion, pResult, pParent);
	return pResult;
}
Ejemplo n.º 6
0
CAIMovement::CAIMovement()
{
	m_pAI = LTNULL;
	m_eState = eStateUnset;
	m_vDest = LTVector(0,0,0);
	m_pDestVolume = LTNULL;
	m_bUnderwater = LTFALSE;
	m_bClimbing = LTFALSE;
	m_bFaceDest = LTTRUE;
	m_bIgnoreVolumes = LTFALSE;
	m_eLastMovementType = kAM_None;
	m_fAnimRate = 1.f;
	m_bMovementLocked = LTFALSE;
	m_bRotationLocked = LTFALSE;
	m_bNoDynamicPathfinding = LTFALSE;
	m_vLastValidVolumePos.Init( 0.0f, 0.0f, 0.0f );
	m_bMoved = LTFALSE;

	m_bNewPathSet = LTFALSE;
	m_cBoundPts = 0;
	m_iBoundPt = 0;

	m_bDoParabola = LTFALSE;
	m_fParabolaPeakDist = 0.f;
	m_fParabolaPeakHeight = 0.f;
	m_fParabola_a = 0.f;
	m_bParabolaPeaked = LTFALSE;
}
Ejemplo n.º 7
0
void GetContouringInfo( LTVector &vForward, LTVector &vNormal, 
					   float &fOutAmount, float &fOutPitchPercent, float &fOutRollPercent )
{
	LTVector	vPlaneF = (vNormal.y >= 1.0f) ? vForward : vNormal;
	
	vPlaneF.y = 0.0f;
	vPlaneF.Normalize();

	LTRotation	rPlaneRot( vPlaneF, LTVector(0, 1, 0));
	LTVector	vPlaneR = rPlaneRot.Right();
	
	// Calculate how much pitch and roll we should apply...

	fOutPitchPercent	= vForward.Dot( vPlaneF );
	fOutRollPercent		= vForward.Dot( vPlaneR );

	// Figure out the length of the foward vector projected on the xz plane.  This
	// is needed because Euler angles are calculated cummulatively, not just based
	// on the global coordinate axis.

	float fXZLen = (float)sqrt( 1.0f - vNormal.y * vNormal.y );

	// Subtract the pitch from 90 degrees cause we want to be parallel to the plane

	fOutAmount = MATH_HALFPI - (float)atan2( vNormal.y, fXZLen );
}
Ejemplo n.º 8
0
void CHUDSubtitles::Render()
{
	// Sanity checks...
	if (!m_bVisible) return;
	if (GetConsoleInt("Subtitles",0) == 0) return;

	// Only show subtitles if conversations in range...
	LTVector vListenerPos;
	bool bListenerInClient;
	LTRotation rRot;
	g_pLTClient->GetListener(&bListenerInClient, &vListenerPos, &rRot);

	bool bForceDraw = (bool)(m_vSpeakerPos == LTVector(0, 0, 0));
	bForceDraw = ((g_pPlayerMgr->GetPlayerCamera()->GetCameraMode() == CPlayerCamera::kCM_Cinematic) ? true : bForceDraw);

	LTVector vPos = m_vSpeakerPos - vListenerPos;
	float fAdjustedRadius = m_fRadius * g_vtAdjustedRadius.GetFloat();

	if (!bForceDraw && vPos.Mag() > fAdjustedRadius)
		return;



	//render normal

	if (m_bOverflow)
		m_Text.RenderClipped(m_Rect);
	else
		m_Text.Render();


}
Ejemplo n.º 9
0
void LightGroup::UpdateClients()
{
	// Calculate our current color
	LTVector vColor = (m_bOn) ? m_vColor : LTVector(0.0f, 0.0f, 0.0f);

	{
		// Set up the update message
		CAutoMessage cMsg;
		cMsg.Writeuint8(MID_SFX_MESSAGE);
		cMsg.Writeuint8(SFX_LIGHTGROUP_ID);
		cMsg.WriteObject(m_hObject);
		cMsg.Writeuint32(m_nID);
		cMsg.WriteLTVector(vColor);

		// Send the message to all connected clients
		g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED);
	}
	
	{
		CAutoMessage cMsg;
		cMsg.Writeuint8(SFX_LIGHTGROUP_ID);

		cMsg.Writeuint32(m_nID);
		cMsg.WriteLTVector(vColor);

		// Make sure new clients will get the message
		g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read());
	}

	m_bClientNeedsUpdate = false;
}
Ejemplo n.º 10
0
//Given an index for a vertex to calculate a basis space for, as well as index offsets to
//form two basis vectors for a plane, it will calculate the space and store it in
//the vertex of the specified index
static inline void GenerateBasisSpace(char* pData, CPolyGridBumpVertex* pVert, int32 nXOff1, int32 nXOff2, int32 nYOff1, int32 nYOff2,
								  float fWidth, float fHeight, float fWidthTimesHeight, float fYScale)
{
	//sanity checks!
	assert(nXOff1 != nXOff2);
	assert(nYOff1 != nYOff2);

	pVert->m_vBasisRight.x = -fWidth;
	pVert->m_vBasisRight.y = ((int32)pData[nXOff1] - pData[nXOff2]) * fYScale;
	pVert->m_vBasisRight.z = 0.0f;

	pVert->m_vBasisForward.x = 0.0f;
	pVert->m_vBasisForward.y = ((int32)pData[nYOff1] - pData[nYOff2]) * fYScale;
	pVert->m_vBasisForward.z = fHeight;

	pVert->m_vBasisUp.x = pVert->m_vBasisRight.y * fHeight;
	pVert->m_vBasisUp.y = fWidthTimesHeight;
	pVert->m_vBasisUp.z = pVert->m_vBasisForward.y * fWidth;

	//normalize our normals
	pVert->m_vBasisUp.Normalize();
	pVert->m_vBasisForward.Normalize();
	pVert->m_vBasisRight.Normalize();

	//just a quick check to make sure that the normal is in the right hemisphere
	assert(pVert->m_vBasisUp.Dot(LTVector(0.0f, 1.0f, 0.0f)) > 0.0f);
}
Ejemplo n.º 11
0
LTVector CAIWeaponAbstract::DefaultGetFirePosition(CAI* pAI)
{
	if (!pAI)
	{
		return LTVector(0,0,0);
	}

	if ( !m_szFireSocketName.empty() )
	{
		HMODELSOCKET hFiringSocket = INVALID_MODEL_SOCKET;

		// Set the socket to fire from to the socket named if it exists
		// check to see if we already have the socket so we can try to
		// avoid annoying lookups.
		g_pModelLT->GetSocket( 
			pAI->m_hObject, 
			m_szFireSocketName.c_str(), 
			hFiringSocket);

		LTTransform transform;
		LTRESULT SocketTransform = g_pModelLT->GetSocketTransform( pAI->m_hObject, hFiringSocket, transform, true );
		AIASSERT( SocketTransform == LT_OK, pAI->m_hObject, "Unable to get socket for transform" );
		return transform.m_vPos;
	}
	else 
	{
		return pAI->GetWeaponPosition( m_pWeapon, false );
	}
}
Ejemplo n.º 12
0
//----------------------------------------------------------------------------
//              
//	ROUTINE:	CHoverMovementModifier::Update()
//              
//	PURPOSE:	Try to smooth the path within limits so that we don't snap on
//				stairs.  Otherwise just 
//              
//----------------------------------------------------------------------------
LTVector CHoverMovementModifier::Update( HOBJECT hObject, const LTVector& vDims, const LTVector& vOldPos, const LTVector& vNewPos, AIVolume* pLastVolume )
{
	// Get the position the AI is really at -- that is, the new X and Z, with
	// the OLD positions Y

	const LTVector vTruePos = LTVector( vNewPos.x, vOldPos.y, vNewPos.z);
	LTVector vFinalPosition = vTruePos;

	// Find the distance down to the new position the AI would be popped to.

	float flLowerBound = GetLowerBound( hObject, m_cCheckDist, vDims, vTruePos );

	// Find the DIFFERENCE between the heights.  If it is less than +-X, then
	// drift in that direction.  If it is greater, then snap to the max
	// distance away that is allowed

	float flDifference = (float)fabs( flLowerBound - vOldPos.y );
	if ( flDifference != 0.0f )
	{
		if ( flDifference <= m_cMaxVerticalDifference )
		{
			// Attempt to make the path a little bit smoother by adjusting
			// the position a bit more slowly
			LTVector vHorizontalMovement = vNewPos - vOldPos;
			vHorizontalMovement.y = 0;
			vFinalPosition.y = Interpolate( vOldPos.y, flLowerBound, vHorizontalMovement.Mag() );
		}
		else
		{
			vFinalPosition.y = Snap( vOldPos.y, flLowerBound, flDifference );
		}
	}

	return vFinalPosition;
}
Ejemplo n.º 13
0
void CLeanMgr::BeginLean( eLeanDirection kDir )
{
	m_kLeanDir = kDir;

	m_fMaxLeanAngle = DEG2RAD( g_vtLeanAngle.GetFloat() );
	m_fLeanFromAngle = m_fLastLeanAngle;

	m_fStartTime = 0.0f;
	m_fEndTime = g_vtLeanOutTime.GetFloat();

	if( m_bLeanedOut )
	{
		// Send a message to the server to remove the original stimulus.

		CAutoMessage cMsg;
		cMsg.Writeuint8( MID_PLAYER_CLIENTMSG );
		cMsg.Writeuint8( CP_PLAYER_LEAN );
		cMsg.Writeuint8( PL_CENTER );
		cMsg.WriteLTVector( LTVector( 0, 0, 0) );
		g_pLTClient->SendToServer( cMsg.Read(), MESSAGE_GUARANTEED );
	}

	// If we are just begining to lean then we are not leaned out...

	m_bLeanedOut = false;
}
Ejemplo n.º 14
0
bool GetIntersectionUnderPoint( LTVector &vInPt, HOBJECT *pFilterList, LTVector &vOutNormal, LTVector &vOutPt )
{
	IntersectQuery	iq;
	IntersectInfo		ii;
	
	vOutNormal.Init(0, 1, 0);

	iq.m_Flags	= IGNORE_NONSOLID | INTERSECT_OBJECTS | INTERSECT_HPOLY;
	iq.m_From	= vInPt;
	iq.m_To		= iq.m_From + LTVector( 0, -1, 0) * 256.0f;

	iq.m_FilterFn  = ObjListFilterFn;
	iq.m_pUserData = pFilterList;

	if( g_pLTClient->IntersectSegment( iq, &ii ) )
	{
		if( ii.m_hObject )
		{
			vOutNormal	= ii.m_Plane.m_Normal;
			vOutPt		= ii.m_Point;

			return true;
		}
	}
	
	return false;
}
CNudge::CNudge(CAIHuman* pAI)
{
	m_pAI = pAI;
	m_eState = eStateNoNudge;
	m_ePriority = ePriorityLow;
	m_vNudge = LTVector(0,0,0);
}
void CClientMeleeCollisionController::HandleBlocked(HOBJECT hTarget, const LTVector& vPos, const LTVector& vDir)
{
	// Get the proper weapon record...
	CClientWeapon* pClientWeapon = g_pClientWeaponMgr->GetCurrentClientWeapon();
	HWEAPON hWeapon = pClientWeapon ? pClientWeapon->GetWeaponRecord() : NULL;	//!!ARL: Use Attacker's weapon instead?  (will need to be sent from server - probably along with block info)
	HWEAPONDATA hWeaponData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA);

	// Spawn a block effect for it...
	const char* pszBlockFX = g_pWeaponDB->GetString(hWeaponData, "BlockFX");
	CLIENTFX_CREATESTRUCT fxcs(pszBlockFX, 0, LTRigidTransform(vPos, LTRotation(vDir, LTVector(0,1,0))));
	g_pGameClientShell->GetSimulationTimeClientFXMgr().CreateClientFX(NULL, fxcs, true);

	// Let the server objects know they've blocked / been blocked.
	CAutoMessage cMsg;
	cMsg.Writeuint8(MID_OBJECT_MESSAGE);
	cMsg.WriteObject(m_hObject);
	cMsg.Writeuint32(MID_MELEEBLOCK);
	cMsg.WriteObject(hTarget);
	g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED);

	// Disable attacker's collision (i.e. stop attacking).
	DisableCollisions();

	// For local player attackers, send a BlockRecoil stimulus so a proper animation can be played.
	if (m_hObject == g_pPlayerMgr->GetMoveMgr()->GetObject())
	{
		CPlayerBodyMgr::Instance().HandleAnimationStimulus("CS_RecoilFromBlock");
	}
}
Ejemplo n.º 17
0
bool MoveObjectToFloor(HOBJECT hObj, HOBJECT *pFilterList, ObjectFilterFn pFilterFn)
{
    if (!hObj) return false;

	// Intersect down to find the poly / object to move down to...

    LTVector vPos, vDims;
	g_pLTServer->GetObjectPos(hObj, &vPos);
	g_pPhysicsLT->GetObjectDims(hObj, &vDims);

	IntersectQuery IQuery;
	IntersectInfo IInfo;

	IQuery.m_From	= vPos;
	IQuery.m_To		= vPos + LTVector(0.0f, -10000.0f, 0.0f);

	IQuery.m_Flags	   = IGNORE_NONSOLID | INTERSECT_OBJECTS | INTERSECT_HPOLY;
	IQuery.m_FilterFn  = pFilterFn ? pFilterFn : ObjListFilterFn;
	IQuery.m_pUserData = pFilterList;

    if (g_pLTServer->IntersectSegment(IQuery, &IInfo))
	{
        float fDist = vPos.y - IInfo.m_Point.y;
		if (fDist > vDims.y)
		{
			vPos.y -= (fDist - (vDims.y + 0.1f));
			g_pLTServer->SetObjectPos(hObj, vPos);
            return true;
		}
	}

    return false;
}
Ejemplo n.º 18
0
void DebugLineSystem::AddArrow( const LTVector & vStart, const LTVector & vEnd,
								const DebugLine::Color & color /* = Color::White */,
								uint8 nAlpha /* = 255 */ )
{
	const float fHeadSize = 4.0f;
	LTVector vStartToEnd = vEnd - vStart;
	float fLen = vStartToEnd.Mag();
	if( vStartToEnd != LTVector::GetIdentity() )
	{
		vStartToEnd.Normalize();
	}

	AddLine( vStart, vEnd, color, nAlpha);

	LTVector vArrow = vStart + ( ( fLen * 0.9f ) * vStartToEnd );

	LTVector vUp( 0.f, 1.f, 0.f );
	LTVector vNorm;
	if( vStartToEnd != vUp )
	{
		vNorm = vStartToEnd.Cross( vUp );
	}
	else {
		vNorm = LTVector( 1.f, 0.f, 0.f );
	}

	vNorm *= ( fHeadSize/2.0f );
	AddLine( vArrow - vNorm, vArrow + vNorm, color, nAlpha);

	AddLine( vArrow + vNorm, vEnd, color, nAlpha);
	AddLine( vArrow - vNorm, vEnd, color, nAlpha);
}
Ejemplo n.º 19
0
LightBase::LightBase() :
	GameBase(OT_LIGHT)
{
	m_vColor				= LTVector(1.0f, 1.0f, 1.0f);
	m_vDirectionalDims		= LTVector(0.0f, 0.0f, 0.0f);
	m_vTranslucentColor		= LTVector(1.0f, 1.0f, 1.0f);
	m_vSpecularColor		= LTVector(1.0f, 1.0f, 1.0f);
	m_fLightRadius			= 300.0f;
	m_fIntensityScale		= 1.0f;
	m_eLightType			= eEngineLight_Invalid;
	m_fSpotFovX				= 90.0f;
	m_fSpotFovY				= 90.0f;
	m_fSpotNearClip			= 0.0f;
	m_eLightLOD				= eEngineLOD_Low;
	m_eWorldShadowsLOD		= eEngineLOD_Low;
	m_eObjectShadowsLOD		= eEngineLOD_Low;
}
Ejemplo n.º 20
0
//given a vector, this will return a rotation that uses the vector as the forward direction with a
//random twist
static LTRotation ConvertDirectionToOrientation(const LTVector& vUnitDir)
{
	//create a random rotation around the plane that we hit
	LTRotation rRot(vUnitDir, LTVector(0.0f, 1.0f, 0.0f));
	rRot.Rotate(vUnitDir, GetRandom(0.0f, MATH_TWOPI));

	return rRot;
}
Ejemplo n.º 21
0
//----------------------------------------------------------------------------
//              
//	ROUTINE:	CAIHumanStateResurrecting::Update()
//              
//	PURPOSE:	
//              
//----------------------------------------------------------------------------
/*virtual*/ void CAIHumanStateResurrecting::Update()
{
	CAIHumanState::Update();

	AIASSERT( m_fResurrectCompleteTime!=-1, GetAI()->m_hObject,
		"CAIHumanStateResurrecting::Update: m_fResurrectCompleteTime == -1" );

	if ( m_bFirstUpdate )
	{
		GetAI()->KillDlgSnd();

		// TEMP!!
		// Replace this with FXEd effects setup!
		CLIENTDEBRIS cd;
		cd.rRot			= m_pAI->GetRotation();
		cd.vPos			= m_pAI->GetPosition() + LTVector( 0.0f, 10.0f, 0.0f );
		cd.nDebrisId	= 43;
		::CreatePropDebris( cd.vPos, LTVector(0,1,0), 43 );
	}

	switch ( m_eStateStatus )
	{
		case kSStat_Conscious:
		break;

		case kSStat_RegainingConsciousness:
		{
			if ( GetAnimationContext()->IsPropSet(kAPG_Posture, kAP_Stand) )
			{
				m_eStateStatus = kSStat_Conscious;
				GetAI()->SetBlinking(LTTRUE);
			}
		}
		break;

		case kSStat_Resurrecting:
		{
			if ( m_fResurrectCompleteTime < g_pLTServer->GetTime() )
			{
				m_eStateStatus = kSStat_RegainingConsciousness;
			}
		}
		break;
	}
}
Ejemplo n.º 22
0
LTVector CAIWeaponThrown::GetFirePosition(CAI* pAI)
{
	if (!pAI)
	{
		return LTVector(0,0,0);
	}

	return pAI->GetWeaponPosition(m_pWeapon, true);
}
Ejemplo n.º 23
0
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);
}
Ejemplo n.º 24
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CDebugLineFX::Clear
//
//	PURPOSE:	Removes all lines from the system.
//
// ----------------------------------------------------------------------- //
void DebugLineSystem::Clear()
{
	lines.clear();
	nextLineToSend = lines.end();
	m_vVertexSum = LTVector(0,0,0);
	m_fNumSummedVertices = 0.0f;
	m_bClearOldLines = true;

}
Ejemplo n.º 25
0
CPrefabRef *CPrefabMgr::CreateRef(CEditRegion *pRegion, CWorldNode *pParent, CLoadedPrefab *pPrefab, const char *pName)
{
	// Create the prefab ref
	CPrefabRef *pResult = new CPrefabRef;
	// Set the object's name correctly
	pResult->SetName(pName);
	// Set its filename for later re-loading
	pResult->SetPrefabFilename(pPrefab->m_sName);
	// Point at the prefab
	pResult->SetPrefabTree(pPrefab->m_cRegion.GetRootNode());
	pResult->SetPrefabDims(pPrefab->m_vMin, pPrefab->m_vMax);
	// Clear out the position and orientation
	pResult->SetPos(LTVector(0.0f, 0.0f, 0.0f));
	pResult->SetOr(LTVector(0.0f, 0.0f, 0.0f));
	// Add it to the tree
	no_InitializeNewNode(pRegion, pResult, pParent);
	return pResult;
}
Ejemplo n.º 26
0
LTVector CAttachButeMgr::GetPVAttachmentScale( int nPVAttachmentID )
{
	if( nPVAttachmentID < 0 || nPVAttachmentID > m_cPVAttachmentID )
	{
		return LTVector(0, 0, 0);
	}
		
	sprintf( s_aTagName, "%s%d", ABM_PVATTACHMENT, nPVAttachmentID );
	return m_buteMgr.GetVector( s_aTagName, ABM_PVATTACHMENT_SCALE, CAVector( 0, 0, 0));
}
Ejemplo n.º 27
0
//virtual function that derived classes must override to handle loading in of
//property data
void LightDirectional::ReadLightProperties(const GenericPropList *pProps)
{
	m_vDirectionalDims = pProps->GetVector("Dims", LTVector(0.0f, 0.0f, 0.0f));
	m_fIntensityScale = pProps->GetReal("IntensityScale", 1.0f);

	//read in the texture associated with this light
	m_sLightTexture = pProps->GetString("Texture", "");
	m_sLightAttenuationTexture = pProps->GetString("AttenuationTexture", "");

	//read in the LOD's
	m_eLightLOD			= CEngineLODPropUtil::StringToLOD(pProps->GetString("LightLOD", ""));
	m_eWorldShadowsLOD	= CEngineLODPropUtil::StringToLOD(pProps->GetString("WorldShadowsLOD", ""));
	m_eObjectShadowsLOD = CEngineLODPropUtil::StringToLOD(pProps->GetString("ObjectShadowsLOD", ""));

	//read in colors and normalize them to be 0..1
	m_vColor			= pProps->GetColor("LightColor", LTVector(255.0f, 255.0f, 255.0f)) / 255.0f;
	m_vTranslucentColor = pProps->GetColor("TranslucentColor", LTVector(255.0f, 255.0f, 255.0f)) / 255.0f;
	m_vSpecularColor	= pProps->GetColor("SpecularColor", LTVector(255.0f, 255.0f, 255.0f)) / 255.0f;
}
Ejemplo n.º 28
0
LTBOOL CNodeController::Init(CCharacterFX* pCharacterFX)
{
	_ASSERT(pCharacterFX);
    if ( !pCharacterFX ) return LTFALSE;

	if (!g_vtLipSyncMaxRot.IsInitted())
	{
        g_vtLipSyncMaxRot.Init(g_pLTClient, "LipSyncMaxRot", NULL, 25.0f);
	}

	if (!g_vtLipSyncFreq.IsInitted())
	{
        g_vtLipSyncFreq.Init(g_pLTClient, "LipSyncFreq", NULL, 20.0f);
	}

	// Store our backpointer

	m_pCharacterFX = pCharacterFX;

	// Map all the nodes in our skeleton in the bute file to the nodes in the actual .abc model file

	int iNode = 0;
	HMODELNODE hCurNode = INVALID_MODEL_NODE;
    while ( g_pLTClient->GetNextModelNode(GetCFX()->GetServerObj(), hCurNode, &hCurNode) == LT_OK)
	{
		_ASSERT(m_cNodes < MAX_NODES);

		char szName[64] = "";
        g_pLTClient->GetModelNodeName(GetCFX()->GetServerObj(), hCurNode, szName, 64);

		ModelNode eModelNode = g_pModelButeMgr->GetSkeletonNode(m_pCharacterFX->GetModelSkeleton(), szName);

		if ( eModelNode != eModelNodeInvalid )
		{
			m_aNodes[eModelNode].eModelNode = eModelNode;
			m_aNodes[eModelNode].hModelNode = hCurNode;
		}

		m_cNodes++;
	}

	// Find our "rotor" nodes

	int cNodes = g_pModelButeMgr->GetSkeletonNumNodes(m_pCharacterFX->GetModelSkeleton());

	for ( iNode = 0 ; iNode < cNodes ; iNode++ )
	{
		if ( NODEFLAG_ROTOR & g_pModelButeMgr->GetSkeletonNodeFlags(m_pCharacterFX->GetModelSkeleton(), (ModelNode)iNode) )
		{
            AddNodeControlRotationTimed((ModelNode)iNode, LTVector(0,1,0), 40000.0f, 20000.0f);
		}
	}

    return LTTRUE;
}
Ejemplo n.º 29
0
void LightBase::HandleDimsMsg( HOBJECT /*hSender*/, const CParsedMsg &crParsedMsg )
{
	if(crParsedMsg.GetArgCount() == 4)
	{
		//read in our new dimensions and apply them
		m_vDirectionalDims.Init(	LTMAX(0.0f, (float)atof(crParsedMsg.GetArg(1))),
									LTMAX(0.0f, (float)atof(crParsedMsg.GetArg(2))),
									LTMAX(0.0f, (float)atof(crParsedMsg.GetArg(3))));
		g_pLTServer->SetLightDirectionalDims(m_hObject, m_vDirectionalDims * LTVector(0.5f, 0.5f, 1.0f));
	}
}
Ejemplo n.º 30
0
bool AIUtil_PositionShootable(CAI* pAI, const LTVector& vTargetOrigin)
{
	if (NULL == pAI 
		|| NULL == pAI->GetAIWeaponMgr()
		|| NULL == pAI->GetAIWeaponMgr()->GetCurrentWeapon())
	{
		return false;
	}

	LTVector vAIWeaponPosition = pAI->GetWeaponPosition(pAI->GetAIWeaponMgr()->GetCurrentWeapon(), false);

	// Bail if the AIs target is in the same position as the weapon.

	if (vTargetOrigin == vAIWeaponPosition)
	{
		return false;
	}

	// Bail if the combat opportunity is too far above or below the AI
	// (must be within the aiming range). 
	//
	// TODO: Determine what a good FOV without hardcoding this value. The
	// selected FOV fixed out cases, but this is animation driven, there
	// is no guarantee this is the ideal value.

	LTVector vToTargetUnit3D = (vTargetOrigin - vAIWeaponPosition).GetUnit();
	vToTargetUnit3D.y = fabs(vToTargetUnit3D.y);
	float fDotUp = LTVector(0.0f, 1.0f, 0.0f).Dot( vToTargetUnit3D );
	if (fDotUp >= c_fFOV60)
	{
		return false;
	}

	// Bail if the AI has to turn his back on his enemy/target to fire at this
	// position.

	LTVector vDirCombatOp = vTargetOrigin - vAIWeaponPosition;
	vDirCombatOp.y = 0.f;
	vDirCombatOp.Normalize();

	LTVector vDirTargetChar = pAI->GetAIBlackBoard()->GetBBTargetPosition() - vAIWeaponPosition;
	vDirTargetChar.y = 0.f;
	vDirTargetChar.Normalize();

	float fHorizontalDp = vDirCombatOp.Dot( vDirTargetChar );
	if( fHorizontalDp <= c_fFOV140 )
	{
		return false;
	}

	// Position is shootable.

	return true;
}