Ejemplo n.º 1
0
void rect(int x1, int y1, int x2, int y2)
{
	int temp;

	if(x1>x2)
	{
		temp=x1;
		x1=x2;
		x2=temp;
	}

	if(y1>y2)
	{
		temp=y1;
		y1=y2;
		y2=y1;
	}

	makeline(x1,y1,x1,y2);
	makeline(x1,y1,x2,y1);
	makeline(x1,y2,x2,y2);
	makeline(x2,y1,x2,y2);

	drawgrid();

}
Ejemplo n.º 2
0
/* Sets up the screen for the start of a game.
 */
void displaygamestart(void)
{
    clear();
    drawgrid();
    movetowords(FALSE);
    addch('\n');
    refresh();
}
Ejemplo n.º 3
0
void cleargrid()
{
	for(int loopx=0;loopx<maxx;loopx++)
	{
		for(int loopy=0;loopy<maxy;loopy++)
		{
			graph[loopx][loopy]=16;
		}
	}
	drawgrid();
}
Ejemplo n.º 4
0
void runkernel(void)
{
	cleardevice();
	setbkcolor(0);

	int id,l,count=0;
	Control.First=0;
	Control.Free=50;
	id=Number+1;
	while((Control.Free<50)||(Number==-1))
	{
		while(bioskey(1)!=0)
		{
			count++;
			bioskey(0);
			biuldwait(id);
			id++;
			Number++;
		}
		if((wt==wh&&wh==0)||(wt!=wh))	biuldmem();/*Biuld all can*/
		cleardevice();
		setbkcolor(0);
		drawgrid();
		run();
		finish();
		compress();
		display();
		delay(2000);
	}
	setcolor(0);
	for(int a=0;a<629;a++)
	{
		moveto(a,390);
		lineto(a,425);
		moveto(a,445);
		lineto(a,460);
	}
	setcolor(YELLOW);
	outtextxy(180,450,"All the processes have been done!");
	getch();
}
Ejemplo n.º 5
0
void ShowScene2(int mode, int view_mode, int quad, GLint s_left, GLint s_down){

  if(rotation_type==EYE_CENTERED&&nskyboxinfo>0)draw_skybox();

  if(UpdateLIGHTS==1)updateLights(light_position0,light_position1);

  if(mode==DRAWSCENE){
    glPointSize((float)1.0);


    /* ++++++++++++++++++++++++ draw trees +++++++++++++++++++++++++ */

    if(ntreeinfo>0){
      CLIP_GEOMETRY;
      drawtrees();
      SNIFF_ERRORS("after drawtrees");
    }

/* ++++++++++++++++++++++++ draw particles +++++++++++++++++++++++++ */

    if(showsmoke==1){
      CLIP_VALS;
      drawpart_frame();
    }

/* ++++++++++++++++++++++++ draw evacuation +++++++++++++++++++++++++ */

    if(showevac==1){
      CLIP_VALS;
      drawevac_frame();
    }

/* ++++++++++++++++++++++++ draw targets +++++++++++++++++++++++++ */

    if(showtarget==1){
      CLIP_VALS;
      drawTargets();
    }

#ifdef pp_GEOMTEST
    if(show_geomtest==1){
      CLIP_GEOMETRY;
      draw_geomtestclip();
      draw_geomtestoutline();
    }
    if(show_cutcells==1)draw_geom_cutcells();
#endif

/* ++++++++++++++++++++++++ draw circular vents +++++++++++++++++++++++++ */

    if(ncvents>0&&visCircularVents!=VENT_HIDE){
      CLIP_GEOMETRY;
      DrawCircVents(visCircularVents);
    }

/* ++++++++++++++++++++++++ draw sensors/sprinklers/heat detectors +++++++++++++++++++++++++ */

    CLIP_GEOMETRY;
    draw_devices();
#ifdef pp_PILOT
    draw_pilot();
#endif    
    SNIFF_ERRORS("after draw_devices");

    if(visaxislabels==1){
      UNCLIP;
      outputAxisLabels();
      SNIFF_ERRORS("after outputAxisLables");
    }


 /* ++++++++++++++++++++++++ draw user ticks +++++++++++++++++++++++++ */

    if(visUSERticks==1){
      antialias(ON);
      UNCLIP;
      draw_user_ticks();
      antialias(OFF);
      SNIFF_ERRORS("after drawticks");
    }

 /* ++++++++++++++++++++++++ draw ticks +++++++++++++++++++++++++ */

    if(visFDSticks==1&&ntickinfo>0){
      UNCLIP;
      drawticks();
      SNIFF_ERRORS("after drawticks");
    }

    /* ++++++++++++++++++++++++ draw ticks +++++++++++++++++++++++++ */

    if(showgravity==1){
      UNCLIP;
      drawaxis();
      SNIFF_ERRORS("after drawaxis");
    }

    /* draw the box framing the simulation (corners at (0,0,0) (xbar,ybar,zbar) */


/* ++++++++++++++++++++++++ draw simulation frame (corners at (0,0,0) and (xbar,ybar,zbar) +++++++++++++++++++++++++ */

    if(isZoneFireModel==0&&visFrame==1&&highlight_flag==2){
      CLIP_GEOMETRY;
      drawoutlines();
      SNIFF_ERRORS("after drawoutlines");
    }

    if(show_rotation_center==1){
      unsigned char pcolor[4];

      CLIP_GEOMETRY;
      glPushMatrix();
      glTranslatef(camera_current->xcen,camera_current->ycen,camera_current->zcen);
      pcolor[0]=255*foregroundcolor[0];
      pcolor[1]=255*foregroundcolor[1];
      pcolor[2]=255*foregroundcolor[2];
      drawsphere(0.03,pcolor);
      glPopMatrix();
    }


/* ++++++++++++++++++++++++ draw mesh +++++++++++++++++++++++++ */

    if(setPDIM==1){
      if(visGrid!=noGridnoProbe){
        int igrid;
        mesh *meshi;

        UNCLIP;
        for(igrid=0;igrid<nmeshes;igrid++){
          meshi=meshinfo+igrid;
          drawgrid(meshi);
          SNIFF_ERRORS("drawgrid");
        }
      }
    }
  } /* end of if(mode==DRAWSCENE) code segment */


/* ++++++++++++++++++++++++ draw selected devices +++++++++++++++++++++++++ */

  if(mode==SELECTOBJECT){
    if(select_device==1){
      CLIP_GEOMETRY;
      draw_devices();
      SNIFF_ERRORS("after drawselect_devices");
      return;
    }
  }

/* ++++++++++++++++++++++++ draw selected avatars +++++++++++++++++++++++++ */

  if(mode==SELECTOBJECT){
    if(select_avatar==1){
      CLIP_GEOMETRY;
      drawselect_avatars();
      SNIFF_ERRORS("after drawselect_avatars");
      return;
    }
  }

/* ++++++++++++++++++++++++ draw selected tours +++++++++++++++++++++++++ */

  if(mode==SELECTOBJECT){
    if(edittour==1&&ntours>0){
      CLIP_GEOMETRY;
      drawselect_tours();
      SNIFF_ERRORS("after drawselect_tours");
      return;
    }
  }


/* ++++++++++++++++++++++++ draw tours +++++++++++++++++++++++++ */

  if(showtours==1){
    CLIP_GEOMETRY;
    drawtours();
    SNIFF_ERRORS("after drawtours");
  }

  /* ++++++++++++++++++++++++ draw stereo parallax indicator +++++++++++++++++++++++++ */
  
  if(show_parallax==1){
    UNCLIP;
    antialias(ON);
    glLineWidth(linewidth);
    glBegin(GL_LINES);
    glColor3fv(foregroundcolor);
    glVertex3f(0.75,0.0,0.25);
    glVertex3f(0.75,1.0,0.25);
    glEnd();
    antialias(OFF);
  }

  /* ++++++++++++++++++++++++ draw blockages +++++++++++++++++++++++++ */

  CLIP_GEOMETRY;
  drawBlockages(mode,DRAW_OPAQUE);
  SNIFF_ERRORS("drawBlockages");

  /* ++++++++++++++++++++++++ draw triangles +++++++++++++++++++++++++ */
  
  if(ngeominfoptrs>0){
    CLIP_GEOMETRY;
    draw_geom(DRAW_OPAQUE,GEOM_STATIC);
    draw_geom(DRAW_OPAQUE,GEOM_DYNAMIC);
  }

/* ++++++++++++++++++++++++ draw shooter points +++++++++++++++++++++++++ */

  if(showshooter!=0&&shooter_active==1){
    CLIP_VALS;
    draw_shooter();
  }

/* ++++++++++++++++++++++++ draw terrain +++++++++++++++++++++++++ */

  if(visTerrainType!=TERRAIN_HIDDEN&&nterraininfo>0){
    int i;
    
    //shaded 17 0
    //stepped 18 1
    //line    19 2
    //texture 20 3
    //hidden 20 4

    CLIP_GEOMETRY;
    for(i=0;i<nterraininfo;i++){
      terraindata *terri;
      int only_geom;

      terri = terraininfo + i;
      if(terri->loaded==1){
        only_geom=0;
      }
      else{
        only_geom=1;
      }
      switch(visTerrainType){
        case TERRAIN_3D:
          drawterrain(terri,only_geom);
          break;
        case TERRAIN_2D_STEPPED:
          if(cullfaces==1)glDisable(GL_CULL_FACE);
          glPushMatrix();
          glScalef(SCALE2SMV(1.0),SCALE2SMV(1.0),SCALE2SMV(1.0));
          glTranslatef(-xbar0,-ybar0,-zbar0);
          DrawContours(&meshinfo[i].terrain_contour);
          glPopMatrix();
          if(cullfaces==1)glEnable(GL_CULL_FACE);
          break;
        case TERRAIN_2D_LINE:
          glPushMatrix();
          glScalef(SCALE2SMV(1.0),SCALE2SMV(1.0),SCALE2SMV(1.0));
          glTranslatef(-xbar0,-ybar0,-zbar0);
          DrawLineContours(&meshinfo[i].terrain_contour,1.0);
          glPopMatrix();
          break;
        case TERRAIN_3D_MAP:
          if(terrain_texture!=NULL&&terrain_texture->loaded==1){
            drawterrain_texture(terri,only_geom);
          }
          else{
            drawterrain(terri,only_geom);
          }
          break;
        default:
          ASSERT(FFALSE);
          break;
      }
    }
  }

/* ++++++++++++++++++++++++ draw slice files +++++++++++++++++++++++++ */

  if(show_gslice_triangles==1||show_gslice_normal==1||show_gslice_normal_keyboard==1||show_gslice_triangulation==1){
    CLIP_VALS;
    drawgslice_outline();
  }
  if((show_slices_and_vectors==1&&showvslice==1)||(showslice==1&&use_transparency_data==0)){
    CLIP_VALS;
    drawslice_frame();
  } 

  /* ++++++++++++++++++++++++ draw boundary files +++++++++++++++++++++++++ */

  if(showpatch==1){
    CLIP_VALS;
    drawpatch_frame();
  }

/* ++++++++++++++++++++++++ draw labels +++++++++++++++++++++++++ */

  if(visLabels==1){
    CLIP_GEOMETRY;
    drawLabels();
  }

/* ++++++++++++++++++++++++ draw animated isosurfaces +++++++++++++++++++++++++ */

    //if(isoinfo!=NULL)drawspherepoints(sphereinfo);
  if(showiso==1){
    CLIP_VALS;
    drawiso(DRAW_OPAQUE);
  }

/* ++++++++++++++++++++++++ draw zone fire modeling info +++++++++++++++++++++++++ */

  if(nrooms>0){
    CLIP_GEOMETRY;
    drawroomgeom();
    SNIFF_ERRORS("after drawroomgeom");
  }
  if(nrooms>0){
    if(showzone==1){
      CLIP_VALS;
      drawfiredata();
      SNIFF_ERRORS("after drawroomdata");
      if(ReadZoneFile==1&&nzvents>0){
        drawventdata();
        SNIFF_ERRORS("after drawventdata");
      }
    }
  }


//**********************************************************************************
//**********************************************************************************
//**********************************************************************************
//    nothing transparent should be drawn before this portion of the code
//    (ie draw all opaque objects first then draw transparent objects
//**********************************************************************************
//**********************************************************************************
//**********************************************************************************

  /* ++++++++++++++++++++++++ draw triangles +++++++++++++++++++++++++ */
  
  if(ngeominfoptrs>0){
    CLIP_GEOMETRY;
    draw_geom(DRAW_TRANSPARENT,GEOM_STATIC);
    draw_geom(DRAW_TRANSPARENT,GEOM_DYNAMIC);
  }

  if(showiso==1){
    CLIP_VALS;
    drawiso(DRAW_TRANSPARENT);
  }

/* ++++++++++++++++++++++++ draw transparent faces +++++++++++++++++++++++++ */

  CLIP_GEOMETRY;
  draw_transparent_faces();

/* ++++++++++++++++++++++++ draw 3D smoke +++++++++++++++++++++++++ */

  if(show3dsmoke==1||showvolrender==1){
    CLIP_VALS;
    drawsmoke_frame();
  }

  if(active_smokesensors==1&&show_smokesensors!=0){
    CLIP_VALS;
    getsmokesensors();
    draw_devices_val();
  }

/* ++++++++++++++++++++++++ draw zone fire modeling info +++++++++++++++++++++++++ */

  if(nrooms>0&&showzone==1){
    CLIP_VALS;
    drawroomdata();
    SNIFF_ERRORS("after drawroomdata");
  }

/* ++++++++++++++++++++++++ draw slice files +++++++++++++++++++++++++ */

  if((show_slices_and_vectors==1&&showvslice==1)||(showslice==1&&use_transparency_data==1)){
    CLIP_VALS;
    drawslice_frame();
    SNIFF_ERRORS("after drawslice_frame");
  } 

/* ++++++++++++++++++++++++ draw transparent blockages +++++++++++++++++++++++++ */

//  draw_demo(20,20);
//  draw_demo2(1);
  CLIP_GEOMETRY;
  drawBlockages(mode,DRAW_TRANSPARENT);
  SNIFF_ERRORS("after drawBlokcages");

/* ++++++++++++++++++++++++ draw vector slice files +++++++++++++++++++++++++ */

  if(showvslice==1){
    CLIP_VALS;
    drawvslice_frame();
  }
  SNIFF_ERRORS("after drawvslice");

/* ++++++++++++++++++++++++ draw plot3d files +++++++++++++++++++++++++ */

  if(showplot3d==1){
    CLIP_VALS;
    drawplot3d_frame();
  }
  SNIFF_ERRORS("after drawplot3d");
}
Ejemplo n.º 6
0
void frame(GLFWwindow* window)
{
	int width = 0, height = 0;
  int i,j,k;
  static float globalTime=0.0f;
  float x,y;

  globalTime += 1.0f/60.0f;
	glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
	glfwGetFramebufferSize(window, &width, &height);
	glViewport(0, 0, width, height);
	glClearColor(20.0f/255.0f, 20.0f/255.0f, 90.0f/255.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDisable(GL_TEXTURE_2D);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glOrtho(viewbounds[0], viewbounds[1], viewbounds[2], viewbounds[3], viewbounds[4], viewbounds[5]);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glDisable(GL_DEPTH_TEST);
	glColor4ub(255,255,255,255);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

  
  if ( glfwGetKey(window,GLFW_KEY_1)==GLFW_PRESS )
  {
    glPointSize(4.0f);
    cpoly_marchingsq_nointerp(g_circles,MAXCIRCLES,sizeof(sCircle),SQSIDE);    
    glLineWidth(1.0f);
    glColor4f(1,1,0,1);

    k=0;
    for (i=0;i<cpoly_pool_icount[CPOLY_IPOOL_0];++i)
    {
      glBegin(GL_LINE_LOOP);
      for (j=k;j<cpoly_pool_get_index(CPOLY_IPOOL_0,i);++j )
      {
        cpoly_pool_get_vertex(j,&x,&y);
        glVertex2f(x,y);
      }
      glEnd();
      k=j;
    }

//     cpoly_convex_hull(cpoly_pool_v,cpoly_pool_get_index(CPOLY_IPOOL_0,0),sizeof(float)*2);
//     glColor4ub(0,255,0,255);
//     glBegin(GL_LINE_LOOP);
//     for ( i=0; i < cpoly_pool_icount[CPOLY_IPOOL_0]; ++i )
//     {
//       j = cpoly_pool_get_index(CPOLY_IPOOL_0,i);
//       cpoly_pool_get_vertex(j,&x,&y);
//       glVertex2f( x,y );
//     }
//     glEnd();
  }
  //else
  {
    for (i=0;i<MAXCIRCLES;++i)
    {
      drawCircle(g_circles[i].x, g_circles[i].y, g_circles[i].r, WHITE, 0, 0, 16.0f);
    }
  }
  drawgrid();
	
//   glPointSize(15.0f);
//   glColor4ub(255,255,0,255);
//   glBegin(GL_POINTS);
//   glVertex2f(0,0);
//   glEnd();

  glfwSwapBuffers(window);
}
Ejemplo n.º 7
0
LRESULT CALLBACK
WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	PAINTSTRUCT	ps;
	HDC		hdc;
#if CLIENT3D | IMAGE | GRAPH3D
	RECT		rc;
#endif
#if GRAPH3D
	static int	countup = 1;
	int		id;
	static vec1 	gx, gy;
#endif
#if TIMERDEMO
	static POINT	mousept;
#endif
#if ARCDEMO
	static int	startdegrees = 0;
	static int	enddegrees = 30;
#endif

	switch( msg) {
#if TIMERDEMO
	case WM_CREATE:
		SetTimer(hwnd, 1, 100, NULL);
		mousept.x = 60;
		mousept.y = 20;
		break;

	case WM_TIMER:
#if GRAPH3D
		GetClientRect(hwnd, &rc);
		if(countup) {
			mousept.y += 20;
			if(mousept.y >= rc.bottom) {
				mousept.y -= 20;
				countup = 0;
			}
		} else {
			mousept.y -= 20;
			if(mousept.y < 20) {
				mousept.y += 20;
				countup = 1;
			}
		}
		SendMessage(hwnd, WM_MOUSEMOVE, 0,
			MAKELONG(mousept.x, mousept.y));
#endif
#if ARCDEMO
		startdegrees += 10;
		if(startdegrees >= 360)
			startdegrees = 0;
		enddegrees += 15;
		if(enddegrees >= 360)
			enddegrees = 0;
		InvalidateRect(hwnd, NULL, TRUE);
#endif
		break;

	case WM_DESTROY:
		KillTimer(hwnd, 1);
		break;
#endif /* TIMERDEMO*/
	case WM_SIZE:
		break;

	case WM_MOVE:
		break;

#if CLIENT3D
	case WM_SETFOCUS:
		PostMessage((HWND)wp, WM_PAINT, 0, 0L);
		break;

	case WM_KILLFOCUS:
		PostMessage((HWND)wp, WM_PAINT, 0, 0L);
		break;
	case WM_ERASEBKGND:
		if(GetFocus() != hwnd)
			return DefWindowProc(hwnd, msg, wp, lp);
		return 1;
#endif
#if GRAPH3D
	case WM_ERASEBKGND:
		if((GetWindowLong(hwnd, GWL_ID) & 03) == 1)
			return 1;
		return DefWindowProc(hwnd, msg, wp, lp);
#endif
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);

#if CLIENT3D
		if(GetFocus() == hwnd) {
			GetClientRect(hwnd, &rc);
			Draw3dShadow(hdc, rc.left, rc.top,
				rc.right-rc.left, rc.bottom-rc.top,
				GetSysColor(COLOR_3DDKSHADOW),
				GetSysColor(COLOR_3DLIGHT));
			InflateRect(&rc, -1, -1);
			FillRect(hdc, &rc, GetStockObject(GRAY_BRUSH));
		}
#endif
#if IMAGE
		GetClientRect(hwnd, &rc);
		DrawDIB(hdc, rc.left+2, rc.top+2, image2);
#endif
#if ARCDEMO
{
	int x, y, w, h;
	RECT rc;

	if(hdc != NULL) {
		GetWindowRect(hwnd, &rc);
		rc.top += 13;
		InflateRect(&rc, -3, -3);
		/*Ellipse(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top);*/
		/*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
		/*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/

		x = rc.left;
		y = rc.top;
		w = rc.right - rc.left;
		h = rc.bottom - rc.top;
		w += 10;
		GdSetForeground(GdFindColor(RGB(0,255,0)));
		GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
			enddegrees*64, MWPIE);
		GdSetForeground(GdFindColor(RGB(0,0,0)));
		GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
			enddegrees*64, MWARCOUTLINE);
		/*GdSetForeground(GdFindColor(RGB(255,255,255)));*/
		/*GdPoint(hdc->psd, x+w/2, y+h/2);*/
	}
	EndPaint(hwnd, &ps);
	break;
}
#endif /* ARCDEMO*/
#if GRAPH3D
		id = (int)GetWindowLong(hwnd, GWL_ID) & 03;
		init3(hdc, id == 1? hwnd: NULL);
		switch(id) {
		case 0:
			rose(1.0, 7, 13);
			break;
		case 1:
			/*look3(0.5, 0.7, 1.5);*/
			/*look3(0.2, -2 * gy, 1.0+gx);*/
			look3(-2 * gx, -2 * gy, 1.2);
			drawgrid(-8.0, 8.0, 10, -8.0, 8.0, 10);
			break;
		case 2:
			setcolor3(BLACK);
			circle3(1.0);
			break;
		case 3:
			setcolor3(BLUE);
			daisy(1.0, 20);
			break;
		}

#if CLIPDEMO
		if(id == 1) {
			HRGN	hrgn, hrgn2;

			/* create circular clip region for effect*/
			GetClientRect(hwnd, &rc);
			InflateRect(&rc, -80, -80);
			switch((int)GetWindowLong(hwnd, GWL_ID)) {
			default:
				hrgn = CreateEllipticRgnIndirect(&rc);
				break;
			case 5:
				hrgn = CreateRoundRectRgn(rc.left, rc.top,
					rc.right, rc.bottom, 100, 100);
				break;
			case 1:
				hrgn = CreateRectRgnIndirect(&rc);
				break;
			}

			/* erase background, clip out blit area*/
			GetClientRect(hwnd, &rc);
			hrgn2 = CreateRectRgnIndirect(&rc);
			SelectClipRgn(hdc, hrgn2);
			ExtSelectClipRgn(hdc, hrgn, RGN_XOR);
			DeleteObject(hrgn2);

			GetClientRect(hwnd, &rc);
			FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));

			/* clip in only blit area*/
			SelectClipRgn(hdc, hrgn);
			DeleteObject(hrgn);
		}
