2025-07-20 05:04 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000499Spring engineGeneralpublic2007-04-04 23:28
ReporterFLOZi 
Assigned Totvo 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000499: [patch]colormap for ballistic ('cannon' type) weapons
DescriptionExactly what it says. Enables the use of colormaps for ballistic weapons. Defaults to using the rgbcolor and intensity tags if no colormap is loaded.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • diff file icon ColormapForCannon.diff (3,200 bytes) 2007-03-25 06:42 -
    Index: Projectiles/ExplosiveProjectile.cpp
    ===================================================================
    --- Projectiles/ExplosiveProjectile.cpp	(revision 3483)
    +++ Projectiles/ExplosiveProjectile.cpp	(working copy)
    @@ -8,6 +8,7 @@
     #include "Map/Ground.h"
     #include "Game/Camera.h"
     #include "Rendering/GL/VertexArray.h"
    +#include "Rendering/Textures/ColorMap.h"
     #include "Sim/Weapons/WeaponDefHandler.h"
     #include "Sim/Misc/InterceptHandler.h"
     #include "mmgr.h"
    @@ -27,12 +28,14 @@
     CExplosiveProjectile::CExplosiveProjectile(const float3& pos,const float3& speed,CUnit* owner, WeaponDef *weaponDef, int ttl,float areaOfEffect)
     : CWeaponProjectile(pos,speed,owner, 0,ZeroVector,weaponDef,0, true),
     	ttl(ttl),
    -	areaOfEffect(areaOfEffect)
    +	areaOfEffect(areaOfEffect),
    +	curTime(0)
     {
     	useAirLos=true;
     
     	SetRadius(weaponDef->collisionSize);
     	drawRadius=weaponDef->size;
    +	invttl=1.0f/ttl;
     
     #ifdef TRACE_SYNC
     	tracefile << "New explosive: ";
    @@ -57,6 +60,9 @@
     		if(TraveledRange())
     			CProjectile::Collision();
     	}
    +	curTime+=invttl;
    +	if(curTime>1)
    +		curTime=1;
     }
     
     void CExplosiveProjectile::Collision()
    @@ -87,15 +93,23 @@
     
     	inArray=true;
     	unsigned char col[4];
    -
    +	if(weaponDef->visuals.colorMap) {
    +		weaponDef->visuals.colorMap->GetColor(col, curTime);
    +	} else {
    +		col[0]=int(weaponDef->visuals.color.x*255);
    +		col[1]=int(weaponDef->visuals.color.y*255);
    +		col[2]=int(weaponDef->visuals.color.z*255);
    +		col[3]=int(weaponDef->intensity*255);
    +	}
    +	
     	float3 dir=speed;
     	dir.Normalize();
     
     	for(int a=0;a<5;++a){
    -		col[0]=int((5-a)*0.2f*weaponDef->visuals.color.x*255);
    -		col[1]=int((5-a)*0.2f*weaponDef->visuals.color.y*255);
    -		col[2]=int((5-a)*0.2f*weaponDef->visuals.color.z*255);
    -		col[3]=int((5-a)*0.2f*weaponDef->intensity*255);
    +		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);
    Index: Projectiles/ExplosiveProjectile.h
    ===================================================================
    --- Projectiles/ExplosiveProjectile.h	(revision 3483)
    +++ Projectiles/ExplosiveProjectile.h	(working copy)
    @@ -22,6 +22,8 @@
     
     	int ttl;
     	float areaOfEffect;
    +	float invttl;
    +	float curTime;
     };
     
     #endif // __EXPLOSIVE_PROJECTILE_H__
    Index: Weapons/Cannon.cpp
    ===================================================================
    --- Weapons/Cannon.cpp	(revision 3483)
    +++ Weapons/Cannon.cpp	(working copy)
    @@ -168,7 +168,7 @@
     	tracefile << "Cannon fire: ";
     	tracefile << owner->pos.x << " " << dir.x << " " << targetPos.x << " " << targetPos.y << " " << targetPos.z << "\n";
     #endif
    -	int ttl=10000;
    +	int ttl=maxPredict;
     	if(selfExplode)
     		ttl=(int)(predict+gs->randFloat()*2.5f-0.5f);
     	SAFE_NEW CExplosiveProjectile(weaponPos,dir*projectileSpeed,owner,weaponDef, ttl,areaOfEffect);
    
    diff file icon ColormapForCannon.diff (3,200 bytes) 2007-03-25 06:42 +

-Relationships
+Relationships

-Notes

~0000813

FLOZi (reporter)

Something I forgot to note:

time to live is set to the maximum prediction for time of flight, this prevents 'burnblow' type behaviour. Burnblow weapons use a ttl which is approximately equal to the time it takes for the weapon to reach its maximum range. Therefore burnblow weapons will change colours more quickly.

~0000815

KDR_11k (reporter)

What, burnblow works?

~0000827

FLOZi (reporter)

Yes, burnblow works...

~0000834

Argh (reporter)

Yay!

~0000867

tvo (reporter)

Committed, r3546
+Notes

-Issue History
Date Modified Username Field Change
2007-03-25 06:42 FLOZi New Issue
2007-03-25 06:42 FLOZi File Added: ColormapForCannon.diff
2007-03-25 06:45 FLOZi Note Added: 0000813
2007-03-25 12:56 KDR_11k Note Added: 0000815
2007-03-25 16:02 FLOZi Note Added: 0000827
2007-03-27 05:54 Argh Note Added: 0000834
2007-04-04 23:27 tvo Status new => assigned
2007-04-04 23:27 tvo Assigned To => tvo
2007-04-04 23:28 tvo Status assigned => resolved
2007-04-04 23:28 tvo Resolution open => fixed
2007-04-04 23:28 tvo Note Added: 0000867
+Issue History