示例#1
0
polygon_t *
poly_sub (polygon_t * a, polygon_t * b)
{
  polygon_t *d = poly_clip (POLY_DIFFERENCE, 2, a, b);
  polygon_t *r = poly_clip (POLY_INTERSECT, 2, a, d);
  poly_free (d);
  return r;
}
示例#2
0
文件: rendpoly.C 项目: ysangkok/sabre
int project_poly(R_3DPoint *poly, int n, int color, Port_3D &port)
{
  int spoints[RENDMAX];
  int cpoints[RENDMAX];
  int *pnts,i;
  int clip_n = 0;

  if (n > 0 && n < RENDMAX)
    {
      pnts = spoints;
      int min_x = INT_MAX;
      int max_x = INT_MIN;
      int min_y = INT_MAX;
      int max_y = INT_MIN;

      for (i = 0; i < n;i++)
	{
	  port.port2screen(poly[i],pnts,pnts+1);

	  if (port.over_flow)
	    {
	      port.over_flow = 0;
	      return (rend2(poly,n,color,port));
	    }
	  if (*pnts < min_x)
	    min_x = *pnts;
	  if (*pnts > max_x)
	    max_x = *pnts;
	  if (*(pnts + 1) < min_y)
	    min_y = *(pnts + 1);
	  if (*(pnts + 1) > max_y)
	    max_y = *(pnts + 1);
	  pnts += 2;
	}
      if (max_x < port.screen.topLeft.x)
	return 0;
      if (min_x > port.screen.botRight.x)
	return 0;
      if (max_y < port.screen.topLeft.y)
	return 0;
      if (min_y > port.screen.botRight.y)
	return 0;
      int cn;
      if (poly_clip(spoints,cpoints,n,&clip_n,
		    &port.screen))
	{
	  cn = (clip_n + 1) * 2;
	  cpoints[cn - 1] = cpoints[1];
	  cpoints[cn - 2] = cpoints[0];
	  fill_convpoly(cpoints,clip_n + 1,color);
	}
    }
  return clip_n;
}
示例#3
0
/* modified by CJ
Input :
         Argument          |   Meaning
         ---------------------------------------------------------
         pMeta             |   Xarina rectangle meta data
         Index             |   Index of the area. Whether to repeat the first vertex at the end is discussed below.
         nLabels_index     |   Index of pMeta   
         ---------------------------------------------------------   
output : intersection area |   BJ4
*/
static double cal_intersection_area(OD_META * pMeta, int Index, ulong nLabels_index){
    
    int i,tmp_wpst;
    double Matrix = 0;
    poly res;
    tmp_wpst = gMouInfo.mouCtrl[Index].area.numOfVertex;
    
    
    vec_t *s = (vec_t *)malloc( sizeof(vec_t)*tmp_wpst );
    
    for( i = 0 ; i < tmp_wpst ; i++ ){
        s[i].x = gMouInfo.mouCtrl[Index].area.vertex[i].x;
        s[i].y = gMouInfo.mouCtrl[Index].area.vertex[i].y;
    }
    
    poly_t subject = { tmp_wpst, 0 ,s};
    
    vec_t c[4] ={
                    { pMeta[nLabels_index].sPosX, pMeta[nLabels_index].sPosY },
                    { pMeta[nLabels_index].sPosX, pMeta[nLabels_index].ePosY },     
                    { pMeta[nLabels_index].ePosX, pMeta[nLabels_index].ePosY },      
                    { pMeta[nLabels_index].ePosX, pMeta[nLabels_index].sPosY }
               };  
   
    poly_t clipper = { 4, 0, c};    
    res = poly_clip( &subject, &clipper);
    for (i = 0; i < res->len; i++){
        
        if( i != ( res->len-1 ) ){
            Matrix = Matrix + ( res->v[i].x*res->v[i+1].y ) - ( res->v[i].y*res->v[i+1].x );
        } else {
            Matrix = Matrix + ( res->v[i].x*res->v[0].y   ) - ( res->v[i].y*res->v[0].x   );
        }

    }

    Matrix /= 2;
    return ( ( Matrix >= 0 )? Matrix : ( -1*Matrix ) ) ;
    
}
示例#4
0
void poly_next_frame(int16_t *frame)
{
	memset(frame, 0, (sizeof(int16_t) * 2));
	for (register int chan = 0; chan < 2; chan++)
	{
		poly_gen *gen = poly_generators;
		for(register int i = 0; i < poly_max_generators; i++)
		{
			if(gen->init == 1 && gen->mute == 0)
			{
				float val = 0.0;
				float arg_amp = gen->amplitude * gen->matrix[chan];
				switch(gen->wavetype)
				{
				case poly_sine:
					val = poly_sine_func(
						arg_amp, 
						gen->freq, 
						gen->phase);
					break;
				case poly_square:
					val = poly_square_func(
						arg_amp, 
						gen->freq, 
						gen->duty, 
						gen->phase);
					break;
				case poly_saw:
					val = poly_saw_func(
						arg_amp, 
						gen->freq, 
						gen->phase);
					break;
				case poly_triangle:
					val = poly_triangle_func(
						arg_amp, 
						gen->freq, 
						gen->phase);
					break;
				case poly_loopsample:
					val = poly_loopsample_func(
						gen->sample, 	
						arg_amp, 
						gen->freq, 
						gen->phase);
					break;
				case poly_noise:
					val = poly_noise_func(
						arg_amp, 
						gen->freq * gen->noise_mult, 
						&(gen->noise_counter), 
						&(gen->noise_state), 
						gen->noise_tap, 
						gen->noise_size, 
						(chan == 0)); // Only enable shifting if it's #0
					break;
				default:
					DEBUG_MSG("waveform not yet implemented");
					break;
				}
				val = val / (float)poly_max_generators;
				frame[chan] += poly_clip((int16_t)val,POLY_MAX_AMP);
			}
			gen = gen + 1;
		}	
	}
	poly_time++;
}