eWallRim::Bound

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

eWallRim::Bound

Post by Jonathan »

Put this in the cycle rendering code and include gArena.h:

Code: Select all

#define SENSORS 1024
#define ROTATIONCONSTANT (2*M_PI/SENSORS)
#define LINEALPHA 0.125

double size = gArena::SizeMultiplier()*500*sqrt(2);
GLfloat vertices[SENSORS][4];

for(int i=0; i<SENSORS; i++) {
	double s = sin(i*ROTATIONCONSTANT);
	double c = cos(i*ROTATIONCONSTANT);
	gSensor sensor(this,pos,eCoord(s,c));
	sensor.detect(size);
	vertices[i][0]=sensor.hit*s;
	vertices[i][1]=sensor.hit*c;
	vertices[i][2]=0;
	vertices[i][3]=0;
}

glPushMatrix();
glLoadIdentity();
glTranslatef(pos.x, pos.y, 0.125);

glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnableClientState(GL_VERTEX_ARRAY);

glColor4f(color_.r, color_.g, color_.b, LINEALPHA);

glVertexPointer(2, GL_FLOAT, 8, vertices);
glDrawArrays(GL_LINES, 0, 2*SENSORS);

glVertexPointer(2, GL_FLOAT, 16, vertices);
glDrawArrays(GL_LINE_LOOP, 0, SENSORS);

glDisableClientState(GL_VERTEX_ARRAY);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(GL_TRUE);

glPopMatrix();
Run it on your fastest computer and see what happens...

Edit: looks best with antialiased lines.

And yes, I'm crazy. :)
ˌɑrməˈɡɛˌtrɑn
User avatar
Sabarai
The Former Man of Cheese
Posts: 2383
Joined: Sat Jun 19, 2004 9:00 pm
Location: 52°09'30.24"N 5°18'48.17"

Post by Sabarai »

?? can't u just tell us what happens? Not everybody has notepad :P (yes yes, stupid mistake 2 delete it) plus; i'm not so technical 2 fix the file up after i looked
Image
Image
Image
Image
Image
User avatar
Z-Man
God & Project Admin
Posts: 11710
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

I have not tried it yet either, but with the code before the last release, all sensors would report false distances. Now, the sensors that go parallel to the gridlines will work, but the diagonal one still will be off because their endpoints get clamped to the arena bounds and not clipped as would be correct.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

The result is some kind of lighting and extremely low framerates. The 'shadows' are not correct.
ˌɑrməˈɡɛˌtrɑn
User avatar
Z-Man
God & Project Admin
Posts: 11710
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Just tried it. It looks sick! Amazing how the lines give your eyes the illusion of real lighting. An optimized version of this ( you know, where you cast slightly less than 1024 rays ) that also lights up the walls and that only shines to the front could be a good addition. You'll see those guys coming after you that you thought you have trapped.

As for the bugs uncovered here:
I already fixed the bug that caused eSensor::before_hit to be set to a wrong value when the hit wall is temporary; you'll be able to use that instead ( I did not anticipate that bug ). I'll implement proper clipping later, so the distance function will work, too.
Edit: done. It was easier to do it right now that go go through this bug-entry-reminder stuff.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

z-man wrote:Just tried it. It looks sick!
:D
Amazing how the lines give your eyes the illusion of real lighting. An optimized version of this ( you know, where you cast slightly less than 1024 rays ) that also lights up the walls and that only shines to the front could be a good addition. You'll see those guys coming after you that you thought you have trapped.
Crazy things sometimes lead to interesting ideas. :)
As for the bugs uncovered here:
I already fixed the bug that caused eSensor::before_hit to be set to a wrong value when the hit wall is temporary; you'll be able to use that instead ( I did not anticipate that bug ). I'll implement proper clipping later, so the distance function will work, too.
Edit: done. It was easier to do it right now that go go through this bug-entry-reminder stuff.
Will check out (actually update, not checkout :)) the CVS later today or tomorrow.
ˌɑrməˈɡɛˌtrɑn
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

screenshot anyone?

and could you make it so that it can be used from the moviepack cfg like most other commands? please? :pdog:
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

I made these a few days ago when I was still experimenting.

Edit: a config option should be easy. All you need to do is replace SENSORS and the rotation multiplier.
Attachments
Sorry non-broadband users... I hate lossy compression.
Sorry non-broadband users... I hate lossy compression.
ˌɑrməˈɡɛˌtrɑn
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

wow very artful, thank you for the sreenshots :)
User avatar
iceman
Reverse Adjust Outside Corner Grinder
Posts: 2448
Joined: Fri Jan 09, 2004 9:54 am
Location: Yorkshire, England. Quote: Its the fumes, they make one want to play
Contact:

Post by iceman »

looks good

does it effect fps much ?
Image He who laughs last, probably has a back-up
Image
Image
sorry about the large animated gif
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

iceman wrote:looks good

does it effect fps much ?
Yes!!! Waaaay too slow with 1024 sensors per cycle. You can see it on the screenshots: at the start of the round my framerate was 11 fps and after only a few new walls it already dropped to 5 fps. And it's very low anyway. ;)
ˌɑrməˈɡɛˌtrɑn
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6712
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

What exactly am I looking at there?
Image
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

10240 lines.
ˌɑrməˈɡɛˌtrɑn
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6712
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

Lines that mean...?
Image
User avatar
Z-Man
God & Project Admin
Posts: 11710
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Light rays cast from the cycle in all directions that stop when they hit a wall. I transformed them into a headlight:

Code: Select all

#define SENSORS 128 
#define ROTATIONCONSTANT (2*M_PI/SENSORS) 
#define LINEALPHA 0.125 
 
double size = gArena::SizeMultiplier()*500*sqrt(2); 
GLfloat vertices[SENSORS][4]; 
 
for(int i=0; i<SENSORS; i++) { 
    int d = i - SENSORS/2;
    REAL angle = .15*d*ROTATIONCONSTANT;
    double s = sin(angle); 
    double c = cos(angle); 
    gSensor sensor(this,pos,dir.Turn(c,s)); 
    sensor.detect(size); 
    vertices[i][0]=sensor.before_hit.x; 
    vertices[i][1]=sensor.before_hit.y; 
    vertices[i][2]=pos.x; 
    vertices[i][3]=pos.y; 
 } 
 
//  sr_ResetRenderState();
glPushMatrix(); 
glLoadIdentity(); 
glTranslatef(0, 0, 0.125); 

glDepthMask(GL_FALSE); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE); 
glEnableClientState(GL_VERTEX_ARRAY); 
glDisable(GL_TEXTURE_2D);
 
glColor4f(color_.r, color_.g, color_.b, LINEALPHA); 
 
glVertexPointer(2, GL_FLOAT, 8, vertices); 
glDrawArrays(GL_LINES, 0, 2*SENSORS); 
 
glVertexPointer(2, GL_FLOAT, 16, vertices); 
glDrawArrays(GL_LINE_STRIP, 0, SENSORS); 
 
glDisableClientState(GL_VERTEX_ARRAY); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
glDepthMask(GL_TRUE); 
 
glPopMatrix();
Much more playable :)
Jonathan's screenshots are with the bugs in the distance callulation. They are fixed now.
Attachments
headlight1.jpg
headlight2.jpg
headlight3.jpg
Post Reply