Esempio n. 1
0
//handles updating the properties of the light given the specified unit time value
void CDynaLightFX::UpdateDynamicProperties(float fUnitTime)
{
	//update the type of this light
	g_pLTClient->SetLightType(m_hLight, GetEngineLightType(GetProps()->m_efcType.GetValue(fUnitTime)));

	//the intensity of the light
	float fIntensity	= GetProps()->m_ffcIntensity.GetValue(fUnitTime);
	float fFlickerScale	= GetProps()->m_ffcFlickerScale.GetValue(fUnitTime);
	g_pLTClient->SetLightIntensityScale(m_hLight, LTMAX(0.0f, fIntensity * GetRandom(fFlickerScale, 1.0f)) );

	//get the color of this light
	LTVector vColor = ToColor3(GetProps()->m_cfcColor.GetValue(fUnitTime));
	g_pLTClient->SetObjectColor(m_hLight, vColor.x, vColor.y, vColor.z, 1.0f);

	//and now the radius of the light
	float fRadius = GetProps()->m_ffcRadius.GetValue(fUnitTime);
	g_pLTClient->SetLightRadius(m_hLight, fRadius);

	//the specular color
	LTVector4 vSpecular = GetProps()->m_cfcSpecularColor.GetValue(fUnitTime);
	g_pLTClient->SetLightSpecularColor(m_hLight, ToColor3(vSpecular));

	//the translucent color
	LTVector4 vTranslucent = GetProps()->m_cfcTranslucentColor.GetValue(fUnitTime);
	g_pLTClient->SetLightTranslucentColor(m_hLight, ToColor3(vTranslucent));

	//the spot light information
	float fFovX = MATH_DEGREES_TO_RADIANS(GetProps()->m_ffcSpotFovX.GetValue(fUnitTime));
	float fFovY = MATH_DEGREES_TO_RADIANS(GetProps()->m_ffcSpotFovY.GetValue(fUnitTime));

	g_pLTClient->SetLightSpotInfo(m_hLight, fFovX, fFovY, 0.0f);
}
Esempio n. 2
0
void LightBase::HandleSpotFOVMsg( HOBJECT /*hSender*/, const CParsedMsg &crParsedMsg )
{
	if(crParsedMsg.GetArgCount() == 3)
	{
		//read in our new dimensions and apply them
		m_fSpotFovX = LTCLAMP((float)atof(crParsedMsg.GetArg(1)), 0.0f, 90.0f);			
		m_fSpotFovY = LTCLAMP((float)atof(crParsedMsg.GetArg(2)), 0.0f, 90.0f);

		g_pLTServer->SetLightSpotInfo(m_hObject,	MATH_DEGREES_TO_RADIANS(m_fSpotFovX * 0.5f), 
													MATH_DEGREES_TO_RADIANS(m_fSpotFovY * 0.5f), 
													m_fSpotNearClip); 
	}
}
Esempio n. 3
0
uint32 RotatingDoor::EngineMessageFn(uint32 messageID, void *pData, float fData)
{
	switch (messageID)
	{
		case MID_PRECREATE:
		{
			// Need to call base class to have the object name read in before
			// we call PostPropRead()

            uint32 dwRet = Door::EngineMessageFn(messageID, pData, fData);

			if (fData == 1.0f)
			{
				ReadProp((ObjectCreateStruct*)pData);
			}

			// Convert speeds from degrees to radians
			m_fSpeed		= MATH_DEGREES_TO_RADIANS(m_fSpeed);
			m_fClosingSpeed	= MATH_DEGREES_TO_RADIANS(m_fClosingSpeed);

			return dwRet;
		}

		case MID_INITIALUPDATE:
		{
			if (fData != INITIALUPDATE_SAVEGAME)
			{
				InitialUpdate();
			}
			break;
		}

		case MID_SAVEOBJECT:
		{
            Save((HMESSAGEWRITE)pData, (uint8)fData);
		}
		break;

		case MID_LOADOBJECT:
		{
            Load((HMESSAGEREAD)pData, (uint8)fData);
		}
		break;

		default : break;
	}

	return Door::EngineMessageFn(messageID, pData, fData);
}
Esempio n. 4
0
bool CCreateRayProps::LoadProperty(ILTInStream* pStream, const char* pszName, const char* pszStringTable, const uint8* pCurveData)
{
	if(LTStrIEquals(pszName, "MaxDist"))
	{
		m_fMaxDist = CFxProp_Float::Load(pStream);
	}
	else if(LTStrIEquals(pszName, "MinDist"))
	{
		m_fMinDist = CFxProp_Float::Load(pStream);
	}
	else if(LTStrIEquals(pszName, "EffectOffset"))
	{
		m_fOffset = CFxProp_Float::Load(pStream);
	}
	else if(LTStrIEquals(pszName, "Alignment"))
	{
		m_eAlignment = (EAlignment)CFxProp_Enum::Load(pStream);
	}
	else if(LTStrIEquals(pszName, "RandomCone"))
	{
		m_fRandomCone = MATH_DEGREES_TO_RADIANS(CFxProp_Float::Load(pStream));
	}
	else if(LTStrIEquals(pszName, "CenterBias"))
	{
		m_fCenterBias = CFxProp_Float::Load(pStream);
	}
	else
	{
		return CBaseCreateProps::LoadProperty(pStream, pszName, pszStringTable, pCurveData);
	}

	return true;
}
Esempio n. 5
0
void ReadKLProps(ILTPreLight *pInterface, HPREOBJECT hObject, KLProps *pProps)
{
	GenericProp gProp;
    LTVector vUp, vRight;

	// Get light properties.
	pInterface->GetPropGeneric(hObject, "DirLight", &gProp);
	pProps->m_bDirLight = gProp.m_Bool;

	if(pProps->m_bDirLight)
		pInterface->GetPropGeneric(hObject, "DirLightRadius", &gProp);
	else
		pInterface->GetPropGeneric(hObject, "LightRadius", &gProp);

	pProps->m_fRadius = gProp.m_Float;

	pInterface->GetPropGeneric(hObject, "FOV", &gProp);
	pProps->m_fFOV = MATH_DEGREES_TO_RADIANS(gProp.m_Float);

	pInterface->GetPropGeneric(hObject, "InnerColor", &gProp);
	pProps->m_vInnerColor = gProp.m_Vec;

	pInterface->GetPropGeneric(hObject, "OuterColor", &gProp);
	pProps->m_vOuterColor = gProp.m_Vec;

	pInterface->GetPropGeneric(hObject, "UseShadowMaps", &gProp);
	pProps->m_bUseShadowMaps = gProp.m_Bool;

	pInterface->GetPropGeneric(hObject, "Pos", &gProp);
	pProps->m_vPos = gProp.m_Vec;

	pInterface->GetPropGeneric(hObject, "Rotation", &gProp);
	pInterface->GetMathLT()->GetRotationVectors(gProp.m_Rotation, vRight, vUp, pProps->m_vForwardVec);
}
void CNodeTrackerContext::SetDefaultLimits( EnumNodeTrackerGroup eGroup )
{
    if( eGroup == kTrackerGroup_None )
        return;

    ModelsDB::HTRACKERNODEGROUP hModelTrackerGroup = m_NodeTrackerInstances[eGroup].m_hModelTrackerGroup;
    CNodeTracker *pNodeTracker = m_NodeTrackerInstances[eGroup].m_pNodeTracker;
    if( !hModelTrackerGroup || !pNodeTracker )
        return;

    // Aimer limits (converted to radians).

    LTRect2f rLimits = g_pModelsDB->GetTrackerAimerNodeLimits( hModelTrackerGroup );
    rLimits.m_vMin.x = MATH_DEGREES_TO_RADIANS( rLimits.m_vMin.x );
    rLimits.m_vMax.x = MATH_DEGREES_TO_RADIANS( rLimits.m_vMax.x );
    rLimits.m_vMin.y = MATH_DEGREES_TO_RADIANS( rLimits.m_vMin.y );
    rLimits.m_vMax.y = MATH_DEGREES_TO_RADIANS( rLimits.m_vMax.y );
    pNodeTracker->SetAimerLimits( rLimits );
}
Esempio n. 7
0
// ----------------------------------------------------------------------- //
// Preprocessor callback to build a light animation frame.
// ----------------------------------------------------------------------- //
LTRESULT CLightFXPlugin::PreHook_Light(
    ILTPreLight *pInterface,
	HPREOBJECT hObject)
{
	PreLightAnimFrameInfo frame;
	PreLightInfo lightInfo;
	GenericProp gProp;
	char animName[512];
    LTBOOL bUseShadowMaps;
    LTVector vRight, vUp;


	// Only generate an animation if we need to.
	if(pInterface->GetPropGeneric(hObject, "UseLightAnims", &gProp) != LT_OK || !gProp.m_Bool)
		return LT_OK;

    frame.m_bSunLight = LTFALSE;
	frame.m_Lights = &lightInfo;
	frame.m_nLights = 1;

	pInterface->GetPropGeneric(hObject, "Pos", &gProp);
	lightInfo.m_vPos = gProp.m_Vec;

	pInterface->GetPropGeneric(hObject, "Color", &gProp);
	lightInfo.m_vInnerColor = gProp.m_Vec;
	lightInfo.m_vOuterColor.Init();

	pInterface->GetPropGeneric(hObject, "DirLight", &gProp);
	lightInfo.m_bDirectional = gProp.m_Bool;

	if(lightInfo.m_bDirectional)
		pInterface->GetPropGeneric(hObject, "DirLightRadius", &gProp);
	else
		pInterface->GetPropGeneric(hObject, "RadiusMax", &gProp);

	lightInfo.m_Radius = gProp.m_Float;

	pInterface->GetPropGeneric(hObject, "FOV", &gProp);
	lightInfo.m_FOV = MATH_DEGREES_TO_RADIANS(gProp.m_Float);

	pInterface->GetPropGeneric(hObject, "Rotation", &gProp);
	pInterface->GetMathLT()->GetRotationVectors(gProp.m_Rotation, vRight, vUp, lightInfo.m_vDirection);

	pInterface->GetPropGeneric(hObject, "Name", &gProp);
	GetCLightFXLightAnimName(animName, gProp.m_String);

	pInterface->GetPropGeneric(hObject, "UseShadowMaps", &gProp);
	bUseShadowMaps = gProp.m_Bool;

	pInterface->CreateLightAnim(animName, &frame, 1, bUseShadowMaps);
	return LT_OK;
}
Esempio n. 8
0
//an internal update functionality that must be called at the start of each effect's update
//function. This does not return any value so it does not need to be checked
void CBaseFX::BaseUpdate(float fTimeInterval)
{
	LTASSERT(IsActive() && !IsSuspended(), "Error: Updated an effect that was either suspended or inactive");

	//update the elapsed time
	m_tmElapsed += fTimeInterval;

	//handle updating the additional rotation of this object for this frame
	if(GetProps()->m_bUpdateRotation)
	{
		LTVector vAngles = GetProps()->m_vfcRotation.GetValue(GetUnitLifetime());
		LTRotation rRotation(	MATH_DEGREES_TO_RADIANS(vAngles.x) * fTimeInterval,
								MATH_DEGREES_TO_RADIANS(vAngles.y) * fTimeInterval,
								MATH_DEGREES_TO_RADIANS(vAngles.z) * fTimeInterval);
		m_rAdditional = rRotation * m_rAdditional;
	}

	//update our parent transformation as long as we aren't fixed, and actually have a parent
	if((m_hParentObject || m_hParentRigidBody) && (GetProps()->m_eFollowType != eFXFollowType_Fixed))
	{
		UpdateParentTransform();
	}
}
Esempio n. 9
0
//called to setup all variables on the engine object once it has been
//created
void LightBase::SetupEngineLight()
{
	//don't bother if we don't have a light
	if(!m_hObject)
		return;

	g_pLTServer->Common()->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
	g_pLTServer->SetObjectColor(m_hObject, m_vColor.x, m_vColor.y, m_vColor.z, 1.0f);
	g_pLTServer->SetLightTranslucentColor(m_hObject, m_vTranslucentColor);
	g_pLTServer->SetLightSpecularColor(m_hObject, m_vSpecularColor);
	g_pLTServer->SetLightRadius(m_hObject, m_fLightRadius);
	g_pLTServer->SetLightIntensityScale(m_hObject, m_fIntensityScale);
	g_pLTServer->SetLightType(m_hObject, m_eLightType);
	g_pLTServer->SetLightTexture(m_hObject, m_sLightTexture.c_str());
	g_pLTServer->SetLightAttenuationTexture(m_hObject, m_sLightAttenuationTexture.c_str());
	g_pLTServer->SetLightDirectionalDims(m_hObject, m_vDirectionalDims * LTVector(0.5f, 0.5f, 1.0f));

	g_pLTServer->SetLightSpotInfo(m_hObject, MATH_DEGREES_TO_RADIANS(m_fSpotFovX * 0.5f), 
											 MATH_DEGREES_TO_RADIANS(m_fSpotFovY * 0.5f), 
											 m_fSpotNearClip); 

	g_pLTServer->SetLightDetailSettings(m_hObject, m_eLightLOD, m_eWorldShadowsLOD, m_eObjectShadowsLOD);
}
Esempio n. 10
0
bool CParticleSystemProps::LoadProperty(ILTInStream* pStream, const char* pszName, const char* pszStringTable, const uint8* pCurveData)
{
	if( LTStrIEquals( pszName, "Material" ) )
	{
		m_pszMaterial = CFxProp_String::Load(pStream, pszStringTable);
	}
	else if (LTStrIEquals( pszName, "NumImages" ) )
	{
		m_nNumImages = (uint32)CFxProp_Int::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "PlayerView" ) )
	{
		m_bPlayerView = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "InSky" ))
	{
		m_eInSky = (EFXSkySetting)CFxProp_Enum::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "ParticleColor" ) )
	{
		m_cfcParticleColor.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "ParticleScale" ) )
	{
		m_ffcParticleScale.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "ParticlesPerEmission" ) )
	{
		m_nfcParticlesPerEmission.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "MinParticleLifeSpan" ) )
	{
		m_ffcMinLifetime.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "MaxParticleLifeSpan" ) )
	{	
		m_ffcMaxLifetime.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "AdditionalAcceleration") )
	{
		m_vfcAcceleration.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "GravityScale") )
	{
		m_ffcGravityScale.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "EmissionInterval" ) )
	{
		m_fEmissionInterval = CFxProp_Float::Load(pStream);
		//if this is above zero, make sure that it is set to a reasonable limit to prevent
		//effects from performing way too many emissions
		if(m_fEmissionInterval > 0.0f)
			m_fEmissionInterval = LTMAX(m_fEmissionInterval, 0.01f);
	}
	else if( LTStrIEquals( pszName, "GroupCreationInterval" ) )
	{
		m_fGroupCreationInterval = CFxProp_Float::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "EmissionDir" ) )
	{
		m_vEmissionDir = CFxProp_Vector::Load(pStream);	

		//handle the case of if an artist cleared it. They aren't supposed to, but happens occasionally
		if(m_vEmissionDir.NearlyEquals(LTVector::GetIdentity(), 0.01f))
			m_vEmissionDir.Init(0.0f, 1.0f, 0.0f);

		m_vEmissionDir.Normalize();

		// Get the perpindicular vectors to this plane
		FindPerps(m_vEmissionDir, m_vEmissionPerp1, m_vEmissionPerp2);
	}
	else if( LTStrIEquals( pszName, "EmissionOffset" ) )
	{
		m_vfcEmissionOffset.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "EmissionDims" ) )
	{
		m_vfcEmissionDims.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "EmissionMinRadius" ) )
	{
		m_ffcMinRadius.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "EmissionMaxRadius" ) )
	{
		m_ffcMaxRadius.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "MinParticleVelocity" ) )
	{
		m_vfcMinVelocity.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "MaxParticleVelocity" ) )
	{
		m_vfcMaxVelocity.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "EmissionType" ) )
	{
		m_eEmissionType = (ePSEmissionType)CFxProp_Enum::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "PercentToBounce" ) )
	{
		m_ffcPercentToBounce.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "RotateParticles" ) )
	{
		m_bRotate = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "MoveParticlesWithSystem" ) )
	{
		m_bObjectSpace = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "MinAngularVelocity" ) )
	{
		m_fMinAngularVelocity = MATH_DEGREES_TO_RADIANS(CFxProp_Float::Load(pStream));
	}
	else if( LTStrIEquals( pszName, "MaxAngularVelocity" ) )
	{
		m_fMaxAngularVelocity = MATH_DEGREES_TO_RADIANS(CFxProp_Float::Load(pStream));
	}
	else if( LTStrIEquals( pszName, "Streak") )
	{
		m_bStreak = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "StreakScale") )
	{
		m_fStreakScale = CFxProp_Float::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "Drag" ) )
	{
		m_ffcDrag.Load(pStream, pCurveData);
	}
	else if( LTStrIEquals( pszName, "BounceStrength" ) )
	{
		m_fBounceStrength = LTMAX(CFxProp_Float::Load(pStream), 0.0f);
	}
	else if( LTStrIEquals( pszName, "Solid" ) )
	{
		m_bSolid = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "TranslucentLight" ) )
	{
		m_bTranslucentLight = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "EnableBounceScale" ) )
	{
		m_bEnableBounceScale = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "VelocityType" ) )
	{
		m_eVelocityType = (ePSVelocityType)CFxProp_Enum::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "InfiniteLife" ) )
	{
		m_bInfiniteLife = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "SplatEffect" ) )
	{
		m_pszSplatEffect = CFxProp_String::Load(pStream, pszStringTable);
	}
	else if( LTStrIEquals( pszName, "SplatPercent" ) )
	{
		m_ffcPercentToSplat.Load(pStream, pCurveData);
	}
	else
	{
		return CBaseFXProps::LoadProperty(pStream, pszName, pszStringTable, pCurveData);
	}

	return true;	
}
Esempio n. 11
0
bool CLTBModelFX::Update(float tmFrameTime)
{

	//Ok, what we are going to do is see if we are supposed to be sync'd to the
	//animation. If so, we are going to flat out ignore tmCur, and instead generate
	//our own. This way we can match the model exactly.
	if(GetProps()->m_bSyncToModelAnim)
	{
		//we need to find out where in the animation the model currently is
		ILTModel		*pLTModel = m_pLTClient->GetModelLT();
		ANIMTRACKERID	nTracker;
		
		if(pLTModel->GetMainTracker( m_hObject, nTracker ) == LT_OK)
		{
			//we have the main tracker, see where in its timeline it is
			uint32 nCurrTime;
			uint32 nAnimTime;

			pLTModel->GetCurAnimTime(m_hObject, nTracker, nCurrTime);
			pLTModel->GetCurAnimLength(m_hObject, nTracker, nAnimTime);

			if(nAnimTime)
			{
				//handle wrapping
				nCurrTime %= nAnimTime;

				//ok, now convert cur time to a valid time
				m_tmElapsed = (nCurrTime * GetProps()->m_tmLifespan) / (float)nAnimTime;
			}
			else
			{
				//zero length animation?
				m_tmElapsed = 0.0f;
			}
		}
	}
	else if(GetProps()->m_bSyncToKey)
	{
		//we need to find out where in the key we currently are
		ILTModel		*pLTModel = m_pLTClient->GetModelLT();
		ANIMTRACKERID	nTracker;
		
		if(pLTModel->GetMainTracker( m_hObject, nTracker ) == LT_OK)
		{
			//we have the main tracker, see where in its timeline it is
			uint32 nAnimLength;
			m_pLTClient->GetModelLT()->ResetAnim( m_hObject, nTracker );
			pLTModel->GetCurAnimLength(m_hObject, nTracker, nAnimLength);

			if(nAnimLength > 0)
				nAnimLength--;

			float tmWrappedTime = fmodf(m_tmElapsed / GetProps()->m_tmLifespan, 1.0f);
			uint32 nAnimTime = (uint32)(tmWrappedTime * nAnimLength);
			pLTModel->SetCurAnimTime(m_hObject, nTracker, nAnimTime);
		}
	}
	
	// Base class update first	
	if (!CBaseFX::Update(tmFrameTime)) 
		return false;


	//see if we should reset our model animation
	if(!GetProps()->m_bSyncToKey && IsFinishedShuttingDown())
	{
		//Reset the animation
		ANIMTRACKERID	nTracker;
		
		m_pLTClient->GetModelLT()->GetMainTracker( m_hObject, nTracker );
		m_pLTClient->GetModelLT()->ResetAnim( m_hObject, nTracker );

		if(GetProps()->m_bOverrideAniLength)
			m_pLTClient->GetModelLT()->SetAnimRate( m_hObject, nTracker, m_fAniRate);
	}

	// Align if neccessary, to the rotation of our parent

	if ((m_hParent) && (GetProps()->m_nFacing == FACE_PARENTALIGN))
	{
		LTRotation rParentRot;
		m_pLTClient->GetObjectRotation(m_hParent, &rParentRot);
		rParentRot = (GetProps()->m_bRotate ? rParentRot : rParentRot * m_rNormalRot);
		m_pLTClient->SetObjectRotation(m_hObject, &rParentRot);
	}
	

	// If we want to add a rotation, make sure we are facing the correct way...
	
	if( GetProps()->m_bRotate )
	{
		LTFLOAT		tmFrame = tmFrameTime;
		LTVector	vR( m_rRot.Right() );
		LTVector	vU( m_rRot.Up() );
		LTVector	vF( m_rRot.Forward() );

		LTRotation	rRotation;

		if( m_hCamera && (GetProps()->m_nFacing == FACE_CAMERAFACING))
		{
			m_pLTClient->GetObjectRotation( m_hCamera, &rRotation );
		}
		else
		{
			m_pLTClient->GetObjectRotation( m_hObject, &rRotation );
		}

		m_rRot.Rotate( vR, MATH_DEGREES_TO_RADIANS( GetProps()->m_vRotAdd.x * tmFrame ));
		m_rRot.Rotate( vU, MATH_DEGREES_TO_RADIANS( GetProps()->m_vRotAdd.y * tmFrame ));
		m_rRot.Rotate( vF, MATH_DEGREES_TO_RADIANS( GetProps()->m_vRotAdd.z * tmFrame ));
		
		rRotation = rRotation * m_rRot;
		
		m_pLTClient->SetObjectRotation( m_hObject, &(rRotation * m_rNormalRot));
	}
	else if( GetProps()->m_nFacing == FACE_CAMERAFACING )
	{
		LTRotation rCamRot;

		m_pLTClient->GetObjectRotation( m_hCamera, &rCamRot );
		m_pLTClient->SetObjectRotation( m_hObject, &(rCamRot * m_rNormalRot) );
	}

	// Success !!

	return true;
}
Esempio n. 12
0
void CNodeController::UpdateLipSyncControl(NCSTRUCT *pNodeControl)
{
	// Make sure the sound handle is valid and check to see if the sound is done...
    if(!pNodeControl->hLipSyncSound || g_pLTClient->IsDone(pNodeControl->hLipSyncSound))
	{
		g_pLTClient->KillSound(pNodeControl->hLipSyncSound);
        pNodeControl->hLipSyncSound = LTNULL;

		if (pNodeControl->bShowingSubtitles)
		{
 			g_pInterfaceMgr->ClearSubtitle();
		}

        pNodeControl->pSixteenBitBuffer = LTNULL;
        pNodeControl->pEightBitBuffer = LTNULL;
        pNodeControl->bValid = LTFALSE;
		return;
	}


	//
	// Process the current sound data (average over sound amplitude).
	//

    LTFLOAT fAverage = 0.0f;  // this will hold the average, normalized from 0.0f to 1.0f.

	// Get the sound buffer.
	if( !pNodeControl->pSixteenBitBuffer && !pNodeControl->pEightBitBuffer )
	{
        uint32 dwChannels = 0;

        g_pLTClient->GetSoundData(pNodeControl->hLipSyncSound,
							pNodeControl->pSixteenBitBuffer,
							pNodeControl->pEightBitBuffer,
							&pNodeControl->dwSamplesPerSecond,
							&dwChannels);
		ASSERT( dwChannels == 1);
		// If you want to use multi-channel sounds (why would you?), you'll need to
		//  to account for the interleaving of channels in the following code.
	}

	ASSERT( pNodeControl->pSixteenBitBuffer || pNodeControl->pEightBitBuffer );


	// Average over the data.  We do an average of the data from the current point
	// being played to 1/g_vtLipSyncFreq.GetFloat() seconds ahead of that point.
    uint32 dwOffset = 0;
    uint32 dwSize   = 0;

    if( LT_OK == g_pLTClient->GetSoundOffset(pNodeControl->hLipSyncSound, &dwOffset, &dwSize) )
	{
		// Determine the end of the data we wish to average over.
        const uint32 dwDivisor = uint32(g_vtLipSyncFreq.GetFloat());
        uint32 dwOffsetEnd = dwOffset + pNodeControl->dwSamplesPerSecond/dwDivisor;
		if( dwOffsetEnd > dwSize )
			dwOffsetEnd = dwSize;


		// Accumulate the the amplitudes for the average.
        uint32 dwMaxAmplitude = 0;

        uint32 dwNumSamples = 0;
        uint32 dwAccum = 0;

		if( pNodeControl->pSixteenBitBuffer )
		{
			for( int16 * pIterator = pNodeControl->pSixteenBitBuffer + dwOffset;
			     pIterator < pNodeControl->pSixteenBitBuffer + dwOffsetEnd;
				 ++pIterator)
			{
				dwAccum += abs(*pIterator);
				++dwNumSamples;
			}

			dwMaxAmplitude = 65536/2;

			#ifdef GRAPH_LIPSYNC_SOUND
				g_GraphPoints.RecordData(pNodeControl->pSixteenBitBuffer,dwSize,dwOffset);
			#endif

		}
		else if( pNodeControl->pEightBitBuffer )
		{
			for( int8 * pIterator = pNodeControl->pEightBitBuffer + dwOffset;
			     pIterator < pNodeControl->pEightBitBuffer + dwOffsetEnd;
				 ++pIterator)
			{
				dwAccum += abs(*pIterator);
				++dwNumSamples;
			}

			dwMaxAmplitude = 256/2;

			#ifdef GRAPH_LIPSYNC_SOUND
				g_GraphPoints.RecordData(pNodeControl->pEightBitBuffer,dwSize,dwOffset);
			#endif
		}

		// And find the average!
		if( dwNumSamples > 0 )
            fAverage = LTFLOAT(dwAccum) / LTFLOAT(dwNumSamples) / LTFLOAT(dwMaxAmplitude);

    } //if( LT_OK == g_pLTClient->GetSoundOffset(pNodeControl->hLipSyncSound, &dwOffset, &dwSize) )

	//
	// Do the rotation.
	//
    ILTMath *pMathLT = g_pLTClient->GetMathLT();

    LTRotation rRot;
    rRot.Init();
    LTVector vAxis(0.0f, 0.0f, 1.0f);
    LTFLOAT fMaxRot = MATH_DEGREES_TO_RADIANS(g_vtLipSyncMaxRot.GetFloat());

	// Calculate the rotation.
	m_fCurLipSyncRot =  fAverage*fMaxRot;
	pMathLT->RotateAroundAxis(rRot, vAxis, -m_fCurLipSyncRot);

	// Create a rotation matrix and apply it to the current offset matrix
    LTMatrix m1;
	pMathLT->SetupRotationMatrix(m1, rRot);
	m_aNodes[pNodeControl->eModelNode].matTransform = m_aNodes[pNodeControl->eModelNode].matTransform * m1;
}
void CNodeTrackerContext::_Init( EnumNodeTrackerGroup eGroup )
{
    LTASSERT( eGroup != kTrackerGroup_None, "CNodeTrackerContext::_Init: No tracking group specified." );

    // Tracking node groups are optional per skeleton in ModelButes.txt.
    // A skeleton may not specify all (or any) tracking nodes.

    ModelsDB::HTRACKERNODEGROUP hModelTrackerGroup = m_NodeTrackerInstances[eGroup].m_hModelTrackerGroup;
    if( !hModelTrackerGroup )
    {
        return;
    }

    // Get the number of nodes.

    uint32 cNodes = g_pModelsDB->GetNumTrackerControlledNodes( hModelTrackerGroup );
    if( cNodes == 0 )
    {
        LTASSERT( 0, "CNodeTrackerContext::_Init: No tracker nodes in group." );
        return;
    }

    // Allocate a node tracker.

    CNodeTracker* pNodeTracker = debug_new( CNodeTracker );
    m_NodeTrackerInstances[eGroup].m_pNodeTracker = pNodeTracker;
    pNodeTracker->SetObject( m_hModel );
    pNodeTracker->SetSystemBlendWeight( 0.f );


    //
    // Setup the aimer node.
    //

    // Aimer node.

    HMODELNODE hAimerNode;
    const char* pszAimerNodeName = g_pModelsDB->GetTrackerAimerNodeName( hModelTrackerGroup );
    g_pModelLT->GetNode( m_hModel, pszAimerNodeName, hAimerNode);
    pNodeTracker->SetAimerNode( hAimerNode );

    // Aimer limits (converted to radians).

    LTRect2f rLimits = g_pModelsDB->GetTrackerAimerNodeLimits( hModelTrackerGroup );
    rLimits.m_vMin.x = MATH_DEGREES_TO_RADIANS( rLimits.m_vMin.x );
    rLimits.m_vMax.x = MATH_DEGREES_TO_RADIANS( rLimits.m_vMax.x );
    rLimits.m_vMin.y = MATH_DEGREES_TO_RADIANS( rLimits.m_vMin.y );
    rLimits.m_vMax.y = MATH_DEGREES_TO_RADIANS( rLimits.m_vMax.y );
    pNodeTracker->SetAimerLimits( rLimits );

    // Max speed (converted to radians).

    float fMaxSpeed;
    fMaxSpeed = g_pModelsDB->GetTrackerAimerNodeMaxSpeed( hModelTrackerGroup );
    fMaxSpeed = MATH_DEGREES_TO_RADIANS( fMaxSpeed );
    pNodeTracker->SetMaxSpeed( fMaxSpeed );


    //
    // Setup the controlled nodes.
    //

    HMODELNODE hControlledNode;
    float fControlledNodeWeight;
    pNodeTracker->SetNumControlledNodes( cNodes );
    for( uint32 iNode=0; iNode < cNodes; ++iNode )
    {
        // Controlled node.

        const char* pszControlledNodeName = g_pModelsDB->GetTrackerControlledNodeName( hModelTrackerGroup, iNode );
        g_pModelLT->GetNode( m_hModel, pszControlledNodeName, hControlledNode);
        pNodeTracker->SetControlledNode( iNode, hControlledNode );

        // Controlled node weight.

        fControlledNodeWeight = g_pModelsDB->GetTrackerControlledNodeWeight( hModelTrackerGroup, iNode );
        pNodeTracker->SetControlledNodeWeight( iNode, fControlledNodeWeight );
    }
}
void Breakable::ReadProp(ObjectCreateStruct *pStruct)
{
	GenericProp genProp;

    if (g_pLTServer->GetPropGeneric("BreakTime", &genProp) == LT_OK)
	{
		m_fBreakTime = genProp.m_Float;
	}

    if (g_pLTServer->GetPropGeneric("BreakSoundRadius", &genProp) == LT_OK)
	{
		m_fBreakSoundRadius = genProp.m_Float;
	}

    if (g_pLTServer->GetPropGeneric("ImpactSoundRadius", &genProp) == LT_OK)
	{
		m_fImpactSoundRadius = genProp.m_Float;
	}

    if (g_pLTServer->GetPropGeneric("DestroyOnImpact", &genProp) == LT_OK)
	{
		m_bDestroyOnImpact = genProp.m_Bool;
	}

    if (g_pLTServer->GetPropGeneric("DestroyAfterBreak", &genProp) == LT_OK)
	{
		m_bDestroyAfterBreak = genProp.m_Bool;
	}

    if (g_pLTServer->GetPropGeneric("CrushObjects", &genProp) == LT_OK)
	{
		m_bCrushObjects = genProp.m_Bool;
	}

    if (g_pLTServer->GetPropGeneric("TouchActivate", &genProp) == LT_OK)
	{
		m_bTouchActivate = genProp.m_Bool;
	}

    if (g_pLTServer->GetPropGeneric("BreakSound", &genProp) == LT_OK)
	{
		if (genProp.m_String[0])
		{
            m_hstrBreakSound = g_pLTServer->CreateString(genProp.m_String);
		}
	}

    if (g_pLTServer->GetPropGeneric("ImpactSound", &genProp) == LT_OK)
	{
		if (genProp.m_String[0])
		{
            m_hstrImpactSound = g_pLTServer->CreateString(genProp.m_String);
		}
	}

    if (g_pLTServer->GetPropGeneric("ScreenShakeAmount", &genProp ) == LT_OK)
	{
		m_vShakeAmount = genProp.m_Vec;
	}

    g_pLTServer->GetPropRotationEuler("Rotation", &m_vStartingPitchYawRoll);
	m_vPitchYawRoll = m_vStartingPitchYawRoll;

    if (g_pLTServer->GetPropGeneric("AdjustPitch", &genProp) == LT_OK)
	{
		m_vAdjust.x = genProp.m_Float;
	}

    if (g_pLTServer->GetPropGeneric("PitchDelta", &genProp) == LT_OK)
	{
		m_vTotalDelta.x = MATH_DEGREES_TO_RADIANS(genProp.m_Float);
	}

    if (g_pLTServer->GetPropGeneric("AdjustYaw", &genProp) == LT_OK)
	{
		m_vAdjust.y = genProp.m_Float;
	}

    if (g_pLTServer->GetPropGeneric("YawDelta", &genProp) == LT_OK)
	{
		m_vTotalDelta.y = MATH_DEGREES_TO_RADIANS(genProp.m_Float);
	}

    if (g_pLTServer->GetPropGeneric("AdjustRoll", &genProp) == LT_OK)
	{
		m_vAdjust.z = genProp.m_Float;
	}

    if (g_pLTServer->GetPropGeneric("RollDelta", &genProp) == LT_OK)
	{
		m_vTotalDelta.z = MATH_DEGREES_TO_RADIANS(genProp.m_Float);
	}

    if (g_pLTServer->GetPropGeneric("RotationTime", &genProp) == LT_OK)
	{
		if (genProp.m_Float > 0.0f)
		{
			m_fRotVel = MATH_CIRCLE / genProp.m_Float;
		}
		else
		{
			m_fRotVel = MATH_CIRCLE;
		}
	}

    if (g_pLTServer->GetPropGeneric("FallVelocity", &genProp) == LT_OK)
	{
		m_vVel.y = genProp.m_Float;
	}
}
Esempio n. 15
0
bool CBaseSpriteProps::LoadProperty(ILTInStream* pStream, const char* pszName, const char* pszStringTable, const uint8* pCurveData)
{
	if( LTStrIEquals( pszName, "Material" ))
	{
		m_pszMaterial = CFxProp_String::Load(pStream, pszStringTable );
	}
	else if( LTStrIEquals( pszName, "AspectWidth" ))
	{
		m_fAspectWidth = CFxProp_Float::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "AspectHeight" ))
	{
		m_fAspectHeight = CFxProp_Float::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "AlignToCamera" ))
	{
		m_bAlignToCamera = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "AlignAroundZ" ))
	{
		m_bAlignAroundZ = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "InSky" ))
	{
		m_eInSky = (EFXSkySetting)CFxProp_Enum::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "Solid" ))
	{
		m_bSolid = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "TranslucentLight" ) )
	{
		m_bTranslucentLight = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "TwoSided" ) )
	{
		m_bTwoSided = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "PlayerView" ) )
	{
		m_bPlayerView = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "RandomRotation" ) )
	{
		m_bRandomRotation = CFxProp_EnumBool::Load(pStream);
	}
	else if( LTStrIEquals( pszName, "RotationalVel" ) )
	{
		m_fRotationVelRad = MATH_DEGREES_TO_RADIANS(CFxProp_Float::Load(pStream));
	}
	else if( LTStrIEquals( pszName, "ToCameraOffset" ) )
	{
		m_fToCameraOffset = CFxProp_Float::Load(pStream);
	}
	else
	{
		return CBaseFXProps::LoadProperty(pStream, pszName, pszStringTable, pCurveData);
	}

	return true;
}