Great, I started doing err... something

Great, I started doing err... something

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Sean Mirrsen
Posts: 578
Joined: 19 Aug 2004, 17:38

Great, I started doing err... something

Post by Sean Mirrsen »

Well, I managed to get the solution to work, by hacking the poor file (by simply opening it in notepad and changing required version), but I immediately run into errors when trying to build it.
There were these two 'errors' which I corrected, so that they don't show up as errors, but I'm not sure if it will impact the app's stability... Both errors are the same, just in different files: UnitDef.h and WeaponDefHandler.h, there were structs defined (sounds and visuals), but they had the struct name typed after the last curly bracket, not after the 'struct' word. Was this supposed to be this way? It was giving out errors, so I fixed it...

Ok, now to the real thing I tried to do. I'm trying to make missiles have their model displayed like starburst missiles do now, and I think I did all necessary code changes, but it still doesn't work... It's still displayed as that grey cone thingy. Where in the code is this grey thingy defined? I want to find it and destroy it! :twisted: :P
User avatar
[K.B.] Napalm Cobra
Posts: 1222
Joined: 16 Aug 2004, 06:15

Post by [K.B.] Napalm Cobra »

RocketProjectile.cpp...

Code: Select all

void CRocketProjectile::Draw()
{
	float3 interPos=pos+speed*gu->timeOffset;
	inArray=true;
	float age2=(age&7)+gu->timeOffset;
	
	float3 dif(interPos-camera->pos);
	dif.Normalize();
	float3 dir1(dif.cross(dir));
	dir1.Normalize();
	float3 dif2(oldSmoke-camera->pos);
	dif2.Normalize();
	float3 dir2(dif2.cross(oldDir));
	dir2.Normalize();

	float color=0.6;

	unsigned char col[4];
	float a1=(1-float(0)/(90))*255;
	a1*=0.7+fabs(dif.dot(dir));
	float alpha=min(255,max(0,a1));
	col[0]=color*alpha;
	col[1]=color*alpha;
	col[2]=color*alpha;
	col[3]=alpha;

	unsigned char col2[4];
	float a2=(1-float(age2)/(90))*255;
	a2*=0.7+fabs(dif2.dot(oldDir));
	alpha=min(255,max(0,a2));
	col2[0]=color*alpha;
	col2[1]=color*alpha;
	col2[2]=color*alpha;
	col2[3]=alpha;

	float xmod=0;
	float ymod=0.25;
	float size=(0.2);
	float size2=(0.2+age2*(1/70.0));

	float txs=(1-age2/8.0);
	va->AddVertexTC(interPos-dir1*size, txs/4+1.0/32, 2.0/16, col2);
	va->AddVertexTC(interPos+dir1*size, txs/4+1.0/32, 3.0/16, col2);
	va->AddVertexTC(oldSmoke+dir2*size2, 0.25+1.0/32, 3.0/16, col2);
	va->AddVertexTC(oldSmoke-dir2*size2, 0.25+1.0/32, 2.0/16, col2);
	col[3]=255;
	float3 r=dir.cross(UpVector);
	r.Normalize();
	float3 u=dir.cross(r);
	va->AddVertexTC(interPos+r*0.1f,1.0/16,1.0/16,col);
	va->AddVertexTC(interPos-r*0.1f,1.0/16,1.0/16,col);
	va->AddVertexTC(interPos+dir,1.0/16,1.0/16,col);
	va->AddVertexTC(interPos+dir,1.0/16,1.0/16,col);

	va->AddVertexTC(interPos+u*0.1f,1.0/16,1.0/16,col);
	va->AddVertexTC(interPos-u*0.1f,1.0/16,1.0/16,col);
	va->AddVertexTC(interPos+dir,1.0/16,1.0/16,col);
	va->AddVertexTC(interPos+dir,1.0/16,1.0/16,col);
}
Is it just me or does this seem over complicated for what it does?
Sean Mirrsen
Posts: 578
Joined: 19 Aug 2004, 17:38

Post by Sean Mirrsen »

Ok, I understood. The Draw section draws the smoketrail between two SmokeProjectiles, and also draws the ugly little triangle rocket that I tried to remove.

Now, I achieved the following results with my hacking:

Missile type weapons have their correct model.
Missiles stop smoking when they have expired.
Missiles fly on a more parabolic trajectory when expired.
Cannon shots can be blown away by the wind.

And, last but not least - I managed to get shadows to display on my machine!! But this very happy fact contains a problem - it seems the surface that is supposed to cast or receive shadows is tilted by around 15 degrees pitch. This makes everything south of the camera completely shadowed. SJ, any clues to what can be done to cure this?
Post Reply

Return to “Engine”