void WORrx_timeout(void) { stopCB(WORrx_cb); removeTimerCB(WORrx_cb); RFstatus &= ~WORrxon; draw_ant(100,0,DRAW_ERASE); cc1100_write1(0x16,conf[0x16]); RFstatus |= WORenabled; cc1100_strobe(SIDLE); cc1100_strobe(SWOR); }
void switch_WOR_RX(void) { if (RFstatus & WORrxon) setCBIntervall(WORrx_cb,WORrx_time); else { WORrx_cb = addTimerCB(WORrx_timeout, WORrx_time); startCB(WORrx_cb); RFstatus |= WORrxon; RFstatus &= ~WORenabled; draw_ant(100,0,DRAW_PUT); cc1100_write1(0x16,0x07); } }
/* draw ant composed of skeleton and glass */ static void show_ant(antspotlightstruct *mp) { glPushMatrix(); /* move into position */ glTranslatef(mp->ant->position[0], 0.33, mp->ant->position[2]); glRotatef(180.0 + mp->ant->direction*180.0/Pi, 0.0, 1.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); /* draw skeleton */ draw_ant(mp, mp->ant->material, mp->mono, 0, mp->ant->step, mySphere2, myCone2); /* draw glass */ if(!mp->wire && !mp->mono) { glEnable(GL_BLEND); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGrayB); glColor4fv(MaterialGrayB); draw_ant(mp, MaterialGrayB, mp->mono, 0, mp->ant->step, mySphere, myCone2); glDisable(GL_BLEND); } glPopMatrix(); }
static Bool draw_antmaze_strip(ModeInfo * mi) { antmazestruct *mp = &antmaze[MI_SCREEN(mi)]; int i; int mono = MI_IS_MONO(mi); /* glMatrixMode(GL_MODELVIEW); */ /* glLoadIdentity(); */ /* glPushMatrix(); */ glEnable(GL_LIGHTING); /* glDisable(GL_BLEND); */ glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); /* set light */ /* double l1 = 1.0 - (elevator < 1.0 ? elevator : 2.0 - elevator); */ /* GLfloat df[4] = {0.8*l1, 0.8*l1, 0.8*l1, 1.0}; */ /* glLightfv(GL_LIGHT0, GL_DIFFUSE, df); */ /* glLightfv(GL_LIGHT1, GL_DIFFUSE, df); */ /* draw board */ if(mp->elevator < 1.0) { glEnable(GL_TEXTURE_2D); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGray6); glTranslatef(-(BOARDSIZE-1)/2.0, 0.0, -(BOARDSIZE-1)/2.0); draw_board(mi, mp); glTranslatef(BOARDSIZE/2.0, 0.0, BOARDSIZE/2.0); glDisable(GL_TEXTURE_2D); } mp->introduced--; glTranslatef(0.0, -0.1, 0.0); for(i = 0; i < ANTCOUNT; ++i) { /* glLightfv(GL_LIGHT0, GL_DIFFUSE, df); */ /* glLightfv(GL_LIGHT1, GL_DIFFUSE, df); */ if(!mp->anton[i]) { continue; } /* determine location, move to goal */ glPushMatrix(); glTranslatef(0.0, 0.01, 0.0); glTranslatef(mp->antposition[i][0], mp->antposition[i][2], mp->antposition[i][1]); /* glScalef(1.0, 0.01, 1.0); */ glScalef(0.6, 0.01, 0.6); glRotatef(180.0 + mp->antdirection[i]*180.0/PI, 0.0, 1.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4fv(MaterialGrayB); glScalef(mp->antsize[i], mp->antsize[i], mp->antsize[i]); /* slow down first ant */ if(i == 0 && mp->part[i] == mp->antpathlength[i]) draw_ant(mi, mp, MaterialGrayB, mono, 1, mp->first_ant_step, mySphere, myCone); else draw_ant(mi, mp, MaterialGrayB, mono, 1, mp->ant_step, mySphere, myCone); glPopMatrix(); glDisable(GL_BLEND); glEnable(GL_LIGHTING); glPushMatrix(); /* glTranslatef(0.0, 0.18, 0.0); */ glTranslatef(0.0, 0.12, 0.0); glTranslatef(mp->antposition[i][0], mp->antposition[i][2], mp->antposition[i][1]); glRotatef(180.0 + mp->antdirection[i]*180.0/PI, 0.0, 1.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); glScalef(0.6, 0.6, 0.6); glScalef(mp->antsize[i], mp->antsize[i], mp->antsize[i]); /* glEnable(GL_TEXTURE_2D); */ /* glBindTexture(GL_TEXTURE_2D, brushedtexture); */ /* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialRed); */ /* slow down first ant */ if(i == 0 && mp->part[i] == mp->antpathlength[i] && mp->elevator > 0.0) { glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); draw_ant(mi, mp, antmaterial[i], mono, 1, mp->first_ant_step, mySphere, myCone); } else { /* glLightfv(GL_LIGHT0, GL_DIFFUSE, df); */ /* glLightfv(GL_LIGHT1, GL_DIFFUSE, df); */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, mp->brushedtexture); draw_ant(mi, mp, antmaterial[i], mono, 1, mp->ant_step, mySphereTex, myCone); glDisable(GL_TEXTURE_2D); } /* draw_ant(mi, antmaterial[i], mono, 0, ant_step, mySphereTex, myCone); */ /* glDisable(GL_TEXTURE_2D); */ glPopMatrix(); } /* glPopMatrix(); */ /* /\* now draw overlay *\/ */ /* glDisable(GL_LIGHTING); */ /* glDisable(GL_BLEND); */ /* /\* go to ortho mode *\/ */ /* glMatrixMode(GL_PROJECTION); */ /* glPushMatrix(); */ /* glLoadIdentity(); */ /* glOrtho(-4.0, 4.0, -3.0, 3.0, -100.0, 100.0); */ /* /\* translate to corner *\/ */ /* glTranslatef(4.0-1.2, 3.0-1.2, 0.0); */ /* glDisable(GL_LIGHTING); */ /* glEnable(GL_BLEND); */ /* /\* draw the 2d board *\/ */ /* glBegin(GL_QUADS); */ /* { */ /* int i, j; */ /* double sz = 1.0; */ /* for(i = 0; i < BOARDSIZE; ++i) */ /* for(j = 0; j < BOARDSIZE; ++j) { */ /* int par = board[i][j]; */ /* glColor4f(par ? 0.4 : 0.6, */ /* par ? 0.4 : 0.6, */ /* par ? 0.4 : 0.6, */ /* 0.5); */ /* glNormal3f(0.0, 0.0, 1.0); */ /* glVertex3f((sz*(i+1))/BOARDSIZE, (sz*(j+1))/BOARDSIZE, 0.0); */ /* glVertex3f((sz*i)/BOARDSIZE, (sz*(j+1))/BOARDSIZE, 0.0); */ /* glVertex3f((sz*i)/BOARDSIZE, (sz*j)/BOARDSIZE, 0.0); */ /* glVertex3f((sz*(i+1))/BOARDSIZE, (sz*j)/BOARDSIZE, 0.0); */ /* mi->polygon_count++; */ /* } */ /* } */ /* glEnd(); */ /* glPopMatrix(); */ /* but the step size is the same! */ mp->ant_step += 0.18; /* if(ant_step > 2*Pi) { */ /* ant_step = 0.0; */ /* } */ if(mp->ant_step > 5*Pi) mp->started = 1; mp->ant_position += 1; return True; }
ENTRYPOINT void draw_antmaze(ModeInfo * mi) { double h = (GLfloat) MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); antmazestruct *mp; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if(!antmaze) return; mp = &antmaze[MI_SCREEN(mi)]; MI_IS_DRAWN(mi) = True; if(!mp->glx_context) return; mi->polygon_count = 0; glXMakeCurrent(display, window, *(mp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* first panel */ glPushMatrix(); /* h = ((GLfloat) MI_HEIGHT(mi)/2) / (3*(GLfloat)MI_WIDTH(mi)/4); */ glViewport(MI_WIDTH(mi)/32, MI_HEIGHT(mi)/8, (9*MI_WIDTH(mi))/16, 3*MI_HEIGHT(mi)/4); glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* h = (3*MI_HEIGHT(mi)/4) / (3*MI_WIDTH(mi)/4); */ gluPerspective(45, 1/h, 1, 25.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); device_rotate(mi); glPushMatrix(); /* follow focused ant */ glTranslatef(0.0, 0.0, -mp->mag - 5.0); glRotatef(20.0+5.0*sin(mp->ant_step/40.0), 1.0, 0.0, 0.0); /* glTranslatef(0.0, */ /* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0)), */ /* started ? -mag : -8.0 + 4.0*fabs(sin(ant_step/10.0))); */ gltrackball_rotate(mp->trackball); glRotatef(mp->ant_step*0.6, 0.0, 1.0, 0.0); /* glRotatef(90.0, 0.0, 0.0, 1.0); */ /* glTranslatef(-antposition[0][0]-0.5, 0.0, -antposition[focus][1]); */ /*-elevator*/ /* sync */ if(!draw_antmaze_strip(mi)) { release_antmaze(mi); return; } glPopMatrix(); glPopMatrix(); h = (GLfloat) (3*MI_HEIGHT(mi)/8) / (GLfloat) (MI_WIDTH(mi)/2); /* draw overhead */ glPushMatrix(); glViewport((17*MI_WIDTH(mi))/32, MI_HEIGHT(mi)/2, MI_WIDTH(mi)/2, 3*MI_HEIGHT(mi)/8); glMatrixMode(GL_PROJECTION); glLoadIdentity(); device_rotate(mi); gluPerspective(45, 1/h, 1, 25.0); glMatrixMode(GL_MODELVIEW); /* twist scene */ glTranslatef(0.0, 0.0, -16.0); glRotatef(60.0, 1.0, 0.0, 0.0); glRotatef(-15.0 + mp->ant_step/10.0, 0.0, 1.0, 0.0); gltrackball_rotate(mp->trackball); /* sync */ if(!draw_antmaze_strip(mi)) { release_antmaze(mi); return; } glPopMatrix(); /* draw ant display */ glPushMatrix(); glViewport((5*MI_WIDTH(mi))/8, MI_HEIGHT(mi)/8, (11*MI_WIDTH(mi))/32, 3*MI_HEIGHT(mi)/8); glMatrixMode(GL_PROJECTION); glLoadIdentity(); device_rotate(mi); gluPerspective(45, 1/h, 1, 25.0); glMatrixMode(GL_MODELVIEW); /* twist scene */ glTranslatef(0.0, 0.0, -1.6); glRotatef(30.0, 1.0, 0.0, 0.0); glRotatef(mp->ant_step, 0.0, 1.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); /* /\* draw ant shadow *\/ */ /* glPushMatrix(); */ /* glScalef(1.0, 0.01, 1.0); */ /* glRotatef(90.0, 0.0, 0.0, 1.0); */ /* glRotatef(90.0, 0.0, 1.0, 0.0); */ /* glDisable(GL_LIGHTING); */ /* glColor4fv(MaterialGray6); */ /* /\* slow down first ant *\/ */ /* draw_ant(MaterialGrayB, 0, 1, first_ant_step, mySphere, myCone); */ /* glPopMatrix(); */ /* draw ant body */ glEnable(GL_TEXTURE_2D); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse); glBindTexture(GL_TEXTURE_2D, mp->brushedtexture); draw_ant(mi, mp, MaterialGray35, 0, 1, mp->ant_step/2.0, mySphereTex, myCone2); glDisable(GL_TEXTURE_2D); glPopMatrix(); /* /\* draw overlay *\/ */ /* glPushMatrix(); */ /* /\* go to ortho mode *\/ */ /* glViewport(MI_WIDTH(mi)/2, MI_HEIGHT(mi)/8, MI_WIDTH(mi)/2, 3*MI_HEIGHT(mi)/8); */ /* glMatrixMode(GL_PROJECTION); */ /* glLoadIdentity(); */ /* glPushMatrix (); */ /* glOrtho(-4.0, 4.0, -3.0, 3.0, -100.0, 100.0); */ /* glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialGrayB); */ /* glColor4fv(MaterialGrayB); */ /* glDisable(GL_LIGHTING); */ /* glEnable(GL_BLEND); */ /* glBegin(GL_QUADS); */ /* glNormal3f(0.0, 0.0, 1.0); */ /* glVertex3f(4.0, 3.0, 0.0); */ /* glVertex3f(2.0, 3.0, 0.0); */ /* glVertex3f(2.0, -3.0, 0.0); */ /* glVertex3f(4.0, -3.0, 0.0); */ /* mi->polygon_count++; */ /* glEnd(); */ /* glEnable(GL_LIGHTING); */ /* glDisable(GL_BLEND); */ /* glPopMatrix(); */ /* glPopMatrix(); */ if (MI_IS_FPS(mi)) { glViewport(0, 0, MI_WIDTH(mi), MI_HEIGHT(mi)); do_fps (mi); } glFlush(); glXSwapBuffers(display, window); update_ants(mp); mp->step += 0.025; }