Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
bool CLTBBouncyChunkFX::Init(ILTClient *pClientDE, FX_BASEDATA *pBaseData, const CBaseFXProps *pProps)
{
	// Perform base class initialisation

	if (!CBaseFX::Init(pClientDE, pBaseData, pProps)) 
		return false;

	LTVector vChunkDir = GetProps()->m_vChunkDir;
	if (pBaseData->m_bUseTargetData)
	{
		vChunkDir = pBaseData->m_vTargetNorm;
	}

	LTVector vPos;
	LTRotation rRot;
	if (m_hParent)
	{
		m_pLTClient->GetObjectPos(m_hParent, &vPos);
		m_pLTClient->GetObjectRotation(m_hParent, &rRot);
	}	
	else
	{
		vPos = m_vCreatePos;
		rRot = m_rCreateRot;
	}

	float scale;
	CalcScale(m_tmElapsed, GetProps()->m_tmLifespan, &scale);

	LTVector vScale(scale, scale, scale);

	ObjectCreateStruct ocs;
	INIT_OBJECTCREATESTRUCT(ocs);

	ocs.m_ObjectType		= OT_MODEL;
	ocs.m_Flags				= FLAG_NOLIGHT | FLAG_VISIBLE;
	ocs.m_Pos				= vPos + GetProps()->m_vOffset;
	ocs.m_Rotation			= rRot;
	ocs.m_Scale				= vScale;
	strcpy(ocs.m_Filename, GetProps()->m_sModelName);
	strcpy(ocs.m_SkinName, GetProps()->m_sSkinName);

	m_hBouncyChunk = m_pLTClient->CreateObject(&ocs);

	// Setup an initial vector for the velocity

	LTVector vOther;
	vOther.x = 1.0f;
	vOther.y = 0.0f;
	vOther.z = 1.0f;
	vOther.Norm();

	LTVector vRight = vChunkDir.Cross(vOther);
	LTVector vUp    = vRight.Cross(vOther);

	m_vVel = vRight * (-GetProps()->m_fChunkSpread + (float)(rand() % (int)(GetProps()->m_fChunkSpread * 2.0f)));
	m_vVel += vUp * (-GetProps()->m_fChunkSpread + (float)(rand() % (int)(GetProps()->m_fChunkSpread * 2.0f)));
	m_vVel += vChunkDir * GetProps()->m_fChunkSpeed;
	m_vVel.Norm(GetProps()->m_fChunkSpeed);

	// Create the base object

	CreateDummyObject();
		
	// Success !!

	return true;
}