#endif /* CLIPDEMO*/

		paint3(hdc);

#endif /* GRAPH3D*/
		EndPaint(hwnd, &ps);
		break;

	case WM_LBUTTONDOWN:
		break;

	case WM_MOUSEMOVE:
#if GRAPH3D
		if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) {
			POINT pt;

			POINTSTOPOINT(pt, lp);
			GetClientRect(hwnd, &rc);
			gx = (vec1)pt.x / rc.right;
			gy = (vec1)pt.y / rc.bottom;
			InvalidateRect(hwnd, NULL, FALSE);
			mousept.x = pt.x;
			mousept.y = pt.y;
		}
#endif
		break;

	case WM_LBUTTONUP:
		break;

	case WM_RBUTTONDOWN:
		break;

	default:
		return DefWindowProc( hwnd, msg, wp, lp);
	}
	return( 0);
}
Ejemplo n.º 8
0
void MakeEffect(int fxtype, float time, float x1, float y1, float x2, float y2, float u1, float v1, float u2, float v2,
				int i1, int i2, int i3, int i4, float f1, float f2, float f3, float f4) {

	int i,j;			// looper
	float reli,relj;		// normalized loop values
	float reli2,relj2;
	float angle;
	float u,v;
	float _x1,_y1,_x2,_y2,_z;	// temp screen coords
	float deltau=(u2-u1)/GRIDXSIZE;
	float deltav=(v2-v1)/GRIDYSIZE;
	float deltax=(x2-x1)/GRIDXSIZE;
	float deltay=(y2-y1)/GRIDYSIZE;

	float f;				// temp shit

	float grid[GRIDXSIZE+1][GRIDYSIZE+1][2];	// da mighty grid :)

	if (time<0) { time=0; }
	if (time>1.0) { time=1.0; }
	u1+=0.002f;
	u2-=0.002f;
	v1-=0.002f;
	v2+=0.002f;

	switch (fxtype) {
	case 0: {
				
				for (i=0;i<=GRIDXSIZE;i++) {
					for (j=0;j<=GRIDYSIZE;j++) {
						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						u=(u2-u1)*reli+u1 + (sin(time*2+reli*20+relj*15)*0.05f + cos(time*2+reli*10+relj*25)*0.05) * sqrr(sin(time*pi*0.5));
						if (u<u1) { u=u1; }
						if (u>u2) { u=u2; }
						v=(v2-v1)*relj+v1 + (sin(time*2+reli*18+relj*25)*0.05f + sin(time*2+reli*28+relj*15)*0.05) * sqrr(sin(time*pi*0.5));
						if (v>v1) { v=v1; }
						if (v<v2) { v=v2; }
						grid[i][j][0]=u;
						grid[i][j][1]=v;
					}
				}

				drawgrid(grid,x1,y1,x2,y2);


				break;
			}

	case 1: {
				
				for (i=0;i<=GRIDXSIZE;i++) {
					for (j=0;j<=GRIDYSIZE;j++) {

						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						f=(float)sqrt(sqrr(reli-0.5)+sqrr(relj-0.5))*2.0;
						f=pow(f,time*3.5f);
						f*=sqrr(sin(time*pi));
						grid[i][j][0]=((u2-u1)*reli+u1-0.5*(u1+u2))*(1-f)+0.5*(u1+u2);
						grid[i][j][1]=((v2-v1)*relj+v1-0.5*(v1+v2))*(1-f)+0.5*(v1+v2);
					}
				}

				drawgrid(grid,x1,y1,x2,y2);
				break;
			}
	case 2: {
				
				for (i=0;i<=GRIDXSIZE;i++) {
					for (j=0;j<=GRIDYSIZE;j++) {

						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						f=sqrt(sqrr(reli-0.5)+sqrr(relj-0.5))*2;
						if (f>0.001) {
						f=pow(f,1/(4*sqrr(sin(time*pi))+1)-1);
						//f=1;
						//f=(1-f)*sqr(sin(time*pi))+f*(1-sqr(sin(time*pi)));
						} else { f=0; }
						grid[i][j][0]=((u2-u1)*reli+u1-0.5*(u1+u2))*(f)+0.5*(u1+u2);
						grid[i][j][1]=((v2-v1)*relj+v1-0.5*(v1+v2))*(f)+0.5*(v1+v2);
					}
				}

				drawgrid(grid,x1,y1,x2,y2);
				break;
			}
	case 3: {
				
				time *=3.6;
				for (i=0;i<=GRIDXSIZE;i++) {
					for (j=0;j<=GRIDYSIZE;j++) {

						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						u=(u2-u1)*reli+u1 + sqrr(sin(time*pi/180*50))*offset[i][j][0];
						if (u<u1) { u=u1; }
						if (u>u2) { u=u2; }
						v=(v2-v1)*relj+v1 + sqrr(sin(time*pi/180*50))*offset[i][j][1];
						if (v>v1) { v=v1; }
						if (v<v2) { v=v2; }
						grid[i][j][0]=u;
						grid[i][j][1]=v;
					}
				}

				drawgrid(grid,x1,y1,x2,y2);
				break;
			}
	case 4: {
				time *=3.6;
				
				for (i=0;i<GRIDXSIZE;i++) {
					for (j=0;j<GRIDYSIZE;j++) {

						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						grid[i][j][0]=(u2-u1)*reli+u1 + sqrr(sin(time*pi/180*50))*offset[i][j][0];
						grid[i][j][1]=(v2-v1)*relj+v1 + sqrr(sin(time*pi/180*50))*offset[i][j][1];
					}
				}

				for (i=0;i<GRIDXSIZE;i++) {
					for (j=0;j<GRIDYSIZE;j++) {
						_x1=(x2-x1)*((float)i/GRIDXSIZE)+x1;
						_x2=(x2-x1)*((float)(i+1)/GRIDXSIZE)+x1;
						_y1=(y2-y1)*((float)j/GRIDYSIZE)+y1;
						_y2=(y2-y1)*((float)(j+1)/GRIDYSIZE)+y1;
						glBegin(GL_QUADS);
							glTexCoord2f(grid[i][j][0],grid[i][j][1]);
							glVertex2f(_x1,_y1);
							glTexCoord2f(grid[i][j][0]+deltau,grid[i][j][1]);
							glVertex2f(_x2,_y1);
							glTexCoord2f(grid[i][j][0]+deltau,grid[i][j][1]+deltav);
							glVertex2f(_x2,_y2);
							glTexCoord2f(grid[i][j][0],grid[i][j][1]+deltav);
							glVertex2f(_x1,_y2);
						glEnd();
					}
				}

				break;
			}
	case 6: {
				
				for (i=0;i<=GRIDXSIZE;i++) {
					for (j=0;j<=GRIDYSIZE;j++) {
						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						reli2=reli-0.5;
						relj2=relj-0.5;
						f=sqrt(sqrr(reli2)+sqrr(relj2));

						if (f>0.01) {
							angle=atan(relj2/reli2);
						} else {
							angle=0;
						}
						if (reli2<0) { angle+=pi; }
						if (f<0.5) {
							if (i1) {
								angle+=25*sqrr(0.5-f)*sqrr(sin(time*pi*0.5));
							} else {
								angle-=25*sqrr(0.5-f)*sqrr(sin(time*pi*0.5));
							}
						}

						reli=f*cos(angle)+0.5;
						relj=f*sin(angle)+0.5;

						grid[i][j][0]=(u2-u1)*reli+u1;
						grid[i][j][1]=(v2-v1)*relj+v1;
					}
				}

				drawgrid(grid,x1,y1,x2,y2);
				break;
			}
	case 7: {
				
				for (i=0;i<=GRIDXSIZE;i++) {
					for (j=0;j<=GRIDYSIZE;j++) {
						reli=(float)i/GRIDXSIZE;
						relj=(float)j/GRIDYSIZE;
						reli2=reli-0.5;
						relj2=relj-0.5;
						f=sqrt(sqrr(reli2)+sqrr(relj2));

						if (f>0.01) {
							angle=atan(relj2/reli2);
						} else {
							angle=0;
						}
						if (reli2<0) { angle-=pi; }

						f-=sqrr(sin(time*pi/180*400+f*10))*0.2 * sqrr(sin(time*pi/180*180));
						

						reli=f*cos(angle)+0.5;
						relj=f*sin(angle)+0.5;

						grid[i][j][0]=(u2-u1)*reli+u1;
						grid[i][j][1]=(v2-v1)*relj+v1;
					}
				}

				drawgrid(grid,x1,y1,x2,y2);
				break;
			}
	}

}
Ejemplo n.º 9
0
void checkgrid()
{
if(selectedwindow()==3)
{
	int x1,x2,y1,y2;
	if(mousestat()==1)
	{
		if(selected(1,0)==0)
		{
			for(int loopx=0;loopx<maxx;loopx++)
			{
				for(int loopy=0;loopy<maxy;loopy++)
				{
					x1=windows[3].x1+4+(loopx*size);
					x2=x1+size-1;
					y1=windows[3].y1+17+(loopy*size);
					y2=y1+size-1;
					if(x>=x1 && x<x2 && y>=y1 && y<y2)
					{
						graph[loopx][loopy]=selected(0,0);
						drawpixel(loopx,loopy);
					}
				}
			}
			thumb();
		}
	}
	if(mousestat()==3)
	{
		if(selected(1,0)==2 || selected(1,0)==3)
		{

			for(int loopx=0;loopx<maxx;loopx++)
			{
				for(int loopy=0;loopy<maxy;loopy++)
				{
					x1=windows[3].x1+4+(loopx*size);
					x2=x1+size-1;
					y1=windows[3].y1+17+(loopy*size);
					y2=y1+size-1;
					if(x>=x1 && x<x2 && y>=y1 && y<y2)
					{
						sx=loopx;
						sy=loopy;
					}

				}
			}


		}
		if(selected(1,0)==1)
		{
			for(int loopx=0;loopx<maxx;loopx++)
			{
				for(int loopy=0;loopy<maxy;loopy++)
				{
					x1=windows[3].x1+4+(loopx*size);
					x2=x1+size-1;
					y1=windows[3].y1+17+(loopy*size);
					y2=y1+size-1;
					if(x>=x1 && x<x2 && y>=y1 && y<y2)
					{
						fillit(loopx,loopy,graph[loopx][loopy],selected(0,0));
						drawgrid();
					}
				}
			}
		}
	}
	if(mousestat()==4 && select==1)
	{
		if(selected(1,0)==2)
		{
			for(int loopx=0;loopx<maxx;loopx++)
			{
				for(int loopy=0;loopy<maxy;loopy++)
				{
					x1=windows[3].x1+4+(loopx*size);
					x2=x1+size-1;
					y1=windows[3].y1+17+(loopy*size);
					y2=y1+size-1;
					if(x>=x1 && x<x2 && y>=y1 && y<y2)
					{
						ex=loopx;
						ey=loopy;
						makeline(sx,sy,ex,ey);
						drawgrid();
					}
				}
			}
		}
		if(selected(1,0)==3)
		{
			for(int loopx=0;loopx<maxx;loopx++)
			{
				for(int loopy=0;loopy<maxy;loopy++)
				{
					x1=windows[3].x1+4+(loopx*size);
					x2=x1+size-1;
					y1=windows[3].y1+17+(loopy*size);
					y2=y1+size-1;
					if(x>=x1 && x<x2 && y>=y1 && y<y2)
					{
						ex=loopx;
						ey=loopy;
						rect(sx,sy,ex,ey);
						drawgrid();
					}
				}
			}
		}
	}
}
}