Beispiel #1
0
char weapon_molotov_init(){
	int i;
	InfMolotov* m;
	for(i=0; i<NUMBER_OF_MOLOTOVS; i++) {
		m = &molotovs[i];
		m->active=GE_FALSE;
		m->molotov=0;
		//m->position
		geVec3d_Clear(&(m->position));
		geVec3d_Clear(&(m->velocity));
		geXForm3d_SetIdentity(&(m->xform));
	}
	molotovCurrentWorld = 0;
	molotovActor = LoadActorDef(".\\actors\\molotov.act");
	if(! molotovActor ) {
		error("Failed to load molotov actor");
		printLog("Failed to load molotov actor\n");
		return 0;
	}
	molotovIndex = 0;
	return 1;
}
Beispiel #2
0
void kill_all_molotovs(){
	int i;
	InfMolotov* m;
	for(i=0; i<NUMBER_OF_MOLOTOVS; i++) {
		m = &molotovs[i];
		m->active=GE_FALSE;
		
		if( m->molotov ){
			if(! molotovCurrentWorld ){
				error("No previous world present when clearing molotovs");
			}
			KillActor(molotovCurrentWorld, &(m->molotov));
			m->molotov = 0;
		}

		geVec3d_Clear(&(m->position));
		geVec3d_Clear(&(m->velocity));
		geXForm3d_SetIdentity(&(m->xform));
	}
	molotovCurrentWorld = 0;
	molotovIndex = 0;
}
Beispiel #3
0
void weapon_mini_rocket_proccess(float timePassed){
#define		COLLISION		geWorld_Collision(mini_rocketCurrentWorld,&(g->box.Min),&(g->box.Max),&(g->position),&newPos,GE_CONTENTS_SOLID_CLIP,GE_COLLIDE_ALL,0xffffffff, cb_move, 0, &lCol)
	int i;
	InfMiniRocket* g;
	geVec3d newPos;
	geVec3d to;
	geVec3d angles;
	GE_Collision lCol;

	for( i=0; i<NUMBER_OF_MINIROCKETS; i++){
		g = & miniRockets[i];
		if( g->active ){
			geVec3d_AddScaled(&(g->position), &(g->velocity), timePassed, &(newPos) );

			if( COLLISION ) {
				g->position = lCol.Impact;
				//geVec3d_Scale(&(g->velocity), -0.8f, &(g->velocity) );
				weapon_mini_rocket_destroy(g);
			}
			else {
				g->position = newPos;
			}

			geVec3d_Add(&(g->position), &(g->velocity), &to);
			LookAt(g->position, to, &angles);
			
			angles.X += GE_PI/2;

			// update xform variable
			geXForm3d_SetIdentity(&(g->xform));
			geXForm3d_RotateX(&(g->xform), angles.X);
			geXForm3d_RotateY(&(g->xform), angles.Y);
			geXForm3d_RotateZ(&(g->xform), angles.Z);
			g->xform.Translation = g->position;
			geActor_ClearPose(g->mini_rocket, &(g->xform) );
		}
	}
#undef COLLISION
}
Beispiel #4
0
char weapon_mini_rocket_init(){
	int i;
	InfMiniRocket* g;
	for(i=0; i<NUMBER_OF_MINIROCKETS; i++) {
		g = &miniRockets[i];
		g->active=GE_FALSE;
		g->mini_rocket=0;
		//g->position
		geVec3d_Clear(&(g->position));
		geVec3d_Clear(&(g->velocity));
		geXForm3d_SetIdentity(&(g->xform));
	}
	mini_rocketCurrentWorld = 0;
	mini_rocketActor = LoadActorDef(".\\actors\\mini_rocket.act");
	if(! mini_rocketActor ) {
		error("Failed to load mini_rocket actor");
		printLog("Failed to load mini_rocket actor\n");
		return 0;
	}
	mini_rocketIndex = 0;
	return 1;
}
Beispiel #5
0
void kill_all_miniRockets(){
	int i;
	InfMiniRocket* g;
	for(i=0; i<NUMBER_OF_MINIROCKETS; i++) {
		g = &miniRockets[i];
		g->active=GE_FALSE;
		
		if( g->mini_rocket ){
			if(! mini_rocketCurrentWorld ){
				error("No previous world present when clearing miniRockets");
			}
			KillActor(mini_rocketCurrentWorld, &(g->mini_rocket));
			g->mini_rocket = 0;
		}

		geVec3d_Clear(&(g->position));
		geVec3d_Clear(&(g->velocity));
		geXForm3d_SetIdentity(&(g->xform));
	}
	mini_rocketCurrentWorld = 0;
	mini_rocketIndex = 0;
}
Beispiel #6
0
void weapon_molotov_proccess(float timePassed){
#define		COLLISION		geWorld_Collision(molotovCurrentWorld,&(m->box.Min),&(m->box.Max),&(m->position),&newPos,GE_CONTENTS_SOLID_CLIP,GE_COLLIDE_ALL,0xffffffff, cb_move, 0, &lCol)
	int i;
	InfMolotov* m;
	geVec3d newPos;
	GE_Collision lCol;

	for( i=0; i<NUMBER_OF_MOLOTOVS; i++){
		m = & molotovs[i];
		if( m->active ){
			m->velocity.Y -= GRAVITY *timePassed;
			geVec3d_AddScaled(&(m->position), &(m->velocity), timePassed, &(newPos) );

			if( COLLISION ) {
				m->position = lCol.Impact;
				weapon_molotov_destroy(m);
				//geVec3d_Scale(&(m->velocity), -0.8f, &(m->velocity) );
				//geVec3d_Reflect(&(m->velocity), &(lCol.Plane.Normal), &(m->velocity), 0.60f);
			}
			else {
				m->position = newPos;
			}

			/*
			if( m->timeLeftToBang <= 0.0f ){
				weapon_molotov_destroy(m);
				return;
			}*/

			// update xform variable
			geXForm3d_SetIdentity(&(m->xform));
			m->xform.Translation = m->position;
			geActor_ClearPose(m->molotov, &(m->xform) );
		}
	}
#undef COLLISION
}
/* ------------------------------------------------------------------------------------ */
void CCameraManager::Defaults()
{
	memset(&Translation, 0, sizeof(geVec3d));
	memset(&Rotation, 0, sizeof(geVec3d));

	bBindToActor	= false;
	theActor		= NULL;
	szActorBone[0]	= 0;
	memset(&CameraOffsetTranslation, 0, sizeof(geVec3d));
	memset(&CameraOffsetRotation, 0, sizeof(geVec3d));
	bUseExtBox		= false;
	theModel		= NULL;
	bBindToModel	= NULL;
	FarClipPlaneDistance = 0.0f;
	ClipEnable		= false;
	TrackingFlags	= kCameraTrackPosition;
// eaa3 12/18/2000 head bob setup
	m_HeadBobOffset	= 0.0f;					// No offset
	m_HeadBob		= false;				// Default to no bobbing
// eaa3 12/18/2000 end
	zooming			= false;
	zoommode		= false;
	shake			= false;
	shakex = shakey = shakemin = 0.0f;
// changed RF063
	jerkamt			= 0.0f;
	jerk			= false;
// end change RF063
// changed RF064
	DesiredHeight	= 0.0f;
	HeightSpeed		= 40.0f;
	OverlayDist		= 10.0f;

	geXForm3d_SetIdentity(&m_OldXForm);
	geVec3d_Clear(&m_vMoveDif);
	m_bViewChanged = m_bPositionMoved = false;
// end change RF064

	CIniFile AttrFile("camera.ini");
	if(!AttrFile.ReadFile())
	{
		CCD->ReportError("[ERROR] Failed to open camera.ini file", false);
		exit(-1);
	}

	std::string KeyName = AttrFile.FindFirstKey();
	std::string Type;

	while(KeyName != "")
	{
		if(KeyName == "General")
		{
			FOV = (float)AttrFile.GetValueF(KeyName, "fieldofview");

			if(FOV == 0.0f)
				FOV = DEFAULTFOV;

			m_LookUp = (float)AttrFile.GetValueF(KeyName, "lookupangle") * GE_PIOVER180;

			if(m_LookUp == 0.0f)
				m_LookUp = 1.0f;

			m_LookDwn = (float)AttrFile.GetValueF(KeyName, "lookdownangle") * GE_PIOVER180;

			if(m_LookDwn == 0.0f)
				m_LookDwn = 1.0f;

			switchallowed = false;
			Type = AttrFile.GetValue(KeyName, "viewswitchallowed");

			if(Type == "true")
				switchallowed = true;

			switch1st = false;
			Type = AttrFile.GetValue(KeyName, "switchto1stpersonallowed");

			if(Type == "true")
				switch1st = true;

			switch3rd = false;
			Type = AttrFile.GetValue(KeyName, "switchto3rdpersonallowed");

			if(Type == "true")
				switch3rd = true;

			switchiso = false;
			Type = AttrFile.GetValue(KeyName, "switchtoisopersonallowed");

			if(Type == "true")
				switchiso = true;

// changed RF064
			HeightSpeed = (float)AttrFile.GetValueF(KeyName, "heightspeed");

			if(HeightSpeed == 0.0f)
				HeightSpeed = 40.0f;

			OverlayDist = (float)AttrFile.GetValueF(KeyName, "overlaydistance");

			if(OverlayDist == 0.0f)
				OverlayDist = 10.0f;
// end change RF064
		}
		else if(KeyName == "FirstPerson")
		{
			Type = AttrFile.GetValue(KeyName, "height");

			if(Type == "auto" || Type == "")
			{
				viewheight = -1.0f;
			}
			else
			{
				viewheight = (float)AttrFile.GetValueF(KeyName, "height");
			}

			allowmouse1st = true;
			Type = AttrFile.GetValue(KeyName, "disablemouse");

			if(Type == "true")
				allowmouse1st = false;
		}
		else if(KeyName == "ThirdPerson")
		{
			Type = AttrFile.GetValue(KeyName, "height");

			if(Type == "auto" || Type == "")
			{
				playerheight = -1.0f;
			}
			else
			{
				playerheight = (float)AttrFile.GetValueF(KeyName, "height");
			}

			playerangleup = (float)AttrFile.GetValueF(KeyName, "angleup") * GE_PIOVER180;
			playerdistance = (float)AttrFile.GetValueF(KeyName, "distance");
			playerzoom = false;
			Type = AttrFile.GetValue(KeyName, "allowzoom");

			if(Type == "true")
			{
				playerzoom = true;
				playermindistance = (float)AttrFile.GetValueF(KeyName, "minimumdistance");
				playermaxdistance = (float)AttrFile.GetValueF(KeyName, "maximumdistance");
			}

			playermouserotation = true;
			Type = AttrFile.GetValue(KeyName, "mouserotation");

			if(Type == "false")
			{
				playermouserotation = false;
				playerallowlook = false;
				Type = AttrFile.GetValue(KeyName, "allowlook");

				if(Type == "true")
					playerallowlook = true;
			}

			allowmouse3rd = true;
			Type = AttrFile.GetValue(KeyName, "disablemouse");

			if(Type == "true")
				allowmouse3rd = false;

			allowtilt3rd = true;
			Type = AttrFile.GetValue(KeyName, "disabletilt");

			if(Type == "true")
				allowtilt3rd = false;
		}
		else if(KeyName == "Isometric")
		{
			Type = AttrFile.GetValue(KeyName, "height");
			if(Type == "auto" || Type == "")
			{
				isoheight = -1.0f;
			}
			else
			{
				isoheight = (float)AttrFile.GetValueF(KeyName, "height");
			}

			isoangleup = (float)AttrFile.GetValueF(KeyName, "angleup") * GE_PIOVER180;
			isoanglearound = (float)AttrFile.GetValueF(KeyName, "anglearound") * GE_PIOVER180;
			isodistance = (float)AttrFile.GetValueF(KeyName, "distance");
			IsoCollFlag = false;
			Type = AttrFile.GetValue(KeyName, "collisiondetection");

			if(Type == "true")
				IsoCollFlag = true;

			allowmouseiso = true;
			Type = AttrFile.GetValue(KeyName, "disablemouse");

			if(Type == "true")
				allowmouseiso = false;
		}
		else if(KeyName == "MultipleFixed")
		{
		}
		else if(KeyName == "Moving")
		{
		}

		KeyName = AttrFile.FindNextKey();
	}
}
Brush *BrushTemplate_CreateCylinder (const BrushTemplate_Cylinder *pTemplate)
{
	double		CurrentXDiameter, CurrentZDiameter;
	double		DeltaXDiameter, DeltaZDiameter;
	double		CurrentXOffset, CurrentZOffset;
	double		DeltaXOffset, DeltaZOffset, sqrcheck;
	double		EllipseZ;
	int			NumVerticalBands, HBand, VBand;
	int			VertexCount=0;
	geVec3d		*Verts, *TopPoints;
	geVec3d		Current, Final, Delta;
	geXForm3d	YRotation;
	FaceList	*fl;
	Face		*f;
	Brush		*b;

	NumVerticalBands	= (int)(pTemplate->VerticalStripes);

	if (NumVerticalBands < 3)
	{
		return	NULL;
	}


	Verts		=(geVec3d *)geRam_Allocate(sizeof(geVec3d)*NumVerticalBands * 2);
	TopPoints	=(geVec3d *)geRam_Allocate(sizeof(geVec3d)*NumVerticalBands);
	fl			=FaceList_Create(NumVerticalBands + 2);

	if(!Verts || !TopPoints ||!fl)
	{
		return	NULL;
	}

	geXForm3d_SetIdentity(&YRotation);
	geXForm3d_SetYRotation(&YRotation, (M_PI * 2.0f)/(geFloat)NumVerticalBands);

	// Start with the top of cylinder
	CurrentXDiameter	=pTemplate->TopXSize;
	CurrentZDiameter	=pTemplate->TopZSize;
	DeltaXDiameter		=(pTemplate->BotXSize - pTemplate->TopXSize);
	DeltaZDiameter		=(pTemplate->BotZSize - pTemplate->TopZSize);
	
	// Get the offset amounts
	CurrentXOffset	=pTemplate->TopXOffset;
	CurrentZOffset	=pTemplate->TopZOffset;
	DeltaXOffset	=(pTemplate->BotXOffset - pTemplate->TopXOffset);
	DeltaZOffset	=(pTemplate->BotZOffset - pTemplate->TopZOffset);

	// Get the band positions and deltas
	geVec3d_Set(&Current, (float)(pTemplate->TopXSize / 2), (float)(pTemplate->YSize / 2), 0.0);
	geVec3d_Set(&Delta, (float)((pTemplate->BotXSize / 2) - Current.X), (float)(-(pTemplate->YSize/2) - Current.Y), 0.0);

	for(HBand = 0;HBand <= 1;HBand++)
	{
		Final = Current;
		for(VBand = 0;VBand < NumVerticalBands;VBand++)
		{
			// Get the elliptical Z value
			// (x^2/a^2) + (z^2/b^2) = 1
			// z = sqrt(b^2(1 - x^2/a^2))
			sqrcheck=( ((CurrentZDiameter/2)*(CurrentZDiameter/2))
				* (1.0 - (Final.X*Final.X)
				/ ( (CurrentXDiameter/2)*(CurrentXDiameter/2) )) );
			if(sqrcheck <0.0)
				sqrcheck=0.0;
			EllipseZ = sqrt(sqrcheck);

			// Check if we need to negate this thing
			if(VBand > (NumVerticalBands/2))
				EllipseZ = -EllipseZ;

			geVec3d_Set
			(
				&Verts[VertexCount],
				(float)(Final.X + CurrentXOffset),
				Final.Y,
				(float)(EllipseZ + CurrentZOffset)
			);
			VertexCount++;

			// Rotate the point around the Y to get the next vertical band
			geXForm3d_Rotate(&YRotation, &Final, &Final);
		}
		CurrentXDiameter	+=DeltaXDiameter;
		CurrentZDiameter	+=DeltaZDiameter;
		CurrentXOffset		+=DeltaXOffset;
		CurrentZOffset		+=DeltaZOffset;

		geVec3d_Add(&Current, &Delta, &Current);
	}

	for(VBand=0;VBand < NumVerticalBands;VBand++)
	{
		TopPoints[VBand]	=Verts[VBand];
	}
	f	=Face_Create(NumVerticalBands, TopPoints, 0);

	if(f)
	{
		if(pTemplate->Solid > 1)
		{
			Face_SetFixedHull(f, GE_TRUE);
		}
		FaceList_AddFace(fl, f);
	}

	for(VBand=NumVerticalBands-1, HBand=0;VBand >=0;VBand--, HBand++)
	{
		TopPoints[HBand]	=Verts[VBand + NumVerticalBands];
	}
	f	=Face_Create(NumVerticalBands, TopPoints, 0);

	if(f)
	{
		if(pTemplate->Solid > 1)
		{
			Face_SetFixedHull(f, GE_TRUE);
		}
		FaceList_AddFace(fl, f);
	}

	// Generate the polygons
	for(HBand = 0;HBand < 1;HBand++)
	{
		for(VBand = 0;VBand < NumVerticalBands;VBand++)
		{
			TopPoints[3]	=Verts[(HBand * NumVerticalBands) + VBand];
			TopPoints[2]	=Verts[(HBand * NumVerticalBands) + ((VBand + 1) % NumVerticalBands)];
			TopPoints[1]	=Verts[((HBand + 1) * NumVerticalBands) + ((VBand + 1) % NumVerticalBands)];
			TopPoints[0]	=Verts[((HBand + 1) * NumVerticalBands) + VBand];
			f				=Face_Create(4, TopPoints, 0);
			if(f)
			{
				FaceList_AddFace(fl, f);
			}
		}
	}
	geRam_Free(Verts);
	geRam_Free(TopPoints);

	if(!pTemplate->Solid)
	{
		b	=Brush_Create(BRUSH_LEAF, fl, NULL);
		if(b)
		{
			Brush_SetSubtract(b, pTemplate->TCut);
		}
		return	b;
	}
	else
	{
		BrushList	*bl	=BrushList_Create();
		Brush		*bh, *bm;

		b	=Brush_Create(BRUSH_LEAF, fl, NULL);
		if(b)
		{
			Brush_SetHollow(b, GE_TRUE);
			Brush_SetHullSize(b, (float)pTemplate->Thickness);
			bh	=Brush_CreateHollowFromBrush(b);
			if(bh)
			{
				Brush_SetHollowCut(bh, GE_TRUE);
				BrushList_Append(bl, b);
				BrushList_Append(bl, bh);

				bm	=Brush_Create(BRUSH_MULTI, NULL, bl);
				if(bm)
				{
					Brush_SetHollow(bm, GE_TRUE);
					Brush_SetSubtract(bm, pTemplate->TCut);
					Brush_SetHullSize(bm, (float)pTemplate->Thickness);
					return	bm;
				}
			}
			else
			{
				Brush_Destroy(&b);
				BrushList_Destroy(&bl);
			}
		}
		else
		{
			BrushList_Destroy(&bl);
		}
	}

	return	NULL;
}