예제 #1
0
파일: terrain.cpp 프로젝트: paud/d2x-xl
CFixVector *get_dy_vec (int h)
{
    CFixVector *dyp;

    dyp = yCache + h;
    if (!ycFlags [h]) {
        CFixVector tv = mSurfaceOrient.UVec () * (h * TERRAIN_HEIGHT_SCALE);
        transformation.RotateScaled (*dyp, tv);
        ycFlags [h] = 1;
    }
    return dyp;
}
예제 #2
0
파일: cfile.cpp 프로젝트: paud/d2x-xl
void CFile::WriteMatrix (const CFixMatrix& m)
{
WriteVector (m.RVec());
WriteVector (m.UVec());
WriteVector (m.FVec());
}
예제 #3
0
파일: cfile.cpp 프로젝트: paud/d2x-xl
void CFile::ReadMatrix (CFixMatrix& m)
{
ReadVector (m.RVec());
ReadVector (m.UVec());
ReadVector (m.FVec());
}
예제 #4
0
void CParticle::Setup (float fBrightness, char nFrame, char nRotFrame, tParticleVertex* pb, int nThread)
{
    CFloatVector3	vCenter, uVec, rVec;
    float				fScale;

    vCenter.Assign (m_vPos);

    if ((m_nType <= SMOKE_PARTICLES) && m_bBlowUp) {
#if DBG
        if (m_nFadeType == 3)
            fScale = 1.0;
        else if (m_decay > 0.9f)
            fScale = (1.0f - pow (m_decay, 44.0f)) / float (pow (m_decay, 0.25f));
        else
            fScale = 1.0f / float (pow (m_decay, 0.25f));
#else
        fScale = (m_nFadeType == 3)
                 ? 1.0f
                 : (m_decay > 0.9f)	// start from zero size by scaling with pow (m_decay, 44f) which is < 0.01 for m_decay == 0.9f
                 ? (1.0f - pow (m_decay, 44.0f)) / float (pow (m_decay, 0.3333333f))
                 : 1.0f / float (pow (m_decay, 0.3333333f));
#endif
    }
    else {
        fScale = m_decay;
    }

    pb [0].color =
        pb [1].color =
            pb [2].color =
                pb [3].color = m_renderColor;

    float hx = ParticleImageInfo (m_nType).xBorder;
    pb [m_nOrient].texCoord.v.u =
        pb [(m_nOrient + 3) % 4].texCoord.v.u = m_texCoord.v.u + hx;
    pb [(m_nOrient + 1) % 4].texCoord.v.u =
        pb [(m_nOrient + 2) % 4].texCoord.v.u = m_texCoord.v.u + m_deltaUV - hx;
    float hy = ParticleImageInfo (m_nType).yBorder;
    pb [m_nOrient].texCoord.v.v =
        pb [(m_nOrient + 1) % 4].texCoord.v.v = m_texCoord.v.v + hy;
    pb [(m_nOrient + 2) % 4].texCoord.v.v =
        pb [(m_nOrient + 3) % 4].texCoord.v.v = m_texCoord.v.v + m_deltaUV - hy;

    if ((m_nType == BUBBLE_PARTICLES) && gameOpts->render.particles.bWiggleBubbles)
        vCenter [X] += (float) sin (nFrame / 4.0f * Pi) / (10 + rand () % 6);
    if (m_bRotate && gameOpts->render.particles.bRotate) {
        int i = (m_nOrient & 1) ? 63 - m_nRotFrame : m_nRotFrame;
        CFixMatrix mOrient = gameData.objs.viewerP->info.position.mOrient * mRot [i];
        uVec.Assign (mOrient.UVec ());
        rVec.Assign (mOrient.RVec ());
    }
    else {
        uVec.Assign (gameData.objs.viewerP->info.position.mOrient.UVec ());
        rVec.Assign (gameData.objs.viewerP->info.position.mOrient.RVec ());
    }
    uVec *= m_nHeight * fScale;
    rVec *= m_nWidth * fScale;
    pb [0].vertex = vCenter - rVec - uVec;
    pb [1].vertex = vCenter - rVec + uVec;
    pb [2].vertex = vCenter + rVec + uVec;
    pb [3].vertex = vCenter + rVec - uVec;
}
예제 #5
0
int FireWeaponDelayedWithSpread (
	CObject *objP,
	ubyte nLaserType,
	int nGun,
	fix xSpreadR,
	fix xSpreadU,
	fix xDelay,
	int bMakeSound,
	int bHarmless,
	short	nLightObj)
{
	short					nLaserSeg;
	int					nFate;
	CFixVector			vLaserPos, vLaserDir, *vGunPoints;
	CHitQuery			fq;
	CHitData				hitData;
	int					nObject;
	CObject*				laserP;
#if FULL_COCKPIT_OFFS
	int bLaserOffs = ((gameStates.render.cockpit.nType == CM_FULL_COCKPIT) &&
							(objP->Index () == LOCALPLAYER.nObject));
#else
	int bLaserOffs = 0;
#endif
	CFixMatrix				m;
	int						bSpectate = SPECTATOR (objP);
	tObjTransformation*	posP = bSpectate ? &gameStates.app.playerPos : &objP->info.position;

#if DBG
if (nLaserType == SMARTMINE_BLOB_ID)
	nLaserType = nLaserType;
#endif
CreateAwarenessEvent (objP, PA_WEAPON_WALL_COLLISION);
// Find the initial vPosition of the laser
if (!(vGunPoints = GetGunPoints (objP, nGun)))
	return 0;
TransformGunPoint (objP, vGunPoints, nGun, xDelay, nLaserType, &vLaserPos, &m);

//--------------- Find vLaserPos and nLaserSeg ------------------
fq.p0					= &posP->vPos;
fq.startSeg			= bSpectate ? gameStates.app.nPlayerSegment : objP->info.nSegment;
fq.p1					= &vLaserPos;
fq.radP0				=
fq.radP1				= 0x10;
fq.thisObjNum		= objP->Index ();
fq.ignoreObjList	= NULL;
fq.flags				= FQ_CHECK_OBJS | FQ_IGNORE_POWERUPS;
fq.bCheckVisibility = false;
nFate = FindHitpoint (&fq, &hitData);
nLaserSeg = hitData.hit.nSegment;
if (nLaserSeg == -1) {	//some sort of annoying error
	return -1;
	}
//SORT OF HACK... IF ABOVE WAS CORRECT THIS WOULDNT BE NECESSARY.
if (CFixVector::Dist (vLaserPos, posP->vPos) > 3 * objP->info.xSize / 2) {
	return -1;
	}
if (nFate == HIT_WALL) {
	return -1;
	}
#if 0
//as of 12/6/94, we don't care if the laser is stuck in an object. We
//just fire away normally
if (nFate == HIT_OBJECT) {
	if (OBJECTS [hitData.hitObject].nType == OBJ_ROBOT)
		OBJECTS [hitData.hitObject].Die ();
	if (OBJECTS [hitData.hitObject].nType != OBJ_POWERUP)
		return;
	}
#endif
//	Now, make laser spread out.
vLaserDir = m.FVec ();
if (xSpreadR || xSpreadU) {
	vLaserDir += m.RVec () * xSpreadR;
	vLaserDir += m.UVec () * xSpreadU;
	}
if (bLaserOffs)
	vLaserDir += m.UVec () * LASER_OFFS;
nObject = CreateNewWeapon (&vLaserDir, &vLaserPos, nLaserSeg, objP->Index (), nLaserType, bMakeSound);
//	Omega cannon is a hack, not surprisingly.  Don't want to do the rest of this stuff.
if (nLaserType == OMEGA_ID)
	return -1;
if (nObject == -1)
	return -1;
//TrackWeaponObject (nObject, int (objP->info.nId));
laserP = OBJECTS + nObject;
if ((nLaserType == GUIDEDMSL_ID) && gameData.multigame.bIsGuided)
	gameData.objs.guidedMissile [objP->info.nId].objP = laserP;
gameData.multigame.bIsGuided = 0;
if (gameData.objs.bIsMissile [nLaserType] && (nLaserType != GUIDEDMSL_ID)) {
	if (!gameData.objs.missileViewerP && (objP->info.nId == gameData.multiplayer.nLocalPlayer))
		gameData.objs.missileViewerP = laserP;
	}
//	If this weapon is supposed to be silent, set that bit!
if (!bMakeSound)
	laserP->info.nFlags |= OF_SILENT;
//	If this weapon is supposed to be silent, set that bit!
if (bHarmless)
	laserP->info.nFlags |= OF_HARMLESS;

//	If the object firing the laser is the CPlayerData, then indicate the laser object so robots can dodge.
//	New by MK on 6/8/95, don't let robots evade proximity bombs, thereby decreasing uselessness of bombs.
if ((objP == gameData.objs.consoleP) && !WeaponIsPlayerMine (laserP->info.nId))
	gameStates.app.bPlayerFiredLaserThisFrame = nObject;

if (gameStates.app.cheats.bHomingWeapons || gameData.weapons.info [nLaserType].homingFlag) {
	if (objP == gameData.objs.consoleP) {
		laserP->cType.laserInfo.nHomingTarget = FindHomingObject (&vLaserPos, laserP);
		gameData.multigame.laser.nTrack = laserP->cType.laserInfo.nHomingTarget;
		}
	else {// Some other CPlayerData shot the homing thing
		Assert (IsMultiGame);
		laserP->cType.laserInfo.nHomingTarget = gameData.multigame.laser.nTrack;
		}
	}
lightClusterManager.Add (nObject, nLightObj);
return nObject;
}