Пример #1
0
LTBOOL CParticleTrailSegmentFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
    if (!CBaseParticleSystemFX::Init(psfxCreateStruct)) return LTFALSE;

    g_cvarSmokeTrailStartScale.Init(g_pLTClient, "SmokeTrailStartScale", LTNULL, 1.0f);
    g_cvarSmokeTrailLWEndScale.Init(g_pLTClient, "SmokeTrailLWEndScale", LTNULL, 15.0f);
    g_cvarSmokeTrailSWEndScale.Init(g_pLTClient, "SmokeTrailSWEndScale", LTNULL, 15.0f);
    g_cvarSmokeTrailSBEndScale.Init(g_pLTClient, "SmokeTrailSBEndScale", LTNULL, 15.0f);
    g_cvarSmokeTrailStartAlpha.Init(g_pLTClient, "SmokeTrailStartAlpha", LTNULL, 0.9f);
    g_cvarSmokeTrailEndAlpha.Init(g_pLTClient, "SmokeTrailEndAlpha", LTNULL, 0.0f);

	PTSCREATESTRUCT* pPTS = (PTSCREATESTRUCT*)psfxCreateStruct;
	VEC_COPY(m_vColor1, pPTS->vColor1);
	VEC_COPY(m_vColor2, pPTS->vColor2);
	VEC_COPY(m_vDriftOffset, pPTS->vDriftOffset);
	m_nType			= pPTS->nType;
	m_fLifeTime		= pPTS->fLifeTime;
	m_fFadeTime		= pPTS->fFadeTime;
	m_fOffsetTime	= pPTS->fOffsetTime;
	m_fRadius		= pPTS->fRadius;
	m_fGravity		= pPTS->fGravity;
	m_nNumPerPuff	= pPTS->nNumPerPuff;

    m_bIgnoreWind   = LTFALSE;

	// We'll control the particle system's position...

    m_basecs.bClientControlsPos = LTTRUE;

    return LTTRUE;
}
Пример #2
0
DBOOL CParticleStreamFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CBaseParticleSystemFX::Init(psfxCreateStruct)) return DFALSE;

	PSTREAMCREATESTRUCT* pSS = (PSTREAMCREATESTRUCT*)psfxCreateStruct;

	m_fRadius			= pSS->fRadius;
	m_fPosRadius		= pSS->fPosRadius;
	m_fMinVel			= pSS->fMinVel;
	m_fMaxVel			= pSS->fMaxVel;
	m_nNumParticles		= pSS->nNumParticles;
	m_fSpread			= pSS->fSpread;
	VEC_COPY(m_vColor1, pSS->vColor1);
	VEC_COPY(m_vColor2, pSS->vColor2);
	m_fAlpha			= pSS->fAlpha;
	m_fMinLife			= pSS->fMinLife;
	m_fMaxLife			= pSS->fMaxLife;
	m_fRampTime			= pSS->fRampTime;
	m_fDelay			= pSS->fDelay;
	m_bState			= pSS->bOn ? 2 : 0;
	m_bRampFlags		= pSS->bRampFlags;
	m_fGravity			= pSS->fGravity;

	m_hstrSound1		= pSS->hstrSound1;
	m_hstrSound2		= pSS->hstrSound2;
	m_hstrSound3		= pSS->hstrSound3;

	m_hstrTexture		= pSS->hstrTexture;
	m_pTextureName		= "SpriteTextures\\drop32_1.dtx";
	return DTRUE;
}
Пример #3
0
LTBOOL CSmokeFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CBaseParticleSystemFX::Init(psfxCreateStruct)) return LTFALSE;

	m_pTextureName	= "SpecialFX\\ParticleTextures\\smoke.dtx";

	SMCREATESTRUCT* pSM = (SMCREATESTRUCT*)psfxCreateStruct;

	VEC_COPY(m_vPos, pSM->vPos);
	VEC_COPY(m_vColor1, pSM->vColor1);
	VEC_COPY(m_vColor2, pSM->vColor1);
	VEC_COPY(m_vMinDriftVel, pSM->vMinDriftVel);
	VEC_COPY(m_vMaxDriftVel, pSM->vMaxDriftVel);
	m_fVolumeRadius			= pSM->fVolumeRadius;
	m_fLifeTime				= pSM->fLifeTime;
	m_fRadius				= pSM->fRadius;
	m_fParticleCreateDelta	= pSM->fParticleCreateDelta;
	m_fMinParticleLife		= pSM->fMinParticleLife;
	m_fMaxParticleLife		= pSM->fMaxParticleLife;
	m_nNumParticles			= pSM->nNumParticles;
	m_bIgnoreWind			= pSM->bIgnoreWind;
	m_hstrTexture			= pSM->hstrTexture;

	m_fGravity		= 0.0f;

	return LTTRUE;
}
Пример #4
0
DBOOL CSmokePuffFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CBaseParticleSystemFX::Init(psfxCreateStruct)) return DFALSE;

	m_pTextureName	= "SpriteTextures\\Particles\\ParticleSmoke2.dtx";

	SMPCREATESTRUCT* pSM = (SMPCREATESTRUCT*)psfxCreateStruct;

	VEC_COPY(m_vColor1, pSM->vColor1);
	VEC_COPY(m_vColor2, pSM->vColor2);
	VEC_COPY(m_vMinDriftVel, pSM->vMinDriftVel);
	VEC_COPY(m_vMaxDriftVel, pSM->vMaxDriftVel);
	m_fDriftDeceleration	= pSM->fDriftDeceleration;
	VEC_COPY(m_vPos, pSM->vPos);
	m_fVolumeRadius			= pSM->fVolumeRadius;
	m_fLifeTime				= pSM->fLifeTime;
	m_fRadius				= pSM->fRadius;
	m_fParticleCreateDelta	= pSM->fParticleCreateDelta;
	m_fMinParticleLife		= pSM->fMinParticleLife;
	m_fMaxParticleLife		= pSM->fMaxParticleLife;
	m_fMaxAlpha				= pSM->fMaxAlpha;
	m_fCreateLifetime		= pSM->fCreateLifetime;
	m_nNumParticles			= pSM->nNumParticles;
	m_bIgnoreWind			= pSM->bIgnoreWind;
	m_pTextureName			= pSM->pTexture;

	m_fFadeTime				= m_fLifeTime*0.6f;
	m_fCreateLifetime = m_fLifeTime * m_fCreateLifetime;

	m_fGravity		= 0.0f;

	return DTRUE;
}
Пример #5
0
LTBOOL ScaleSprite::Update()
{
	if (m_bStartOn)
	{
		g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, USRFLG_VISIBLE, USRFLG_VISIBLE);

		g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
	}

	SetNextUpdate(UPDATE_NEVER);
 
	// BUG - This isn't quite right.  Sometimes this works (flipping the sprite)
	// other times the sprite shouldn't be flipped...Not sure what the bug is.
	// For some reason the sprites are sometimes backwards...Get the rotation
	// so we can flip it...

    LTRotation rRot;
    LTVector vPos, vDir, vU, vR, vF;
	g_pLTServer->GetObjectPos(m_hObject, &vPos);
	g_pLTServer->GetObjectRotation(m_hObject, &rRot);
	vU = rRot.Up();
	vR = rRot.Right();
	vF = rRot.Forward();

	if (m_bFlushWithWorld)
	{
		// Align the sprite to the surface directly behind the sprite
		// (i.e., opposite the forward vector)...

		VEC_NORM(vF);
		VEC_MULSCALAR(vDir, vF, -1.0f);


		// Determine where on the surface to place the sprite...

		IntersectInfo iInfo;
		IntersectQuery qInfo;

		VEC_COPY(qInfo.m_From, vPos);
		VEC_COPY(qInfo.m_Direction, vDir);
		qInfo.m_Flags	 = IGNORE_NONSOLID | INTERSECT_OBJECTS | INTERSECT_HPOLY;
        qInfo.m_FilterFn = LTNULL;

        if (g_pLTServer->CastRay(&qInfo, &iInfo))
		{
            LTVector vTemp;
			VEC_COPY(vPos, iInfo.m_Point);
			VEC_COPY(vDir, iInfo.m_Plane.m_Normal);

			// Place the sprite just above the surface...

			VEC_MULSCALAR(vTemp, vDir, 1.0f);
			VEC_ADD(vPos, vPos, vTemp);

			g_pLTServer->SetObjectPos(m_hObject, &vPos);
		}
	}

    return LTTRUE;
}
Пример #6
0
void CMovement::ConsolidatePath()
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return;

	IntersectQuery IQuery;
	IntersectInfo IInfo;

	IQuery.m_Flags	  = INTERSECT_OBJECTS | IGNORE_NONSOLID;
	IQuery.m_FilterFn = DNULL;

	//check first from our pos to second path point

	DLink* pLink1 = m_PathList.m_Head.m_pNext;

	// add a little sanity checking (gk 9/2)
	if (pLink1->m_pData && pLink1->m_pNext->m_pData)
	{

		VEC_COPY(IQuery.m_From, m_vPos);
		VEC_COPY(IQuery.m_To, *((DVector*)pLink1->m_pNext->m_pData));

		if(!pServerDE->IntersectSegment(&IQuery, &IInfo))
		{
			dl_RemoveAt(&m_PathList,pLink1);
			delete pLink1;
		}
	}

	//loop through pathpoint and pathpoint + 2
	pLink1 = m_PathList.m_Head.m_pNext;

	if (pLink1->m_pData && pLink1->m_pNext->m_pData)
	{
		DLink* pLink2 = pLink1->m_pNext->m_pNext;
		
		while(pLink1->m_pData && pLink2->m_pData)
		{
			VEC_COPY(IQuery.m_From, *((DVector*)pLink1->m_pData));
			VEC_COPY(IQuery.m_To, *((DVector*)pLink2->m_pData));

			if(!pServerDE->IntersectSegment(&IQuery, &IInfo))
			{
				DLink *pObLink = pLink1->m_pNext;
				dl_RemoveAt(&m_PathList,pObLink);
				delete pObLink;
				pLink2 = pLink2->m_pNext;
			}
			else
			{
				pLink1 = pLink1->m_pNext;
				pLink2 = pLink2->m_pNext;
			}
		}
	}

	return;
}
Пример #7
0
LTBOOL CScanner::CanSeeObject(ObjectFilterFn ofn, HOBJECT hObject)
{
	_ASSERT(hObject);
    if (!hObject) return LTFALSE;

	if (g_pGameServerShell->GetGameType() == COOPERATIVE_ASSAULT && m_nPlayerTeamFilter && IsPlayer(hObject))
	{
		CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObject);
		if (pPlayer->GetTeamID() != m_nPlayerTeamFilter)
			return LTFALSE;
	}


    LTVector vPos;
    g_pLTServer->GetObjectPos(hObject, &vPos);

    LTVector vDir;
	vDir = vPos - GetScanPosition();

	if (VEC_MAGSQR(vDir) >= m_fVisualRange)
	{
        return LTFALSE;
	}

	vDir.Norm();

    LTRotation rRot = GetScanRotation();

    LTVector vUp, vRight, vForward;
    g_pLTServer->GetRotationVectors(&rRot, &vUp, &vRight, &vForward);

    LTFLOAT fDp = vDir.Dot(vForward);

	if (fDp < m_fFOV)
	{
        return LTFALSE;
	}

	// See if we can see the position in question

	IntersectQuery IQuery;
	IntersectInfo IInfo;

	VEC_COPY(IQuery.m_From, GetScanPosition());
	VEC_COPY(IQuery.m_To, vPos);
	IQuery.m_Flags	  = INTERSECT_OBJECTS | IGNORE_NONSOLID;
	IQuery.m_FilterFn = ofn;

    if (g_pLTServer->IntersectSegment(&IQuery, &IInfo))
	{
		if (IInfo.m_hObject == hObject)
		{
            return LTTRUE;
		}
	}

    return LTFALSE;
}
Пример #8
0
DBOOL ParticleSystem::ReadProp(ObjectCreateStruct *)
{
	CServerDE* pServerDE = GetServerDE();
	if (!pServerDE) return DFALSE;

	GenericProp genProp;

	if (g_pServerDE->GetPropGeneric("Static", &genProp) == DE_OK)
		m_bStatic = genProp.m_Bool;

	if (g_pServerDE->GetPropGeneric("ParticleFlags", &genProp) == DE_OK)
		m_dwFlags = genProp.m_Long;

	if (g_pServerDE->GetPropGeneric("BurstWait", &genProp) == DE_OK)
		m_fBurstWait = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("ParticlesPerSecond", &genProp) == DE_OK)
		m_fParticlesPerSecond = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("EmissionRadius", &genProp) == DE_OK)
		m_fEmissionRadius = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("MinimumVelocity", &genProp) == DE_OK)
		m_fMinimumVelocity = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("MaximumVelocity", &genProp) == DE_OK)
		m_fMaximumVelocity = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("VelocityOffset", &genProp) == DE_OK)
		m_fVelocityOffset = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("ParticleLifetime", &genProp) == DE_OK)
		m_fParticleLifetime = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("Color1", &genProp) == DE_OK)
		VEC_COPY(m_vColor1, genProp.m_Color);

	if (g_pServerDE->GetPropGeneric("Color2", &genProp) == DE_OK)
		VEC_COPY(m_vColor2, genProp.m_Color);

	if (g_pServerDE->GetPropGeneric("ParticleRadius", &genProp) == DE_OK)
		m_fRadius = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("Gravity", &genProp) == DE_OK)
		m_fGravity = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("RotationVelocity", &genProp) == DE_OK)
		m_fRotationVelocity = genProp.m_Float;

	if (g_pServerDE->GetPropGeneric("TextureName", &genProp) == DE_OK)
	{
		if (genProp.m_String[0]) m_hstrTextureName = pServerDE->CreateString(genProp.m_String);
	}

	return DTRUE;
}
int dCollideRTL(dxGeom* g1, dxGeom* RayGeom, int Flags, dContactGeom* Contacts, int Stride)
{
	dxTriMesh* TriMesh = (dxTriMesh*)g1;

    dReal Length = dGeomRayGetLength(RayGeom);
	int FirstContact, BackfaceCull;
	dGeomRayGetParams(RayGeom, &FirstContact, &BackfaceCull);
	int ClosestHit = dGeomRayGetClosestHit(RayGeom);
	dVector3 Origin, Direction;
	dGeomRayGet(RayGeom, Origin, Direction);

    char intersect=0;
    GIM_TRIANGLE_RAY_CONTACT_DATA contact_data;

	if(ClosestHit)
	{
		intersect = gim_trimesh_ray_closest_collision(&TriMesh->m_collision_trimesh,Origin,Direction,Length,&contact_data);
	}
	else
	{
	    intersect = gim_trimesh_ray_collision(&TriMesh->m_collision_trimesh,Origin,Direction,Length,&contact_data);
	}

    if(intersect == 0)
	{
        return 0;
    }

	int OutTriCount = 0;

	if(TriMesh->RayCallback)
	{
        if(TriMesh->RayCallback(TriMesh, RayGeom, contact_data.m_face_id,
                                         contact_data.u , contact_data.v))
        {
            OutTriCount = 1;
        }
	}
	else
	{
	    OutTriCount = 1;
	}

	if(OutTriCount>0)
	{
	    dContactGeom* Contact = SAFECONTACT(Flags, Contacts, (OutTriCount-1), Stride);
        VEC_COPY(Contact->pos,contact_data.m_point);
        VEC_COPY(Contact->normal,contact_data.m_normal);
        Contact->depth = contact_data.tparam;
        Contact->g1 = TriMesh;
        Contact->g2 = RayGeom;
	}

	return OutTriCount;
}
Пример #10
0
DBOOL CBaseParticleSystemFX::CreateObject(CClientDE *pClientDE)
{
	if (!CSpecialFX::CreateObject(pClientDE)) return DFALSE;

	DVector vPos;
	DRotation rRot;
	ROT_INIT(rRot);

	// Use server object position if a position wasn't specified...

	if (m_vPos.x == 0.0f && m_vPos.y == 0.0f && m_vPos.z == 0.0f)
	{
		if (m_hServerObject)
		{
			pClientDE->GetObjectPos(m_hServerObject, &vPos);
		}
	}
	else
	{
		VEC_COPY(vPos, m_vPos);
	}

	// Use the specified rotation if applicable

	if (m_rRot.m_Vec.x != 0.0f || m_rRot.m_Vec.y != 0.0f || 
		m_rRot.m_Vec.z != 0.0f || m_rRot.m_Spin != 1.0f)
	{
		ROT_COPY(rRot, m_rRot);
	}

	// Setup the ParticleSystem...

	ObjectCreateStruct createStruct;
	INIT_OBJECTCREATESTRUCT(createStruct);

	createStruct.m_ObjectType = OT_PARTICLESYSTEM;
	createStruct.m_Flags = FLAG_VISIBLE | FLAG_UPDATEUNSEEN;
	VEC_COPY(createStruct.m_Pos, vPos);
	ROT_COPY(createStruct.m_Rotation, rRot);

	m_hObject = m_pClientDE->CreateObject(&createStruct);
	m_pClientDE->SetupParticleSystem(m_hObject, m_pTextureName, 
									 m_fGravity, m_dwFlags, m_fRadius / 640.0f);

	VEC_SET(m_vColorRange, m_vColor2.x - m_vColor1.x, 
						   m_vColor2.y - m_vColor1.y,
						   m_vColor2.z - m_vColor1.z);

	if (m_vColorRange.x < 0.0f) m_vColorRange.x = 0.0f;
	if (m_vColorRange.y < 0.0f) m_vColorRange.y = 0.0f;
	if (m_vColorRange.z < 0.0f) m_vColorRange.z = 0.0f;

	return DTRUE;
}
Пример #11
0
LTBOOL CParticleTrailFX::Update()
{
	CSFXMgr* psfxMgr = g_pRiotClientShell->GetSFXMgr();
	if (!psfxMgr || !m_pClientDE || !m_hServerObject) return LTFALSE;

	LTFLOAT fTime = m_pClientDE->GetTime();

	// Check to see if we should go away...

	if (m_bWantRemove)
	{
		return LTFALSE;
	}


	// See if it is time to create a new trail segment...

	if ((m_fStartTime < 0) || (fTime > m_fStartTime + m_fSegmentTime))
	{
		PTSCREATESTRUCT pts;

		pts.hServerObj = m_hServerObject;
		VEC_COPY(pts.vColor1, m_vColor1);
		VEC_COPY(pts.vColor2, m_vColor2);
		VEC_COPY(pts.vDriftOffset, m_vDriftOffset);
		pts.nType			= m_nType;
		pts.bSmall			= m_bSmall;
		pts.fLifeTime		= m_fLifeTime;
		pts.fFadeTime		= m_fFadeTime;
		pts.fOffsetTime		= m_fOffsetTime;
		pts.fRadius			= 2000.0f;
		pts.fGravity		= 0.0f;
		pts.nNumPerPuff		= m_nNumPerPuff;

		if (m_nType & PT_BLOOD)
		{
			pts.fRadius	 = 600.0f;
		}
		else if (m_nType & PT_GIBSMOKE)
		{
			pts.fRadius	 = 1250.0f;
		}

		CSpecialFX* pFX = psfxMgr->CreateSFX(SFX_PARTICLETRAILSEG_ID, &pts);

		// Let each Particle segment do its initial update...

		if (pFX) pFX->Update();

		m_fStartTime = fTime;
	}

	return LTTRUE;
}
Пример #12
0
DVector CMovement::FindTurn(DVector vStart, DVector vTestDir, DVector vMoveDir, DFLOAT fMoveLen, 
							DFLOAT fTestLen)
{
	DVector vFinal,vCurPos;
	DBOOL	bStop = DTRUE;
	DFLOAT fMaxDist = 0.0f;

	VEC_INIT(vFinal);
	VEC_COPY(vCurPos, vStart);

	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return vFinal;

	IntersectQuery IQuery;
	IntersectInfo IInfo;

	IQuery.m_Flags	  = INTERSECT_OBJECTS | IGNORE_NONSOLID;
	IQuery.m_FilterFn = DNULL;

	VEC_COPY(IQuery.m_From,vStart);
	VEC_COPY(IQuery.m_Direction,vMoveDir);

	//find maximum searchable distance in vMoveDir
	if(pServerDE->CastRay(&IQuery,&IInfo))
	{
		fMaxDist = VEC_DIST(vStart,IInfo.m_Point);
	}

	//loop til we find a spot to turn
	for(float fDist = 0.0f; !((fDist + fMoveLen) >= fMaxDist); fDist += fMoveLen)
	{
		VEC_ADDSCALED(vCurPos, vCurPos, vMoveDir, fMoveLen);

		VEC_COPY(IQuery.m_From,vCurPos);
		VEC_ADDSCALED(IQuery.m_To,vCurPos, vTestDir, fTestLen);

		if(!pServerDE->IntersectSegment(&IQuery, &IInfo))
		{
			VEC_ADDSCALED(vFinal, vCurPos, vMoveDir, fMoveLen);
			return vFinal;
		}
	}

	if(m_nNumPoints >= 10 || (VEC_DIST(vCurPos,vStart) <= 0.0))
		return vCurPos;

	//we can't turn here so we add to list and keep searching in new direction
	AddPosToPathList(vCurPos);

	DVector vNewMoveDir;
	VEC_MULSCALAR(vNewMoveDir, vTestDir, -1.0f);

	return FindTurn(vCurPos, vMoveDir, vNewMoveDir, fMoveLen, (fMaxDist - fDist) + 1.0f);
}
Пример #13
0
void PolyGrid::	Setup(DVector* pvDims, DVector* pvColor1, DVector* pvColor2,
					  HSTRING hstrSurfaceSprite, DFLOAT fXScaleMin, DFLOAT fXScaleMax,
					  DFLOAT fYScaleMin, DFLOAT fYScaleMax, DFLOAT fXScaleDuration,
					  DFLOAT fYScaleDuration, DFLOAT fXPan, DFLOAT fYPan,
					  DFLOAT fAlpha, DDWORD dwNumPolies)
{
	D_WORD wColor1, wColor2;

	CServerDE* pServerDE = GetServerDE();
	if (!pServerDE || !pvDims || !pvColor1 || !pvColor2 || dwNumPolies < 4) return;

	VEC_COPY(m_vDims, *pvDims);
	pServerDE->SetObjectDims(m_hObject, pvDims);
	VEC_COPY(m_vColor1, *pvColor1);
	VEC_COPY(m_vColor2, *pvColor2);

	wColor1 = Color255VectorToWord( pvColor1 );
	wColor2 = Color255VectorToWord( pvColor2 );

	// Limit the number of polies to 32k...
	if ( dwNumPolies > 0x7FFF )
		dwNumPolies = 0x7FFF;

	HSTRING hstrSprite = hstrSurfaceSprite ? hstrSurfaceSprite : pServerDE->CreateString("");

	// Tell the clients about the polygrid...
	HMESSAGEWRITE hMessage = pServerDE->StartSpecialEffectMessage(this);
	pServerDE->WriteToMessageByte(hMessage, SFX_POLYGRID_ID);
	pServerDE->WriteToMessageVector(hMessage, &m_vDims);
	pServerDE->WriteToMessageWord(hMessage, wColor1);
	pServerDE->WriteToMessageWord(hMessage, wColor2);
	pServerDE->WriteToMessageFloat(hMessage, fXScaleMin);
	pServerDE->WriteToMessageFloat(hMessage, fXScaleMax);
	pServerDE->WriteToMessageFloat(hMessage, fYScaleMin);
	pServerDE->WriteToMessageFloat(hMessage, fYScaleMax);
	pServerDE->WriteToMessageFloat(hMessage, fXScaleDuration);
	pServerDE->WriteToMessageFloat(hMessage, fYScaleDuration);
	pServerDE->WriteToMessageFloat(hMessage, fXPan);
	pServerDE->WriteToMessageFloat(hMessage, fYPan);
	pServerDE->WriteToMessageFloat(hMessage, fAlpha);
	pServerDE->WriteToMessageHString(hMessage, hstrSprite);
	pServerDE->WriteToMessageWord(hMessage, (D_WORD)dwNumPolies);
	pServerDE->WriteToMessageByte(hMessage, m_nPlasmaType);
	pServerDE->WriteToMessageByte(hMessage, m_nRingRate[0]);
	pServerDE->WriteToMessageByte(hMessage, m_nRingRate[1]);
	pServerDE->WriteToMessageByte(hMessage, m_nRingRate[2]);
	pServerDE->WriteToMessageByte(hMessage, m_nRingRate[3]);
	pServerDE->EndMessage(hMessage);

	if (!hstrSurfaceSprite)
	{
		pServerDE->FreeString(hstrSprite);
	}
}
Пример #14
0
DBOOL BounceMovingObject(PhysicsState *pUserState, MovingObject *pObject, 
						 DVector *pNewPos, ClientIntersectInfo* pInfo, SurfaceType *eType)
{

	if (!pObject || !pNewPos || !pInfo) return DFALSE;

	PhysicsState* pState = pUserState ? pUserState : GetCurPhysicsState(pObject);
	if (!pState) return DFALSE;

	ClientIntersectQuery query;
	float dot;

	// Only do an intersection test if the line is long enough (sometimes the 
	// intersection test will fail on really short lines).
	memset(&query, 0, sizeof(query));
	VEC_COPY(query.m_From, pObject->m_Pos);
	VEC_COPY(query.m_To, *pNewPos);

	if (eType)
		query.m_Flags = INTERSECT_HPOLY;

	if (pState->m_pClientDE->IntersectSegment(&query, pInfo))
	{
		// get the surface type
		if (eType)
			*eType = GetSurfaceType(pInfo->m_hObject, pInfo->m_hPoly);

		// Reflect the velocity.
		dot = VEC_DOT(pObject->m_Velocity, pInfo->m_Plane.m_Normal);
		dot *= -2.0f;

		VEC_ADDSCALED(pObject->m_Velocity, pObject->m_Velocity, pInfo->m_Plane.m_Normal, dot);

		// If the plane hit is in the opposite direction of travel, then move back a little...
		if( dot > 0.0f )
		{
			// Move the dest point a little in front of the plane.
			VEC_ADDSCALED(*pNewPos, pInfo->m_Point, pInfo->m_Plane.m_Normal, 0.3f);
		}
	
		// Dampen it.
		VEC_MULSCALAR(pObject->m_Velocity, pObject->m_Velocity, pState->m_VelocityDampen);
		
		// (250 is the max squared magnitude).
		if(pInfo->m_Plane.m_Normal.y > 0.6f && (VEC_MAGSQR(pObject->m_Velocity) < (250.0f)))
		{
			pObject->m_PhysicsFlags |= MO_RESTING;
		}

		return DTRUE;
	}

	return DFALSE;
}
Пример #15
0
void gim_trimesh_get_triangle_vertices(GIM_TRIMESH * trimesh, GUINT32 triangle_index, vec3f v1,vec3f v2,vec3f v3)
{
    vec3f * transformed_vertices = GIM_BUFFER_ARRAY_POINTER(vec3f,trimesh->m_transformed_vertex_buffer,0);

    GUINT32 * triangle_indices = GIM_BUFFER_ARRAY_POINTER(GUINT32,trimesh->m_tri_index_buffer,triangle_index*3);

    //Copy the vertices
    VEC_COPY(v1,transformed_vertices[triangle_indices[0]]);
    VEC_COPY(v2,transformed_vertices[triangle_indices[1]]);
    VEC_COPY(v3,transformed_vertices[triangle_indices[2]]);
}
Пример #16
0
DBOOL CRainFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CBaseParticleSystemFX::Init(psfxCreateStruct)) return DFALSE;

	// Set up our creation struct...

	RAINCREATESTRUCT* pPS = (RAINCREATESTRUCT*)psfxCreateStruct;
	m_cs = *pPS;

	m_bGravity = pPS->bGravity;

	m_fRadius = 200.0f * pPS->fParticleScale;

	VEC_COPY(m_vDims, pPS->vDims)
	VEC_COPY(m_vDirection, pPS->vDirection)
	m_fLifetime = pPS->fLifetime;
	m_fSpread = pPS->fSpread;
	m_fTimeLimit = pPS->fTimeLimit;
	m_fPulse = pPS->fPulse;

	m_fAreaDensity = ((m_vDims.x * m_vDims.z) / 250) * pPS->fDensity;
	
	// Set our (parent's) flags...

	m_dwFlags = m_cs.dwFlags;

