All pastes #449187 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-04-20 02:28 UTC
rendered paste body
Index: rts/Lua/LuaWeaponDefs.cpp===================================================================--- rts/Lua/LuaWeaponDefs.cpp	(revision 3625)+++ rts/Lua/LuaWeaponDefs.cpp	(working copy)@@ -341,6 +341,7 @@ 	HSTR_PUSH_NUMBER(L, "tileLength",  v.tilelength); 	HSTR_PUSH_NUMBER(L, "scrollSpeed", v.scrollspeed); 	HSTR_PUSH_NUMBER(L, "pulseSpeed",  v.pulseSpeed);+	HSTR_PUSH_BOOL  (L, "plasmaBlend",  v.blend); 	return 1; //	CColorMap *colorMap; //	AtlasedTexture *texture1;Index: rts/Rendering/Textures/TextureAtlas.cpp===================================================================--- rts/Rendering/Textures/TextureAtlas.cpp	(revision 3625)+++ rts/Rendering/Textures/TextureAtlas.cpp	(working copy)@@ -340,3 +340,13 @@ { 	return textures.find(StringToLower(name)) != textures.end(); }++AtlasedTexture CTextureAtlas::GetTextureWithBackup(std::string name, std::string backupName)+{+	if (textures.find(StringToLower(name)) != textures.end()) {+		return textures[StringToLower(name)];+	} else {+		return textures[StringToLower(backupName)];+	}+}+Index: rts/Rendering/Textures/TextureAtlas.h===================================================================--- rts/Rendering/Textures/TextureAtlas.h	(revision 3625)+++ rts/Rendering/Textures/TextureAtlas.h	(working copy)@@ -57,8 +57,12 @@ 	//return a Texture struct of the specified texture 	AtlasedTexture GetTexture(std::string name); 	+	//Return a Texture struct of the specified texture if it exists, otherwise return a backup texture.+	AtlasedTexture GetTextureWithBackup(std::string name, std::string backupName);+	 	//return a boolean true if the texture exists within the "textures" map and false if it does not.  	bool TextureExists(const std::string& name);+	  	//return a pointer to a Texture struct of the specified texture, this pointer points to the actuall Texture struct stored, do not delete or modify 	AtlasedTexture* GetTexturePtr(std::string name);Index: rts/Sim/Projectiles/ExplosiveProjectile.cpp===================================================================--- rts/Sim/Projectiles/ExplosiveProjectile.cpp	(revision 3625)+++ rts/Sim/Projectiles/ExplosiveProjectile.cpp	(working copy)@@ -104,18 +104,35 @@ 	 	float3 dir=speed; 	dir.Normalize();+	+	if (weaponDef->visuals.plasmaBlend) {   		//plasma shot is a blend of 5 textures -	for(int a=0;a<5;++a){-		col[0]=int((5-a)*0.2f*col[0]);-		col[1]=int((5-a)*0.2f*col[1]);-		col[2]=int((5-a)*0.2f*col[2]);-		col[3]=int((5-a)*0.2f*col[3]);-		float3 interPos=pos+speed*gu->timeOffset-dir*drawRadius*0.6f*a;-		va->AddVertexTC(interPos-camera->right*drawRadius-camera->up*drawRadius,weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->ystart,col);-		va->AddVertexTC(interPos+camera->right*drawRadius-camera->up*drawRadius,weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->ystart,col);-		va->AddVertexTC(interPos+camera->right*drawRadius+camera->up*drawRadius,weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->yend,col);-		va->AddVertexTC(interPos-camera->right*drawRadius+camera->up*drawRadius,weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->yend,col);-	}+		for(int a=0;a<5;++a){+			col[0]=int((5-a)*0.2f*col[0]);+			col[1]=int((5-a)*0.2f*col[1]);+			col[2]=int((5-a)*0.2f*col[2]);+			col[3]=int((5-a)*0.2f*col[3]);+			float3 interPos=pos+speed*gu->timeOffset-dir*drawRadius*0.6f*a;+			va->AddVertexTC(interPos-camera->right*drawRadius-camera->up*drawRadius,weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->ystart,col);+			va->AddVertexTC(interPos+camera->right*drawRadius-camera->up*drawRadius,weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->ystart,col);+			va->AddVertexTC(interPos+camera->right*drawRadius+camera->up*drawRadius,weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->yend,col);+			va->AddVertexTC(interPos-camera->right*drawRadius+camera->up*drawRadius,weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->yend,col);+		}+	} else {							//plasma shot texture is directional and not blended+		float3 dif(pos-camera->pos);+		float camDist=dif.Length();+		dif/=camDist;+		float3 dir1(dif.cross(speed));+		dir1.Normalize();+		float3 dir2(dif.cross(dir1));++		float3 interPos=pos+speed*gu->timeOffset-dir*drawRadius*0.6f*5;+		va->AddVertexTC(interPos-dir1*drawRadius-dir2*drawRadius,weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->ystart,col);+		va->AddVertexTC(interPos-dir1*drawRadius+dir2*drawRadius,weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->ystart,col);+		va->AddVertexTC(interPos+dir1*drawRadius+dir2*drawRadius,weaponDef->visuals.texture1->xend,weaponDef->visuals.texture1->yend,col);+		va->AddVertexTC(interPos+dir1*drawRadius-dir2*drawRadius,weaponDef->visuals.texture1->xstart,weaponDef->visuals.texture1->yend,col);+	}	+ }  int CExplosiveProjectile::ShieldRepulse(CPlasmaRepulser* shield,float3 shieldPos, float shieldForce, float shieldMaxSpeed)Index: rts/Sim/Projectiles/FireBallProjectile.cpp===================================================================--- rts/Sim/Projectiles/FireBallProjectile.cpp	(revision 3625)+++ rts/Sim/Projectiles/FireBallProjectile.cpp	(working copy)@@ -63,10 +63,10 @@ 		col[0]=(maxCol-i)*25; 		col[1]=(maxCol-i)*15; 		col[2]=(maxCol-i)*10;-		va->AddVertexTC(interPos-camera->right*size-camera->up*size,ph->fireballflaretex.xstart ,ph->fireballflaretex.ystart ,col);-		va->AddVertexTC(interPos+camera->right*size-camera->up*size,ph->fireballflaretex.xend ,ph->fireballflaretex.ystart ,col);-		va->AddVertexTC(interPos+camera->right*size+camera->up*size,ph->fireballflaretex.xend ,ph->fireballflaretex.yend ,col);-		va->AddVertexTC(interPos-camera->right*size+camera->up*size,ph->fireballflaretex.xstart ,ph->fireballflaretex.yend ,col);+		va->AddVertexTC(interPos-camera->right*size-camera->up*size,ph->dguntex.xstart ,ph->dguntex.ystart ,col);+		va->AddVertexTC(interPos+camera->right*size-camera->up*size,ph->dguntex.xend ,ph->dguntex.ystart ,col);+		va->AddVertexTC(interPos+camera->right*size+camera->up*size,ph->dguntex.xend ,ph->dguntex.yend ,col);+		va->AddVertexTC(interPos-camera->right*size+camera->up*size,ph->dguntex.xstart ,ph->dguntex.yend ,col); 		interPos = interPos-speed*0.5f; 	} }Index: rts/Sim/Projectiles/ProjectileHandler.cpp===================================================================--- rts/Sim/Projectiles/ProjectileHandler.cpp	(revision 3625)+++ rts/Sim/Projectiles/ProjectileHandler.cpp	(working copy)@@ -106,118 +106,27 @@ 		sprintf(num, "%02i", i); 		smoketex[i] = textureAtlas->GetTexture(std::string("ismoke") + num); 	}-	-	//The following section allows the modmaker to define projectile textures in alternative to some of those above.-	if (textureAtlas->TextureExists("sbtrailtexture")) {-		sbtrailtex = textureAtlas->GetTexture("sbtrailtexture");-	} else {-		sbtrailtex = textureAtlas->GetTexture("smoketrail");-	}-	-	if (textureAtlas->TextureExists("missiletrailtexture")) {-		missiletrailtex = textureAtlas->GetTexture("missiletrailtexture");-	} else {-		missiletrailtex = textureAtlas->GetTexture("smoketrail");-	}-	-	if (textureAtlas->TextureExists("muzzleflametexture")) {-		muzzleflametex = textureAtlas->GetTexture("muzzleflametexture");-	} else {-		muzzleflametex = textureAtlas->GetTexture("explo");-	}-		-	if (textureAtlas->TextureExists("repulsetexture")) {-		repulsetex = textureAtlas->GetTexture("repulsetexture");-	} else {-		repulsetex = textureAtlas->GetTexture("explo");-	}-	-	if (textureAtlas->TextureExists("fireballflaretexture")) {-		fireballflaretex = textureAtlas->GetTexture("fireballflaretexture");-	} else {-		fireballflaretex = textureAtlas->GetTexture("flare");-	}-	-	if (textureAtlas->TextureExists("flareprojectiletexture")) {-		flareprojectiletex = textureAtlas->GetTexture("flareprojectiletexture");-	} else {-		flareprojectiletex = textureAtlas->GetTexture("flare");-	}-	-	if (textureAtlas->TextureExists("sbflaretexture")) {-		sbflaretex = textureAtlas->GetTexture("sbflaretexture");-	} else {-		sbflaretex = textureAtlas->GetTexture("flare");-	} -	if (textureAtlas->TextureExists("missileflaretexture")) {-		missileflaretex = textureAtlas->GetTexture("missileflaretexture");-	} else {-		missileflaretex = textureAtlas->GetTexture("flare");-	}+	sbtrailtex = textureAtlas->GetTextureWithBackup("sbtrailtexture", "smoketrail");+	missiletrailtex = textureAtlas->GetTextureWithBackup("missiletrailtexture", "smoketrail");+	muzzleflametex = textureAtlas->GetTextureWithBackup("muzzleflametexture", "explo");+	repulsetex = textureAtlas->GetTextureWithBackup("repulsetexture", "explo");+	dguntex = textureAtlas->GetTextureWithBackup("dguntexture", "flare");+	flareprojectiletex = textureAtlas->GetTextureWithBackup("flareprojectiletexture", "flare");+	sbflaretex = textureAtlas->GetTextureWithBackup("sbflaretexture", "flare");+	missileflaretex = textureAtlas->GetTextureWithBackup("missileflaretexture", "flare");+	beamlaserflaretex = textureAtlas->GetTextureWithBackup("beamlaserflaretexture", "flare");+	bubbletex = textureAtlas->GetTextureWithBackup("bubbletexture", "circularthingy");+	geosquaretex = textureAtlas->GetTextureWithBackup("geosquaretexture", "circularthingy");+	gfxtex = textureAtlas->GetTextureWithBackup("gfxtexture", "circularthingy");+	projectiletex = textureAtlas->GetTextureWithBackup("projectiletexture", "circularthingy");+	repulsegfxtex = textureAtlas->GetTextureWithBackup("repulsegfxtexture", "circularthingy");+	sphereparttex = textureAtlas->GetTextureWithBackup("sphereparttexture", "circularthingy");+	torpedotex = textureAtlas->GetTextureWithBackup("torpedotexture", "circularthingy");+	wrecktex = textureAtlas->GetTextureWithBackup("wrecktexture", "circularthingy");+	plasmatex = textureAtlas->GetTextureWithBackup("plasmatexture", "circularthingy");+ 	-		if (textureAtlas->TextureExists("beamlaserflaretexture")) {-		beamlaserflaretex = textureAtlas->GetTexture("beamlaserflaretexture");-	} else {-		beamlaserflaretex = textureAtlas->GetTexture("flare");-	}-	-	if (textureAtlas->TextureExists("bubbletexture")) {-		bubbletex = textureAtlas->GetTexture("bubbletexture");-	} else {-		bubbletex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("geosquaretexture")) {-		geosquaretex = textureAtlas->GetTexture("geosquaretexture");-	} else {-		geosquaretex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("gfxtexture")) {-		gfxtex = textureAtlas->GetTexture("gfxtexture");-	} else {-		gfxtex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("projectiletexture")) {-		projectiletex = textureAtlas->GetTexture("projectiletexture");-	} else {-		projectiletex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("repulsegfxtexture")) {-		repulsegfxtex = textureAtlas->GetTexture("repulsegfxtexture");-	} else {-		repulsegfxtex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("sphereparttexture")) {-		sphereparttex = textureAtlas->GetTexture("sphereparttexture");-	} else {-		sphereparttex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("torpedotexture")) {-		torpedotex = textureAtlas->GetTexture("torpedotexture");-	} else {-		torpedotex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("wrecktexture")) {-		wrecktex = textureAtlas->GetTexture("wrecktexture");-	} else {-		wrecktex = textureAtlas->GetTexture("circularthingy");-	}-	-	if (textureAtlas->TextureExists("weapondeftexture")) {-		weapondeftex = textureAtlas->GetTexture("weapondeftexture");-	} else {-		weapondeftex = textureAtlas->GetTexture("circularthingy");-	}-	-	-	 	groundFXAtlas = SAFE_NEW CTextureAtlas(2048, 2048); 	//add all textures in groundfx section 	ptex = resources.GetAllValues("resources\\graphics\\groundfx");Index: rts/Sim/Projectiles/ProjectileHandler.h===================================================================--- rts/Sim/Projectiles/ProjectileHandler.h	(revision 3625)+++ rts/Sim/Projectiles/ProjectileHandler.h	(working copy)@@ -72,28 +72,28 @@  	//texturcoordinates for projectiles 	AtlasedTexture flaretex;-	AtlasedTexture fireballflaretex; //dgun texture-	AtlasedTexture flareprojectiletex;-	AtlasedTexture sbtrailtex;  //first section of starburst missile trail texture-	AtlasedTexture missiletrailtex;-	AtlasedTexture muzzleflametex; //first section of missile trail texture+	AtlasedTexture dguntex; //dgun texture+	AtlasedTexture flareprojectiletex; //texture used by flares that trick missiles+	AtlasedTexture sbtrailtex;  //default first section of starburst missile trail texture+	AtlasedTexture missiletrailtex; //default first section of missile trail texture+	AtlasedTexture muzzleflametex; //default muzzle flame texture 	AtlasedTexture repulsetex;  //texture of impact on repulsor-	AtlasedTexture sbflaretex; //starburst  missile flare texture-	AtlasedTexture missileflaretex;-	AtlasedTexture beamlaserflaretex;+	AtlasedTexture sbflaretex; //default starburst  missile flare texture+	AtlasedTexture missileflaretex;  //default missile flare texture+	AtlasedTexture beamlaserflaretex; //default beam laser flare texture 	AtlasedTexture explotex; 	AtlasedTexture explofadetex; 	AtlasedTexture heatcloudtex; 	AtlasedTexture circularthingytex; 	AtlasedTexture bubbletex;  //torpedo trail texture-	AtlasedTexture geosquaretex;+	AtlasedTexture geosquaretex;  //unknown use 	AtlasedTexture gfxtex; //nanospray texture-	AtlasedTexture projectiletex;-	AtlasedTexture repulsegfxtex;-	AtlasedTexture sphereparttex;-	AtlasedTexture torpedotex;-	AtlasedTexture wrecktex; //smoking explosion part-	AtlasedTexture weapondeftex; //plasma texture+	AtlasedTexture projectiletex;  //appears to be unused+	AtlasedTexture repulsegfxtex;  //used by repulsor+	AtlasedTexture sphereparttex; //sphere explosion texture+	AtlasedTexture torpedotex;  //appears in-game as a 1 texel texture+	AtlasedTexture wrecktex; //smoking explosion part texture+	AtlasedTexture plasmatex; //default plasma texture 	AtlasedTexture laserendtex; 	AtlasedTexture laserfallofftex; 	AtlasedTexture randdotstex;Index: rts/Sim/Weapons/WeaponDefHandler.cpp===================================================================--- rts/Sim/Weapons/WeaponDefHandler.cpp	(revision 3625)+++ rts/Sim/Weapons/WeaponDefHandler.cpp	(working copy)@@ -116,6 +116,8 @@ 	sunparser->GetDef(weaponDefs[id].laserflaresize, "15", weaponname + "\\laserflaresize"); 	sunparser->GetDef(weaponDefs[id].intensity, "0.9", weaponname + "\\intensity"); 	sunparser->GetDef(weaponDefs[id].duration, "0.05", weaponname + "\\duration");+	+	sunparser->GetDef(weaponDefs[id].visuals.plasmaBlend, "1", weaponname + "\\plasmaBlend");  	if(weaponDefs[id].name.find("disintegrator")!=string::npos){	//fulhack 		weaponDefs[id].visuals.renderType = WEAPON_RENDERTYPE_FIREBALL;}@@ -365,7 +367,7 @@ 	//get some weapon specific defaults 	if(weaponDefs[id].type=="Cannon"){ 		//CExplosiveProjectile-		weaponDefs[id].visuals.texture1 = &ph->weapondeftex;+		weaponDefs[id].visuals.texture1 = &ph->plasmatex; 		weaponDefs[id].visuals.color=sunparser->GetFloat3(float3(1.0f,0.5f,0.0f),weaponname + "\\rgbcolor"); 		sunparser->GetDef(weaponDefs[id].intensity, "0.2", weaponname + "\\intensity"); 	} else if(weaponDefs[id].type=="Rifle"){@@ -374,7 +376,7 @@ 		//... 	} else if(weaponDefs[id].type=="AircraftBomb"){ 		//CExplosiveProjectile or CTorpedoProjectile-		weaponDefs[id].visuals.texture1 = &ph->weapondeftex;+		weaponDefs[id].visuals.texture1 = &ph->plasmatex; 	} else if(weaponDefs[id].type=="Shield"){ 		weaponDefs[id].visuals.texture1 = &ph->perlintex; 	} else if(weaponDefs[id].type=="Flame"){@@ -399,7 +401,7 @@ 		weaponDefs[id].visuals.texture2 = &ph->missiletrailtex; 	} else if(weaponDefs[id].type=="TorpedoLauncher"){ 		//CExplosiveProjectile or CTorpedoProjectile-		weaponDefs[id].visuals.texture1 = &ph->weapondeftex;+		weaponDefs[id].visuals.texture1 = &ph->plasmatex; 	} else if(weaponDefs[id].type=="LaserCannon"){ 		//CLaserProjectile 		weaponDefs[id].visuals.texture1 = &ph->laserfallofftex;@@ -424,7 +426,7 @@ 		sunparser->GetDef(weaponDefs[id].thickness, "0.8", weaponname + "\\thickness"); 	} else if(weaponDefs[id].type=="EmgCannon"){ 		//CEmgProjectile-		weaponDefs[id].visuals.texture1 = &ph->weapondeftex;+		weaponDefs[id].visuals.texture1 = &ph->plasmatex; 		weaponDefs[id].visuals.color=sunparser->GetFloat3(float3(0.9f,0.9f,0.2f),weaponname + "\\rgbcolor"); 		sunparser->GetDef(weaponDefs[id].size, "3", weaponname + "\\size"); 	} else if(weaponDefs[id].type=="DGun"){@@ -436,8 +438,8 @@ 		weaponDefs[id].visuals.texture2 = &ph->sbtrailtex; 		weaponDefs[id].visuals.texture3 = &ph->explotex; 	}else {-		weaponDefs[id].visuals.texture1 = &ph->weapondeftex;-		weaponDefs[id].visuals.texture2 = &ph->weapondeftex;+		weaponDefs[id].visuals.texture1 = &ph->plasmatex;+		weaponDefs[id].visuals.texture2 = &ph->plasmatex; 	} 	std::string tmp; 	sunparser->GetDef(tmp, "", weaponname + "\\texture1");Index: rts/Sim/Weapons/WeaponDefHandler.h===================================================================--- rts/Sim/Weapons/WeaponDefHandler.h	(revision 3625)+++ rts/Sim/Weapons/WeaponDefHandler.h	(working copy)@@ -144,6 +144,8 @@ 		float tilelength; 		float scrollspeed; 		float pulseSpeed;+		+		bool plasmaBlend; 	}; 	Visuals visuals;