//	m_pTextureName	= "spritetextures\\Particles\\particle2.dtx";
	m_pTextureName	= "spritetextures\\blooddrop2.dtx";		//SCHLEGZ 5/3/98 10:19:28 PM: a better liquid particle

	VEC_COPY(m_vColor1, pPS->vColor1);
	VEC_COPY(m_vColor2, pPS->vColor2);
/*
	if (pPS->bBloodRain)	// Blood rain is red :)
	{
		VEC_COPY(m_vColor[0], 255, 30, 30);
		VEC_SET(m_vColor[1], 255, 30, 30);
		VEC_SET(m_vColor[2], 200, 24, 24);
		VEC_SET(m_vColor[3], 150, 18, 18);
		VEC_SET(m_vColor[4], 100, 12, 12);
		VEC_SET(m_vColor[5], 50, 6, 6);
	}
	else
	{
		VEC_SET(m_vColor[0], 200, 255, 255);
		VEC_SET(m_vColor[1], 160, 200, 200);
		VEC_SET(m_vColor[2], 120, 150, 150);
		VEC_SET(m_vColor[3], 80, 100, 100);
		VEC_SET(m_vColor[4], 40, 50, 50);
		VEC_SET(m_vColor[5], 40, 50, 50);
	}
*/
	return DTRUE;
}
Пример #17
0
DBOOL CSmokeTrailFX::Update()
{
	CBloodClientShell *pShell = (CBloodClientShell*)g_pClientDE->GetClientShell();
	CSFXMgr* psfxMgr = pShell->GetSFXMgr();
	if (!psfxMgr || !m_pClientDE || !m_hServerObject) return DFALSE;

	DFLOAT fTime = m_pClientDE->GetTime();

	// Check to see if we should go away...

	if (m_bWantRemove)
	{
		return DFALSE;
	}


	// See if it is time to create a new trail segment...
	if ((m_fStartTime < 0) || (fTime > m_fStartTime + m_fSegmentTime))
	{
		STSCREATESTRUCT sts;

		sts.hServerObj = m_hServerObject;
		VEC_COPY(sts.vVel, m_vVel);
		VEC_COPY(sts.vColor1, m_vColor1);
		VEC_COPY(sts.vColor2, m_vColor2);
		sts.bSmall			= m_bSmall;
		sts.fLifeTime		= m_fLifeTime;
		sts.fFadeTime		= m_fFadeTime;
		sts.fOffsetTime		= m_fOffsetTime;
		sts.fRadius			= 1000.0f;
		sts.fGravity		= 15.0f;
		sts.nNumPerPuff		= m_nNumPerPuff;

		if(VEC_MAG(sts.vVel) < 1.0f)
		{
			sts.fGravity = 25.0f;
			sts.fOffsetTime = 0.1f;
			sts.fRadius = 500.0f;
			sts.nNumPerPuff = 1;
			sts.fLifeTime = 1.0f;
		}

 		CSpecialFX* pFX = psfxMgr->CreateSFX(SFX_SMOKETRAILSEG_ID, &sts, DFALSE, this);

		// Let each smoke segment do its initial update...
		if (pFX) pFX->Update();

		m_fStartTime = fTime;
	}

	return DTRUE;
}
Пример #18
0
DBOOL CCastLineFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CBaseLineSystemFX::Init(psfxCreateStruct)) return DFALSE;

	CLCREATESTRUCT* pCL = (CLCREATESTRUCT*)psfxCreateStruct;
	VEC_COPY(m_vStartColor, pCL->vStartColor);
	VEC_COPY(m_vEndColor, pCL->vStartColor);
	m_fStartAlpha	= pCL->fStartAlpha;
	m_fEndAlpha		= pCL->fEndAlpha;
	m_hCastTo		= pCL->hCastTo;

	return DTRUE;
}
Пример #19
0
LTBOOL CDeathFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
    if (!CSpecialFX::Init(psfxCreateStruct)) return LTFALSE;

	DEATHCREATESTRUCT* pD = (DEATHCREATESTRUCT*)psfxCreateStruct;

	m_nDeathType	= pD->nDeathType;
	m_eModelId		= pD->eModelId;
	m_eModelStyle	= pD->eModelStyle;
	VEC_COPY(m_vPos, pD->vPos);
	VEC_COPY(m_vDir, pD->vDir);

    return LTTRUE;
}
Пример #20
0
void CClientExplosionSFX::Setup(DVector *vPos, DVector *vNormal, DFLOAT fOffset)
{
	VEC_COPY(m_vPos, *vPos);
	VEC_COPY(m_vNormal, *vNormal);
	m_fOffset = fOffset;

	if(m_fOffset)
	{
		DVector	temp;
		VEC_NORM(m_vNormal);
		VEC_MULSCALAR(temp, m_vNormal, m_fOffset);
		VEC_ADD(m_vPos, m_vPos, temp);
	}
}
Пример #21
0
int dCollideRTL(dxGeom* g1, dxGeom* RayGeom, int Flags, dContactGeom* Contacts, int Stride)
{
	dIASSERT (Stride >= (int)sizeof(dContactGeom));
	dIASSERT (g1->type == dTriMeshClass);
	dIASSERT (RayGeom->type == dRayClass);
	dIASSERT ((Flags & NUMC_MASK) >= 1);
	
	dxTriMesh* TriMesh = (dxTriMesh*)g1;

    dReal Length = dGeomRayGetLength(RayGeom);
	int FirstContact, BackfaceCull;
	dGeomRayGetParams(RayGeom, &FirstContact, &BackfaceCull);
	int ClosestHit = dGeomRayGetClosestHit(RayGeom);
	dVector3 Origin, Direction;
	dGeomRayGet(RayGeom, Origin, Direction);

    char intersect=0;
    GIM_TRIANGLE_RAY_CONTACT_DATA contact_data;

	if(ClosestHit)
	{
		intersect = gim_trimesh_ray_closest_collisionODE(&TriMesh->m_collision_trimesh,Origin,Direction,Length,&contact_data);
	}
	else
	{
	    intersect = gim_trimesh_ray_collisionODE(&TriMesh->m_collision_trimesh,Origin,Direction,Length,&contact_data);
	}

    if(intersect == 0)
	{
        return 0;
    }


	if(!TriMesh->RayCallback || 
		TriMesh->RayCallback(TriMesh, RayGeom, contact_data.m_face_id, contact_data.u , contact_data.v))
	{
		dContactGeom* Contact = &( Contacts[ 0 ] );
        VEC_COPY(Contact->pos,contact_data.m_point);
        VEC_COPY(Contact->normal,contact_data.m_normal);
        Contact->depth = contact_data.tparam;
        Contact->g1 = TriMesh;
        Contact->g2 = RayGeom;
		Contact->side1 = contact_data.m_face_id;
		Contact->side2 = -1;
		return 1;
	}

	return 0;
}
Пример #22
0
void Explosion::SetupShockwave(char *pSprite, DVector vScaleMin, DVector vScaleMax,
								DFLOAT fDuration)
{	
	if (!g_pServerDE || !pSprite) return;

	if (pSprite) m_hstrShockwaveSprite = g_pServerDE->CreateString(pSprite);
	else m_hstrShockwaveSprite = g_pServerDE->CreateString(szDefShockwaveSprite);

	VEC_COPY(m_vShockwaveScaleMin, vScaleMin);
	VEC_COPY(m_vShockwaveScaleMax, vScaleMax);

	m_fShockwaveDuration	= fDuration;
	m_bCreateShockwave		= DTRUE;
}
Пример #23
0
void VolumeBrush::CreateSurface()
{
    CServerDE* pServerDE = GetServerDE();
    if (!pServerDE) return;

    ObjectCreateStruct theStruct;
    INIT_OBJECTCREATESTRUCT(theStruct);

    DVector vPos, vDims, vScale;
    VEC_INIT(vScale);

    pServerDE->GetObjectDims(m_hObject, &vDims);
    pServerDE->GetObjectPos(m_hObject, &vPos);

    DRotation rRot;
    pServerDE->GetObjectRotation(m_hObject, &rRot);

    VEC_COPY(m_vLastPos, vPos);

    vPos.y += vDims.y - (m_fSurfaceHeight/2.0f);
    VEC_COPY(theStruct.m_Pos, vPos);
    ROT_COPY(theStruct.m_Rotation, rRot);

    HCLASS hClass = pServerDE->GetClass("PolyGrid");

    PolyGrid* pSurface = DNULL;

    if (hClass)
    {
        pSurface = (PolyGrid *)pServerDE->CreateObject(hClass, &theStruct);
    }

    if (pSurface)
    {
        m_hSurfaceObj = pSurface->m_hObject;
        vDims.y		  = m_fSurfaceHeight;

        DFLOAT fXPan = 1.0f + (m_vCurrent.x * 0.01f);
        DFLOAT fYPan = 1.0f + (m_vCurrent.y * 0.01f);

        pSurface->Setup(&vDims, &m_vSurfaceColor1, &m_vSurfaceColor2,
                        m_hstrSurfaceSprite, m_fXScaleMin, m_fXScaleMax,
                        m_fYScaleMin, m_fYScaleMax, m_fXScaleDuration,
                        m_fYScaleDuration, fXPan, fYPan, m_fSurfaceAlpha,
                        m_dwNumSurfacePolies);

//		pServerDE->SetObjectColor(m_hSurfaceObj,1.0f,0,0,0.1f);
    }
}
Пример #24
0
void VolumeBrush::CreateSurface()
{
	ObjectCreateStruct theStruct;
	INIT_OBJECTCREATESTRUCT(theStruct);

    LTVector vPos, vDims, vScale;
	VEC_INIT(vScale);

    g_pLTServer->GetObjectDims(m_hObject, &vDims);
    g_pLTServer->GetObjectPos(m_hObject, &vPos);

    LTRotation rRot;
    g_pLTServer->GetObjectRotation(m_hObject, &rRot);

	VEC_COPY(m_vLastPos, vPos);

	vPos.y += vDims.y - (m_fSurfaceHeight/2.0f);
	VEC_COPY(theStruct.m_Pos, vPos);
    theStruct.m_Rotation = rRot;

    HCLASS hClass = g_pLTServer->GetClass("PolyGrid");

    PolyGrid* pSurface = LTNULL;

	if (hClass)
	{
        pSurface = (PolyGrid *)g_pLTServer->CreateObject(hClass, &theStruct);
	}

	if (pSurface)
	{
		m_hSurfaceObj = pSurface->m_hObject;
		vDims.y		  = m_fSurfaceHeight;

        LTFLOAT fXPan = 1.0f + (m_vCurrent.x * 0.01f);
        LTFLOAT fYPan = 1.0f + (m_vCurrent.y * 0.01f);

		if (!m_bHidden)
		{
            g_pLTServer->SetObjectUserFlags(m_hSurfaceObj, USRFLG_VISIBLE);
		}

		pSurface->Setup(&vDims, &m_vSurfaceColor1, &m_vSurfaceColor2,
						m_hstrSurfaceSprite, m_fXScaleMin, m_fXScaleMax,
						m_fYScaleMin, m_fYScaleMax, m_fXScaleDuration,
						m_fYScaleDuration, fXPan, fYPan, m_fSurfAlpha,
						m_dwNumSurfPolies, m_bAdditive, m_bMultiply);
	}
}
Пример #25
0
DBOOL CLaserBeamFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CSpecialFX::Init(psfxCreateStruct)) return DFALSE;

	LASERBEAMCREATESTRUCT	*pLS = (LASERBEAMCREATESTRUCT*)psfxCreateStruct;

	VEC_COPY(m_vSource, pLS->vSource);
	VEC_COPY(m_vDest, pLS->vDest);
	m_nType = pLS->nType;

	m_fStartTime = 0.0f;
	m_bFirstUpdate = 1;
	SetupBeam();
	return DTRUE;
}
void CinematicTrigger::CreateKeyFramer(ObjectCreateStruct *pStruct)
{
	if (m_hKeyFramer || !pStruct) return;

	ObjectCreateStruct theStruct;
	INIT_OBJECTCREATESTRUCT(theStruct);

	VEC_COPY(theStruct.m_Pos, pStruct->m_Pos);
    theStruct.m_Rotation = pStruct->m_Rotation;

	sprintf(theStruct.m_Name, "%s_%s%d", pStruct->m_Name, c_szKeyframerName, s_nKFId);

    HCLASS hClass = g_pLTServer->GetClass("KeyFramer");
    KeyFramer* pKeyFramer = (KeyFramer*) g_pLTServer->CreateObject(hClass, &theStruct);
	if (!pKeyFramer) return;

	pKeyFramer->ReadProps();

	m_hKeyFramer = pKeyFramer->m_hObject;
    g_pLTServer->CreateInterObjectLink(m_hObject, m_hKeyFramer);

	// Make the keyframer's ObjectName that of the camera...

	char szCamName[255];
	sprintf(szCamName, "%s_%s%d", pStruct->m_Name, c_szCameraName, s_nKFId);
	pKeyFramer->SetObjectName(szCamName);
}
/*!

\param trimesh
\param plane vec4f plane
\param contacts A vec4f array. Must be initialized (~100). Each element have the coordinate point in the first 3 elements, and vec4f[3] has the penetration depth.
*/
void gim_trimesh_plane_collision(GIM_TRIMESH * trimesh,vec4f plane, GDYNAMIC_ARRAY * contacts)
{
    contacts->m_size = 0;
    char classify;
    PLANE_CLASSIFY_BOX(plane,trimesh->m_aabbset.m_global_bound,classify);
    if(classify>1) return; // in front of plane

    //Locks mesh
    gim_trimesh_locks_work_data(trimesh);
    //Get vertices
    GUINT32 i, vertcount = trimesh->m_transformed_vertex_buffer.m_element_count;
    vec3f * vertices = GIM_BUFFER_ARRAY_POINTER(vec3f,trimesh->m_transformed_vertex_buffer,0);

    GREAL dist;
    vec4f * result_contact;

    for (i=0; i<vertcount; i++)
    {
        dist = DISTANCE_PLANE_POINT(plane,vertices[i]);
        if(dist<=0.0f)
        {
            GIM_DYNARRAY_PUSH_EMPTY(vec4f,(*contacts));
            result_contact = GIM_DYNARRAY_POINTER_LAST(vec4f,(*contacts));
            VEC_COPY((*result_contact),vertices[i]);
            (*result_contact)[3] = -dist;
        }
    }
    gim_trimesh_unlocks_work_data(trimesh);
}
Пример #28
0
DBOOL CBloodTrailFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
	if (!CSpecialFX::Init(psfxCreateStruct)) return DFALSE;

	BTCREATESTRUCT* pBT = (BTCREATESTRUCT*)psfxCreateStruct;
	VEC_COPY(m_vVel, pBT->vVel);
	VEC_COPY(m_vColor,pBT->vColor);

	m_nNumPerPuff	= 4;

	m_fLifeTime		= 0.75f;

	m_fSegmentTime  = 0.2f;

	return DTRUE;
}
Пример #29
0
HLOCALOBJ CParticleExplosionFX::CreateDebris()
{
    LTVector vScale;
    VEC_SET(vScale, 1.0f, 1.0f, 1.0f);
    VEC_MULSCALAR(vScale, vScale, GetRandom(1.0f, 5.0f));

    char* pFilename = GetDebrisModel(DBT_STONE_BIG, vScale);
    char* pSkin     = GetDebrisSkin(DBT_STONE_BIG);

    if (!pFilename) return LTNULL;

    ObjectCreateStruct createStruct;
    INIT_OBJECTCREATESTRUCT(createStruct);

    createStruct.m_ObjectType = OT_MODEL;
    SAFE_STRCPY(createStruct.m_Filename, pFilename);
    SAFE_STRCPY(createStruct.m_SkinName, pSkin);
    createStruct.m_Flags = FLAG_VISIBLE | FLAG_NOLIGHT;
    VEC_COPY(createStruct.m_Pos, m_vPos);

    HLOCALOBJ hObj = m_pClientDE->CreateObject(&createStruct);

    m_pClientDE->SetObjectScale(hObj, &vScale);

    return hObj;
}
Пример #30
0
void Trigger::CreateBoundingBox()
{
	CServerDE* pServerDE = GetServerDE();
	if (!pServerDE) return;

	ObjectCreateStruct theStruct;
	INIT_OBJECTCREATESTRUCT(theStruct);

	DVector vPos;
	pServerDE->GetObjectPos(m_hObject, &vPos);
	VEC_COPY(theStruct.m_Pos, vPos);

	SAFE_STRCPY(theStruct.m_Filename, "Models\\Props\\1x1_square.abc");
	// strcpy(theStruct.m_SkinName, "SpecialFX\\smoke.dtx");
	theStruct.m_Flags = FLAG_VISIBLE;

	HCLASS hClass = pServerDE->GetClass("Model");
	LPBASECLASS pModel = pServerDE->CreateObject(hClass, &theStruct);

	if (pModel)
	{
		m_hBoundingBox = pModel->m_hObject;

		DVector vDims;
		pServerDE->GetObjectDims(m_hObject, &vDims);

		DVector vScale;
		VEC_DIVSCALAR(vScale, vDims, 0.5f);
		pServerDE->ScaleObject(m_hBoundingBox, &vScale);
	}

	pServerDE->SetObjectColor(m_hBoundingBox, GetRandom(0.5f, 1.0f), 
							  GetRandom(0.5f, 1.0f), GetRandom(0.5f, 1.0f), 1.0f);
}