コード例 #1
0
//--------------------------------------------------------------
// mouse pressed
void mgSimpleDesktop::mouseDown(
  void* source,
  int x,
  int y,
  int modifiers,
  int button)
{
#ifdef WORKED
//  takeKeyFocus();

  mgDimension size;
  getSize(size);

  mgRectangle inside(0, 0, size.m_width, size.m_height);
  if (m_upFrame != NULL)
    m_upFrame->getInsideRect(inside);

  // =-= select entry under point
  y = y - inside.m_y;

  int index = (y/m_lineHeight) + m_scrollPosn;
  if (index < m_entries.length())
  {
    if (m_multiSelect)
    {
      // =-= shift select, cntl select, start of drag select
      // =-= reset all other selections if just click
      mgListEntry* entry = (mgListEntry*) m_entries.getAt(index);
      entry->m_selected = true;
    }
    else
    {
      m_selected = index;
    }
    damage();
  }
#endif
}
コード例 #2
0
ファイル: bullet1.c プロジェクト: devkotasabin/TankWar
void drawbullet(int num)
{
int n;
int x, y,i;
for(i=0;i<MAXBULLET;i++){
x = bullets[num][i]->x;
y = bullets[num][i]->y;
//is the bullet active?
if (!bullets[num][i]->alive) continue;
//draw bullet sprite
for (n=0; n<2; n++)
{
if (inside(x, y, scrollx[n], scrolly[n],
scrollx[n] + SCROLLW - bullet_bmp[n]->w,
scrolly[n] + SCROLLH - bullet_bmp[n]->h))
//draw bullet, adjust for scroll
draw_sprite(buffer, bullet_bmp[num], startx[n] + x-scrollx[n],
starty[n] + y-scrolly[n]);
}
//draw bullet on radar
putpixel(buffer, radarx + x/10, radary + y/12, WHITE);
}
}
コード例 #3
0
void Phy::Axis::moveAng(float ang) {
	float last_ang = angle;

	if (angle > 900) {
		angle = 900;
	}
	else if (angle < -900) {
		angle = -900;
	}

	if (!inside(-450, 450, angle)) {
		collide = false;
	}
	else collide = true;

	angle = ang;
	angular_velocity = (angle - last_ang) / TIMESTEP;

	x_offset = playerheight * sin(angle * 3.1415 / 1800);
	velocity.y = playerheight * (angular_velocity * 3.1415 / 1800) * cos(angle * 3.1415 / 1800);


}
コード例 #4
0
	intersection_context surface_mobius::intersect(const ray &emission_ray) const {
		if (!collision_test(emission_ray)) {
			return null_intersect;
		}

		double ox = emission_ray.origin.x;
		double oy = emission_ray.origin.y;
		double oz = emission_ray.origin.z;
		double dx = emission_ray.dir.x;
		double dy = emission_ray.dir.y;
		double dz = emission_ray.dir.z;
		double R = radius;
		
		double coef_0 = 0, coef_1 = 0, coef_2 = 0, coef_3 = 0;

		coef_0 = ox * ox * oy + oy * oy * oy - 2 * ox * ox * oz - 2 * oy * oy * oz + oy * oz * oz - 2 * ox * oz * R - oy * R * R;
		coef_1 = dy * ox * ox - 2 * dz * ox * ox + 2 * dx * ox * oy + 3 * dy * oy * oy - 2 * dz * oy * oy - 4 * dx * ox * oz - 4 * dy * oy * oz + 2 * dz * oy * oz + dy * oz * oz - 2 * dz * ox * R - 2 * dx * oz * R - dy * R * R;
		coef_2 = 2 * dx * dy * ox - 4 * dx * dz * ox + dx * dx * oy + 3 * dy * dy * oy - 4 * dy * dz * oy + dz * dz * oy - 2 * dx * dx * oz - 2 * dy * dy * oz + 2 * dy * dz * oz - 2 * dx * dz * R;
		coef_3 = dx * dx * dy + dy * dy * dy - 2 * dx * dx * dz - 2 * dy * dy * dz + dy * dz * dz;

		std::vector<double> coef, result;

		coef.push_back(coef_0);
		coef.push_back(coef_1);
		coef.push_back(coef_2);
		coef.push_back(coef_3);

		result = equation_solve(coef, 3);

		for (std::vector<double>::iterator iter = result.begin(); iter != result.end(); ++iter) {
			if (*iter > epsilon && inside(emission_ray.at(*iter))) {
				return intersection_context(*iter);
			}
		}

		return null_intersect;
	}
コード例 #5
0
bool cTileRasterizer::preTile(int tile_x,int tile_y)
{
	Vec2f bary;
	uint32 zMin = mZMax,zMax = mZMin,z;

	// Fixme: Add Tomas' conservative tile test


	int xadd[4] = {0,mTileWidth-1,0,mTileWidth-1};
	int yadd[4] = {0,0,mTileHeight-1,mTileHeight-1};

	// add specific tile code here (to be executed just before the pixels are being traversed)
	for (int i = 0; i < 4; i++) {
		inside(tile_x*mTileWidth + xadd[i],tile_y*mTileHeight + yadd[i]);
		bary = computeBarycentricCoords();
		z = interpolateZ(bary);	
		zMin = MIN2(zMin,z);
		zMax = MAX2(zMax,z);
	}
	zMin = MAX2(mZMin,zMin);	
	zMax = MIN2(mZMax,zMax);	

	return !mDepthUnit->cullTile(zMin,zMax,tile_x*mTileWidth,tile_y*mTileHeight);
}
コード例 #6
0
void cTileRasterizer::rasterizeTriangle(void)
{	
	ASSERT(mAPI);
	//ASSERT(mFrameBuffer);
	ASSERT(mDepthUnit);

#if 0
	mBBox2DMin.debugprint();
	mBBox2DMax.debugprint();
	mTileCoordsMin.debugprint();
	mTileCoordsMax.debugprint();
	printf("\n");
#endif

	// start with brute force traversal of tile inside bbox of triangle: visit every pixel in there
	// loop over all tiles
	for(int byi=mTileCoordsMin.y; byi<mTileCoordsMax.y; byi++)
	{
		for(int bxi=mTileCoordsMin.x; bxi<mTileCoordsMax.x; bxi++)
		{
			// loop over all pixels inside current tiles
			preTile(bxi,byi);
			for(int yi=byi*mTileHeight; yi<(byi+1)*mTileHeight ;yi++)
			{
				for(int xi=bxi*mTileWidth; xi<(bxi+1)*mTileWidth ;xi++)
				{
					if(inside(xi,yi))								// use edge functions for inclusion testing
					{
						perFragment(xi,yi);
					}
				}
			}
			postTile(bxi,byi);
		}
	}
}
コード例 #7
0
// FIND CELL
//-------------------------------------------------------------------------
Index UniformGrid::findCell(const Vector &point, int flags) const {

    const bool acceptGhost = flags&AcceptGhost;

    for (int c=0; c<3; ++c) {
        if (point[c] < m_min[c])
            return InvalidIndex;
        if (point[c] > m_max[c])
            return InvalidIndex;
    }

    Index n[3];
    for (int c=0; c<3; ++c) {
        n[c] = (point[c]-m_min[c])/m_dist[c];
        if (n[c] >= m_numDivisions[c]-1)
            n[c] = m_numDivisions[c]-2;
    }

    Index el = cellIndex(n, m_numDivisions);
    assert(inside(el, point));
    if (acceptGhost || !isGhostCell(el))
        return el;
    return InvalidIndex;
}
コード例 #8
0
float CLevelGraph::farthest_vertex_in_direction(u32 start_vertex_id, const Fvector &start_point, const Fvector &finish_point, u32 &finish_vertex_id, xr_vector<bool> *tpaMarks, bool check_accessability) const
{
	SContour				_contour;
	const_iterator			I,E;
	int						saved_index, iPrevIndex = -1, iNextNode;
	Fvector					temp_point = start_point;
	float					fDistance = start_point.distance_to(finish_point), fCurDistance = 0.f;
	u32						dwCurNode = start_vertex_id;

	while (!inside(vertex(dwCurNode),finish_point) && (fCurDistance < (fDistance + EPS_L))) {
		begin				(dwCurNode,I,E);
		saved_index			= -1;
		contour				(_contour,dwCurNode);
		for ( ; I != E; ++I) {
			iNextNode		= value(dwCurNode,I);
			if (valid_vertex_id(iNextNode) && (iPrevIndex != iNextNode))
				choose_point(start_point,finish_point,_contour, iNextNode,temp_point,saved_index);
		}

		if (saved_index > -1) {
			if (check_accessability && !is_accessible(saved_index))
				return		(fCurDistance);

			fCurDistance	= start_point.distance_to_xz(temp_point);
			iPrevIndex		= dwCurNode;
			dwCurNode		= saved_index;
		}
		else
			return			(fCurDistance);

		if (tpaMarks)
			(*tpaMarks)[dwCurNode]	= true;
		finish_vertex_id	= dwCurNode;
	}
	return					(fCurDistance);
}
コード例 #9
0
ファイル: mgUglyList.cpp プロジェクト: duaneking/SeaOfMemes
//--------------------------------------------------------------
// mouse moved
void mgUglyList::mouseMove(
  void* source,
  int x,
  int y,
  int modifiers)
{
  mgDimension size;
  getSize(size);

  mgRectangle inside(0, 0, size.m_width, size.m_height);
  if (m_upFrame != NULL)
    m_upFrame->getInsideRect(inside);

  // find entry under point
  y = y - inside.m_y;

  int index = (y/m_lineHeight) + m_scrollPosn;
  if (index < m_entries.length())
  {
    m_hover = index;
    damage();
  }
  else m_hover = -1;
}
コード例 #10
0
void reduce_right(int size)
{
 check(inside(size));
 
 if(size==0)
  return;
  
 //overhead
 
 if(overhead_for(count()-size)<=threshold())
 {
  //reset
  
  reset(count()-size,size);
  
  //update
  
  _count-=size;
  
  return;
 }
 
 //save
 
 self buffer;
 
 buffer.attach(*this);
 
 //allocate
 
 allocate(buffer.count()-size);
 
 //move
 
 move(0,buffer,0,count());
}
コード例 #11
0
ファイル: bullet1.c プロジェクト: devkotasabin/TankWar
void updateexplosion(int num)
{
int x, y,i;
for(i=0;i<MAXBULLET;i++){
if (!explosions[num]->alive) continue ;
//draw explosion (maxframe) times
if (explosions[num]->curframe++ < explosions[num]->maxframe)
{
x = explosions[num]->x;
y = explosions[num]->y;
//draw explosion in enemy window
rotate_sprite(buffer, explode_bmp,
x + rand()%10 - 20, y + rand()%10 - 20,
itofix(rand()%255));
//draw explosion in "my" window if enemy is visible
x = scrollx[!num] + SCROLLW/2;
y = scrolly[!num] + SCROLLH/2;
if (inside(x, y,
scrollx[num], scrolly[num],
scrollx[num] + SCROLLW, scrolly[num] + SCROLLH))
{
//but only draw if explosion is active
if (explosions[num]->alive)
rotate_sprite(buffer, explode_bmp,
startx[num]+x-scrollx[num] + rand()%10 - 20,
starty[num]+y-scrolly[num] + rand()%10 - 20,
itofix(rand()%255));
}
}
else
{
explosions[num]->alive = 0;
explosions[num]->curframe = 0;
}
}
}
コード例 #12
0
template <typename T2> void copy(int index,T2* pointer,int size)
{
 check(inside(index,size));
 check(pointer!=nullptr);  
 
 if(size==0)
  return;
 
 //copyable
 
 if(is_copyable<T2>())
 {   
  memcpy(get()+index,pointer,sizeof(T)*size);
  
  return;
 }

 //set
 
 for(int i=0;i<size;i++)
 {
  at(i+index)=pointer[i];
 }
}
コード例 #13
0
ファイル: calc.c プロジェクト: vsis/p_matrix
//******************************************************************************
int get_intersection_line_image (crystal *a, crystal *b){
	if ( (a == NULL) || (b == NULL) ){
		error_msg("get_intersection_line_image(): se recibió uno o más cristales nulos");
	}
	vector *origin, *direction;
	origin = a->position;
	direction = diff(b->position, a->position);
	//variables que representan la cara actual de un voxel, el tipo de plano, y el índice del punto encontrado
	int voxel_face, plane_type, index=0,result; 	
	vector *aux, *inter[2];
	inter[0] = inter[1] = NULL;
	//calcula la intersección de la recta con los 6 planos que contiene las caras del voxel
	for (voxel_face = 0; voxel_face < 6; voxel_face++){
		plane_type = voxel_face / 2; //cada dos caras del voxel se cambia el tipo de plano
		aux = get_intersection_line_plane(plane_type, p_planes[voxel_face], origin, direction);	
		if ( (aux != NULL) && ( inside( aux ) ) ){ //determina si la intersección está dentro de la cara
			inter[index] = aux;
			index++;
			if (index == 2 && equal(inter[0], inter[1]) ){ //si hay dos puntos iguales se ignora el segundo
				index--;
				free(inter[1]);
				inter[1] = NULL;
			}else if(index == 2){ //si hay dos puntos distintos se termina el cálculo.
				break;	// en este punto se podría calcular la intersección.
			}
		}else{
			free( aux );
		}
	}
	
	result = (inter[0] != NULL) && (inter[1] != NULL);
	free ( inter[0] );
	free ( inter[1] );
	free ( direction );
	return result;
}
コード例 #14
0
const bool AxisAlignedBoundingBox::outside(const QVector3D & vertex) const
{
    return !inside(vertex);
}
コード例 #15
0
ファイル: turn.c プロジェクト: quickgold192/oslab1
/*
  dwarf stuff.
*/
void dwarves()
{
    int i, j, k, attack, stick, dtotal;

    /* See if dwarves allowed here */
    if (g.newloc == 0 || forced(g.newloc) || g.loc_attrib[g.newloc] & NOPIRAT)
        return;

    /* See if dwarves are active. */
    if (!g.dflag) {
        if (inside(g.newloc))
            ++g.dflag;
        return;
    }
    /* If first close encounter (of 3rd kind) */
    if (g.dflag == 1) {
        if (!inside(g.newloc) || pct(85))
            return;
        ++g.dflag;

        /* kill 0, 1 or 2 of the dwarfs */
        for (i = 1; i < 3; ++i)
            if (pct(50))
                g.dloc[(ranz(DWARFMAX - 1)) + 1] = 0;

        /* If any of the survivors is at location, use alternate choise */
        for (i = 1; i <= DWARFMAX; ++i) {
            if (g.dloc[i] == g.newloc)
                g.dloc[i] = g.daltloc;
            g.odloc[i] = g.dloc[i];
        }
        rspeak(3);
        drop(AXE, g.newloc);
        return;
    }
    /* Things are in full swing.  Move each dwarf at random, except if
       he's seen us then he sticks with us.  Dwarfs never go to
       locations outside or meet the bear or following him into dead
       end in maze.  And of couse, dead dwarves don't do much of
       anything.  */

    dtotal = attack = stick = 0;
    for (i = 1; i <= DWARFMAX; ++i) {
        if (g.dloc[i] == 0)
            continue;
        /* Move a dwarf at random.  we don't have a matrix around to do
           it as in the original version... */
        do
            j = ranz(106) + 15;
        /* allowed area */
        while (j == g.odloc[i] || j == g.dloc[i]
                || g.loc_attrib[j] & NOPIRAT);

        if (j == 0)
            bug(36);
        g.odloc[i] = g.dloc[i];
        g.dloc[i] = j;

        g.dseen[i] = ((g.dseen[i] && inside(g.newloc))
                      || g.dloc[i] == g.newloc
                      || g.odloc[i] == g.newloc);

        if (g.dseen[i]) {
            g.dloc[i] = g.newloc;
            if (i == DWARFMAX)
                dopirate();
            else {
                ++dtotal;
                if (g.odloc[i] == g.dloc[i]) {
                    ++attack;
                    if (g.knfloc >= 0)
                        g.knfloc = g.newloc;
                    if (ranz(1000) < (45 * (g.dflag - 2)))
                        ++stick;
                }
            }
        }
    }

    /* Now we know shat's happing, let's tell the poor sucker about it */
    if (dtotal == 0)
        return;
    if (dtotal > 1)
        printf("There are %d threatening little dwarves in the room with you!\n", dtotal);
    else
        rspeak(4);
    if (attack == 0)
        return;
    if (g.dflag == 2)
        ++g.dflag;
    if (attack > 1) {
        printf("%d of them throw knives at you!!\n", attack);
        k = 6;
    } else {
        rspeak(5);
        k = 52;
    }
    if (stick <= 1) {
        rspeak(stick + k);
        if (stick == 0)
            return;
    } else
        printf("%d of them get you !!!\n", stick);
    g.oldloc2 = g.newloc;
    death();
    return;
}
コード例 #16
0
ファイル: geofence.cpp プロジェクト: 1002victor/Firmware
bool Geofence::inside(const struct vehicle_global_position_s &global_position)
{
	return inside(global_position.lat, global_position.lon, global_position.alt);
}
コード例 #17
0
ファイル: geofence.cpp プロジェクト: 1002victor/Firmware
bool Geofence::inside(const struct vehicle_global_position_s &global_position, float baro_altitude_amsl)
{
	return inside(global_position.lat, global_position.lon, baro_altitude_amsl);
}
コード例 #18
0
// GET INTERPOLATOR
//-------------------------------------------------------------------------
GridInterface::Interpolator RectilinearGrid::getInterpolator(Index elem, const Vector &point, DataBase::Mapping mapping, GridInterface::InterpolationMode mode) const {

   vassert(inside(elem, point));

#ifdef INTERPOL_DEBUG
   if (!inside(elem, point)) {
      return Interpolator();
   }
#endif

   if (mapping == DataBase::Element) {
       std::vector<Scalar> weights(1, 1.);
       std::vector<Index> indices(1, elem);

       return Interpolator(weights, indices);
   }

   std::array<Index,3> n = cellCoordinates(elem, m_numDivisions);
   std::array<Index,8> cl = cellVertices(elem, m_numDivisions);

   Vector corner0(m_coords[0][n[0]], m_coords[1][n[1]], m_coords[2][n[2]]);
   Vector corner1(m_coords[0][n[0]+1], m_coords[1][n[1]+1], m_coords[2][n[2]+1]);
   const Vector diff = point-corner0;
   const Vector size = corner1-corner0;

   const Index nvert = 8;
   std::vector<Index> indices((mode==Linear || mode==Mean) ? nvert : 1);
   std::vector<Scalar> weights((mode==Linear || mode==Mean) ? nvert : 1);

   if (mode == Mean) {
       const Scalar w = Scalar(1)/nvert;
       for (Index i=0; i<nvert; ++i) {
           indices[i] = cl[i];
           weights[i] = w;
       }
   } else if (mode == Linear) {
       vassert(nvert == 8);
       for (Index i=0; i<nvert; ++i) {
           indices[i] = cl[i];
       }
       Vector ss = diff;
       for (int c=0; c<3; ++c) {
           ss[c] /= size[c];
       }
       weights[0] = (1-ss[0])*(1-ss[1])*(1-ss[2]);
       weights[1] = ss[0]*(1-ss[1])*(1-ss[2]);
       weights[2] = ss[0]*ss[1]*(1-ss[2]);
       weights[3] = (1-ss[0])*ss[1]*(1-ss[2]);
       weights[4] = (1-ss[0])*(1-ss[1])*ss[2];
       weights[5] = ss[0]*(1-ss[1])*ss[2];
       weights[6] = ss[0]*ss[1]*ss[2];
       weights[7] = (1-ss[0])*ss[1]*ss[2];
   } else {
      weights[0] = 1;

      if (mode == First) {
         indices[0] = cl[0];
      } else if(mode == Nearest) {
          Vector ss = diff;
          int nearest=0;
          for (int c=0; c<3; ++c) {
              nearest <<= 1;
              ss[c] /= size[c];
              if (ss[c] < 0.5)
                  nearest |= 1;
          }
          indices[0] = cl[nearest];
      }
   }

   return Interpolator(weights, indices);

}
コード例 #19
0
ファイル: kvld.cpp プロジェクト: mdqyy/KVLD
VLD::VLD(const ImageScale& series, T const& P1, T const& P2) : contrast(0.0) {
	//============== initializing============//
	principleAngle.fill(0);
	descriptor.fill(0);
	weight.fill(0);

	begin_point[0]=P1.x;
	begin_point[1]=P1.y;
	end_point[0]=P2.x;
	end_point[1]=P2.y;

	float dy= float(end_point[1]- begin_point[1]), dx= float(end_point[0]- begin_point[0]);
	  distance=sqrt(dy*dy+dx*dx);

	if (distance==0)
		std::cerr<<"Two SIFT points have the same coordinate"<<std::endl;

	float radius=std::max(distance/float(dimension+1), 2.0f);//at least 2

	double mainAngle= get_orientation();//absolute angle

	int image_index=series.getIndex(radius);

	const Image<float> & ang = series.angles[image_index];
	const Image<float> & m   = series.magnitudes[image_index];
	double ratio=series.ratios[image_index];
  
 // std::cout<<std::endl<<"index of image "<<radius<<" "<<image_index<<" "<<ratio<<std::endl;
	
  int w=m.Width() ,h=m.Height();
	float r=float(radius/ratio);//series.radius_size;
	float sigma2=r*r;
	//======Computing the descriptors=====//

	for (int i=0;i<dimension; i++){
		double statistic[binNum];
    std::fill_n(statistic, binNum, 0.0);

		float xi= float(begin_point[0]+ float(i+1)/(dimension+1)*(dx));
		float yi= float(begin_point[1]+ float(i+1)/(dimension+1)*(dy));
		yi/=float(ratio);
		xi/=float(ratio);
		
    for (int y=int(yi-r);y<=int(yi+r+0.5);y++){
			for (int x=int(xi-r);x<=int(xi+r+0.5);x++){
				float d=point_distance(xi,yi,float(x),float(y));
				if (d<=r && inside(w,h,x,y,1)){
					//================angle and magnitude==========================//
					double angle;
					if (ang(y,x)>=0)
						angle=ang(y,x)-mainAngle;//relative angle
					else angle=0.0;

					//cout<<angle<<endl;
					while (angle<0)
						angle +=2*PI;
					while (angle>=2*PI)
						angle -=2*PI;

					//===============principle angle==============================//
					int index=int(angle*binNum/(2*PI)+0.5);

					double Gweight=exp(-d*d/4.5/sigma2)*(m(y,x));
          // std::cout<<"in number "<<image_index<<" "<<x<<" "<<y<<" "<<m(y,x)<<std::endl;
					if (index<binNum)
						statistic[index]+=Gweight;
					else // possible since the 0.5
						statistic[0]+=Gweight;

					//==============the descriptor===============================//
					int index2=int(angle*subdirection/(2*PI)+0.5);
					assert(index2>=0 && index2<=subdirection);

					if (index2<subdirection)
						descriptor[subdirection*i+index2]+=Gweight;
					else descriptor[subdirection*i]+=Gweight;// possible since the 0.5
				}
			}
		}
		//=====================find the biggest angle of ith SIFT==================//
		int index,second_index;
		max(statistic,weight[i],binNum,index,second_index);
		principleAngle[i]=index;
	}

  normalize_weight(descriptor);
 
  contrast= std::accumulate(weight.begin(), weight.end(), 0.0);
	contrast/=distance/ratio;
	normalize_weight(weight);
}
コード例 #20
0
void ofxDraggable::touchMoved(ofTouchEventArgs &touch) {
    if (!touches.empty()) {
        vector<ofTouchEventArgs>::iterator iter;
        for (iter=touches.begin(); iter!=touches.end(); iter++) {
            if (iter->id == touch.id) {
                break;
            }
        }
        
        
        if (iter==touches.end()) {
            cout << "ofxDraggable::touchMoved - can't find touch" << endl;
        } else {
            switch (touches.size()) {
                case 1:
                    if (inside(touch)) {
                        mat.postMult(ofMatrix4x4::newTranslationMatrix(ofVec2f(touch.x,touch.y)-ofVec2f(iter->x,iter->y)));
                        *iter = touch;
                    } else {
                        touchUp(touch);
                    }
                    break;
                case 2: {
                    ofVec2f p2(touch.x,touch.y);
                    ofVec2f p1(iter->x,iter->y);
                    *iter = touch;
                    ofTouchEventArgs &second = touches[1-distance(touches.begin(), iter)];
                    ofVec2f q(second.x,second.y);
                    ofVec2f qp1 = q-p1;
                    ofVec2f qp2 = q-p2;
                    
                                        
                    ofVec2f trans(0.5*(qp1-qp2));
                    float scl = qp2.length()/qp1.length();
                    float rot = (atan2(qp2.y, qp2.x)-atan2(qp1.y, qp1.x))*180.0f/PI;
                    
                    ofVec2f anchor = mat.getInverse().preMult(ofVec3f(0.5*(p1+q)));
                    
                    ofMatrix4x4 temp(mat);
                    temp.preMult(ofMatrix4x4::newScaleMatrix(scl, scl, 1.0));  
                    temp.preMult(ofMatrix4x4::newRotationMatrix(rot, ofVec3f(0,0,1.0)));
                    
                    ofVec2f vec = temp.preMult(ofVec3f(anchor))-mat.preMult(ofVec3f(anchor));
                    //    cout << anchor <<"\t" << vec << "\t" << scl << endl;
                    
                    temp.postMult(ofMatrix4x4::newTranslationMatrix(trans-vec));
                    mat=temp;
                    
                    
                    
                    
                    
                } break;
                default:
                    break;
            }
        }
        
        
    }
};
コード例 #21
0
// ---------------------------------------------------------------------------
// 
// ------------
void bXMapLineUp::make(){
bGenericGeoElement* o;
ivx_rect			vr,vrb,bnd;
bArray				arr(*_gapp->selMgr()->elements());
int					i,j,ko,kv;
int					imax,jmax,n=0;
insidePtr			inside;
ivertices			*ref,*vxs;
i2dvertex			p,lp;
bool				end=false;
int					hd=round(Measure_d2i(_gapp,_hd));
int					vd=round(Measure_d2i(_gapp,_vd));

	if(_use_surf){
		inside=ivx_in_ivs;
		_gapp->cntMgr()->elements()->get(1,&o);
		o->getBounds(&bnd);
		o->getVertices(&ref);
		imax=1+(bnd.bottom-bnd.top)/vd;
		jmax=1+(bnd.right-bnd.left)/hd;
	}
	else{
		inside=dummy_ivx_in_ivs;
		arr.get(1,&o);
		o->getBounds(&bnd);
		vr=bnd;
		o->getVertices(&vxs);
		n+=vxs->nv;
		for(i=2;i<arr.count();i++){
			arr.get(i,&o);
			o->getBounds(&vrb);
			ivr_union(&vrb,&vr,&bnd);
			vr=bnd;
			o->getVertices(&vxs);
			n+=vxs->nv;
		}
		ref=NULL;
		if(_kind==kXMapLineUpKindLine){
			imax=ceil((double)n/_nb);
			jmax=_nb;
		}
		else{
			imax=_nb;
			jmax=ceil((double)n/_nb);	
		}
	}
		
	_gapp->layersMgr()->SetObjInvalidation(false);	
	
char			msg[__MESSAGE_STRING_LENGTH_MAX__];
char			ttl[__MESSAGE_STRING_LENGTH_MAX__];
    get_localized_name(ttl,getbundle());
	message_string(kMsgProgress,msg,1);
bProgressWait	wt(ttl,msg,true,true,arr.count());	

bEventLog	log(_gapp,this);
	
	ko=1;
	kv=0;
	arr.get(ko,&o);
	o->getVertices(&vxs);
	lp.h=bnd.left;
	lp.v=bnd.top;
	for(i=0;i<imax;i++){
		for(j=0;j<jmax;j++){
			p.h=bnd.left+j*hd;
			p.v=bnd.top+i*vd;
			if(!inside(&p,ref,1)){
				continue;
			}
			lp=p;
			vxs->vx.vx2[kv]=p;
			kv++;
			if(kv==vxs->nv){
				kv=0;
				ko++;
				o->setVertices(vxs);
				if(!wt.set_progress(ko)){
					end=true;
					break;
				}
				if(!arr.get(ko,&o)){
					end=true;
					break;
				}
				o->getVertices(&vxs);
			}
		}
		if(end){
			break;
		}
	}
	
	if(!end){
		if(kv<vxs->nv){
			for(i=kv;i<vxs->nv;i++){
				vxs->vx.vx2[kv]=lp;
			}
			o->setVertices(vxs);
			ko++;
		}
		for(i=ko;i<=arr.count();i++){
			if(!wt.set_progress(i)){
				break;
			}	
			arr.get(i,&o);
			o->getVertices(&vxs);
			for(j=0;j<vxs->nv;j++){
				vxs->vx.vx2[j]=lp;
			}
			o->setVertices(vxs);
		}
	}
	_gapp->layersMgr()->SetObjInvalidation(true);	
	log.close();
}
コード例 #22
0
ファイル: mainmenu.cpp プロジェクト: wolfman-x/mechcommander2
void MainMenu::update()
{

	if ( bDrawBackground || MPlayer || LogisticsData::instance->isSingleMission() )
	{
		getButton( MM_MSG_SAVE )->disable( true );
	}
	else
		getButton( MM_MSG_SAVE )->disable( false );

	getButton( MM_MSG_MULTIPLAYER )->disable( true );

	if ( introMovie )
	{
		userInput->mouseOff();

		if (userInput->getKeyDown(KEY_SPACE) || userInput->getKeyDown(KEY_ESCAPE) || userInput->getKeyDown(KEY_LMOUSE))
		{
			introMovie->stop();
		}

		bool result = introMovie->update();
		if (result)
		{
			
			//Movie's Over.
			//Whack it.
			delete introMovie;
			introMovie = NULL;
		}

		return;
	}

	if (!musicStarted)
	{
		musicStarted = true;
		soundSystem->setMusicVolume( prefs.MusicVolume );
		soundSystem->playDigitalMusic(tuneId);
	}

	if ( endAnim.isDone() )
	{
		status = endResult;
	}

	if ( bDrawMechlopedia )
	{
		mechlopedia->update();
		if ( mechlopedia->getStatus() == NEXT )
		{
			beginFadeIn( 0 );
			bDrawMechlopedia = 0;
			if ( !bDrawBackground )
				status = NEXT;
		}
		return;
	}

	if ( bOptions )
	{
		OptionsScreenWrapper::status_type result = optionsScreenWrapper->update();
		if (result == OptionsScreenWrapper::opt_DONE)
		{
			optionsScreenWrapper->end();
			bOptions = 0;
		}

		return;
	}

	if ( (bSave || bLoad || bLoadCampaign) && endAnim.isDone() )
	{
		LogisticsSaveDialog::instance()->update();

		if ( LogisticsSaveDialog::instance()->getStatus() == LogisticsScreen::YES 
			&& LogisticsSaveDialog::instance()->isDone() )
		{
			
			char name[1024];
			strcpy( name, savePath );
			strcat( name, LogisticsSaveDialog::instance()->getFileName() );
			int index = strlen( name ) - 4;
			if ( _stricmp( &name[index], ".fit" ) !=0 ) 
				strcat( name, ".fit" );

			
			FitIniFile file;
			if ( bSave )
			{
				// make sure the save game directory exists, if not create it
				CreateDirectory( savePath, NULL );

				if ( NO_ERR != file.createWithCase( name ) )
				{
					char errorStr[1024];
					sprintf( errorStr, "couldn't open the file %s", name );
					Assert( 0, 0, errorStr );
				}
				else
				{
					LogisticsData::instance->save( file );
					LogisticsSaveDialog::instance()->end();
					file.close();
				}
				bSave = bLoad = 0;
				status = NEXT;
				

			}
			else if ( bLoadCampaign )
			{
				LogisticsData::instance->startNewCampaign( LogisticsSaveDialog::instance()->getFileName());
				status = endResult = RESTART;
//				background.beginFadeOut( 1.0f );
//				beginFadeOut( 1.0f );
				bLoadCampaign = 0;
			}
			else
			{
				if ( NO_ERR != file.open( name ) )
				{
					char errorStr[1024];
					sprintf( errorStr, "couldn't open the file %s", name );
					Assert( 0, 0, errorStr );
				}
				else
					LogisticsData::instance->load( file );
				LogisticsSaveDialog::instance()->end();
				bSave = bLoad = 0;
				status = RESTART;
				file.close();

			}
		}
		else if ( LogisticsSaveDialog::instance()->getStatus() == LogisticsScreen::NO &&
			LogisticsSaveDialog::instance()->isDone())
		{
			LogisticsSaveDialog::instance()->end();
			bSave = bLoad = bLoadCampaign = 0 ;
			if ( !bDrawBackground )
				status = NEXT;
			else
			{
				beginAnim.begin();
				endAnim.end();
			}
		}
		return;
	}
	else if ( bLoadSingle && endAnim.isDone())
	{
		singleLoadDlg.update();
		if ( singleLoadDlg.isDone() )
		{
			if ( singleLoadDlg.getStatus() == YES )
			{
				const char* pName = singleLoadDlg.getMapFileName();
				if (pName)
				{
					LogisticsData::instance->setSingleMission( pName );
					status = SKIPONENEXT;
				}
			}

			bLoadSingle = 0;
			beginAnim.begin();
			endAnim.end();
		}
	}

	else if ( promptToQuit )
	{
		LogisticsOKDialog::instance()->update();
		{
			if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::YES )
			{
				soundSystem->playDigitalSample( LOG_EXITGAME );
				gos_TerminateApplication();
				promptToQuit = 0;

			}
			else if ( LogisticsOKDialog::instance()->getStatus() == LogisticsScreen::NO)
			{
				if ( LogisticsOKDialog::instance()->isDone() )
					promptToQuit = 0;
			}

			

		}
	}
	else if ( bLegal )
	{
		LogisticsLegalDialog::instance()->update();
		if ( LogisticsLegalDialog::instance()->isDone() )
		{
			LogisticsLegalDialog::instance()->end();
			bLegal = 0;
		}
	}
	else if ( bHostLeftDlg )
	{
		LogisticsOneButtonDialog::instance()->update();
		if ( LogisticsOneButtonDialog::instance()->isDone() )
		{
			LogisticsOneButtonDialog::instance()->end();
			bHostLeftDlg = 0;
		}

		if ( MPlayer ) // has to be done, but can't be done when initialized
		{
			MPlayer->closeSession();
			delete MPlayer;
			MPlayer = NULL;
		}
	}
	else if ( promptToDisconnect )
	{
		LogisticsOKDialog::instance()->update();
		if ( LogisticsOKDialog::instance()->isDone() )
		{
			if ( YES == LogisticsOKDialog::instance()->getStatus() )
			{
				if ( MPlayer )
				{
					MPlayer->closeSession();
					delete MPlayer;
					MPlayer = NULL;
				}
				long oldRes = endResult;
				endResult = 0;

				handleMessage( oldRes, oldRes );

				setDrawBackground( true );
			}
			else
				handleMessage( NEXT, NEXT );
			
			promptToDisconnect = 0;
		}
	}
	else
	{
		if ( bDrawBackground  )
		{
			if ( !intro.animObjects[0].isDone() )
			{
				intro.update();
				background.update();
				if (userInput->getKeyDown(KEY_ESCAPE) || (Environment.Renderer == 3))
				{
					introOver = true;
					userInput->mouseOn();
					soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );

				}
				else if ( !introOver )
					return;
			}
			else
			{
				background.update();
				if ( !introOver )
					soundSystem->playDigitalSample( LOG_MAINMENUBUTTON );

				introOver = true;
				userInput->mouseOn();

			}
		}

		beginAnim.update();
		endAnim.update();

		LogisticsScreen::update();
		if ( (!bLoadSingle) && userInput->isLeftClick() && !inside( userInput->getMouseX(), userInput->getMouseY() ) )
		{
			handleMessage( 0, MM_MSG_RETURN_TO_GAME );
		}
	}
}
コード例 #23
0
ファイル: Cylinder.cpp プロジェクト: kozo2/ecell4
Real CylindricalSurface::distance(const Real3& coord) const
{
    return inside().distance(coord); //XXX: This is too slow.
}
コード例 #24
0
ファイル: Frustum.cpp プロジェクト: priyananda/student
bool Frustum::cull(const Point &a, const Point &b, const Point &c, const Point &d) const
{
	return inside(a) || inside(b) || inside(c) || inside(d);
}
コード例 #25
0
ファイル: GcScopeBar.cpp プロジェクト: cernst72/GoldenCheetah
void
GcScopeButton::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.save();
    painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing, true);

    // widget rectangle
    QRectF body(0,0,width(), height());
    QRectF off(0,1,width(), height());
    QRectF inside(0,2,width(), height()-4);

    QPainterPath clip;
    clip.addRect(inside);
    painter.setClipPath(clip);
    painter.setPen(Qt::NoPen);

    if (checked && underMouse()) {
        painter.setBrush(QBrush(QColor(150,150,150)));     
        painter.drawRoundedRect(body, 19, 11);
        if (highlighted) {
            QColor over = GColor(CCALCURRENT);
            over.setAlpha(180);
            painter.setBrush(over);
            painter.drawRoundedRect(body, 19, 11);
        }
        if (red) {
            QColor over = QColor(Qt::red);
            over.setAlpha(180);
            painter.setBrush(over);
            painter.drawRoundedRect(body, 19, 11);
        }
    } else if (checked && !underMouse()) {
        painter.setBrush(QBrush(QColor(120,120,120)));     
        painter.drawRoundedRect(body, 19, 11);
        if (highlighted) {
            QColor over = GColor(CCALCURRENT);
            over.setAlpha(180);
            painter.setBrush(over);
            painter.drawRoundedRect(body, 19, 11);
        }
        if (red) {
            QColor over = QColor(Qt::red);
            over.setAlpha(180);
            painter.setBrush(over);
            painter.drawRoundedRect(body, 19, 11);
        }
    } else if (!checked && underMouse()) {
        painter.setBrush(QBrush(QColor(180,180,180)));     
        painter.drawRoundedRect(body, 19, 11);
    } else if (!checked && !underMouse()) {
    }

    // now paint the text
    // don't do all that offset nonsense for flat style
    // set fg checked and unchecked colors
    QColor checkedCol(240,240,240), uncheckedCol(30,30,30,200);
    if (!GCColor::isFlat()) {

        // metal style
        painter.setPen((underMouse() || checked) ? QColor(50,50,50) : Qt::white);
        painter.drawText(off, text, Qt::AlignVCenter | Qt::AlignCenter);

    } else {

        // adjust colors if flat and dark
        if (GCColor::luminance(GColor(CCHROME)) < 127) {
            // dark background so checked is white and unchecked is light gray
            checkedCol = QColor(Qt::white);
            uncheckedCol = QColor(Qt::lightGray);
        }
    }

    // draw the text
    painter.setPen((underMouse() || checked) ? checkedCol : uncheckedCol);
    painter.drawText(body, text, Qt::AlignVCenter | Qt::AlignCenter);
    painter.restore();
}
コード例 #26
0
ファイル: turn.c プロジェクト: quickgold192/oslab1
/*
  special time limit stuff...
*/
int stimer()
{
    int i, spk;
    static int clock3;

    g.foobar = g.foobar > 0 ? -g.foobar : 0;
    g.combo = g.combo > 0 ? -g.combo : 0;
    if (g.turns > 310 && g.abbnum != 10000 && !g.terse)
        rspeak(273);

    /* Bump all the right clocks for reconning battery life and closing */
    if (g.closed) {
        clock3--;
        if (clock3 == 0) {
            g.prop[PHONE] = 0;
            g.prop[BOOTH] = 0;
            rspeak(284);
        } else if (clock3 < -7) {
            rspeak(254);
            normend();
            return (TRUE);
        }
    }
    if (g.tally == 0 && inside(g.loc) && g.loc != Y2)
        --g.clock;
    if (g.clock == 0) {
        /* Start closing the cave */
        g.prop[GRATE] = 0;
        biton(GRATE, LOCKBT);
        bitoff(GRATE, OPENBT);
        g.prop[FISSURE] = 0;
        g.prop[TDOOR] = 0;
        biton(TDOOR, LOCKBT);
        bitoff(TDOOR, OPENBT);
        g.prop[TDOOR2] = 0;
        biton(TDOOR2, LOCKBT);
        bitoff(TDOOR2, OPENBT);
        for (i = 1; i <= DWARFMAX; ++i) {
            g.dseen[i] = FALSE;
            g.dloc[i] = 0;
        }
        move(TROLL, 0);
        move((TROLL + MAXOBJ), 0);
        move(TROLL2, plac[TROLL]);
        move((TROLL2 + MAXOBJ), fixd[TROLL]);
        juggle(CHASM);
        if (g.prop[BEAR] != 3)
            destroy(BEAR);
        g.prop[CHAIN] = 0;
        g.fixed[CHAIN] = 0;
        g.prop[AXE] = 0;
        g.fixed[AXE] = 0;
        rspeak(129);
        g.clock = -1;
        g.closing = TRUE;
        return (FALSE);
    }
    if (g.clock < 0)
        --g.clock2;
    if (g.clock2 == 0) {
        /* Set up storage room... and close the cave... */
        g.prop[BOTTLE] = put(BOTTLE, 115, 8);
        g.holder[BOTTLE] = WATER;
        g.place[WATER] = -BOTTLE;
        g.hlink[WATER] = 0;
        bitoff(BOTTLE, OPENBT);
        g.prop[PLANT] = put(PLANT, 115, 0);
        g.prop[OYSTER] = put(OYSTER, 115, 0);
        g.prop[LAMP] = put(LAMP, 115, 0);
        g.prop[ROD] = put(ROD, 115, 0);
        g.prop[DWARF] = put(DWARF, 115, 0);
        g.loc = 115;
        g.oldloc = 115;
        g.newloc = 115;
        /* Leave the grate with normal (non-negative property). */
        put(GRATE, 116, 0);
        biton(GRATE, LOCKBT);
        bitoff(GRATE, OPENBT);
        g.prop[SNAKE] = put(SNAKE, 116, 1);
        g.prop[BIRD] = put(BIRD, 116, 1);
        g.prop[CAGE] = put(CAGE, 116, 0);
        g.prop[ROD2] = put(ROD2, 116, 0);
        g.prop[PILLOW] = put(PILLOW, 116, 0);

        g.prop[BOOTH] = put(BOOTH, 116, -3);
        g.fixed[BOOTH] = 115;
        g.prop[PHONE] = put(PHONE, 212, -4);

        g.prop[MIRROR] = put(MIRROR, 115, 0);
        g.fixed[MIRROR] = 116;
        g.prop[BOOK2] = put(BOOK2, 115, 0);

        for (i = 1; i < MAXOBJ; ++i) {
            if (toting(i) && enclosed(i))
                extract(i);
            if (toting(i))
                destroy(i);
        }
        rspeak(132);
        g.closed = TRUE;
        clock3 = 20 + ranz(20);
        newtravel = TRUE;
        return (TRUE);
    }
    if (g.prop[LAMP] == 1)
        --g.limit;
    if (g.limit == 0) {
        --g.limit;
        g.prop[LAMP] = 0;
        if (here(LAMP))
            rspeak(184);
        return (FALSE);
    }
    if (g.limit < 0 && outside(g.loc)) {
        rspeak(185);
        normend();
        return (TRUE);
    }
    if (g.limit <= 40) {
        if (g.lmwarn || !here(LAMP))
            return (FALSE);
        g.lmwarn = TRUE;
        spk = 187;
        if (g.prop[BATTERIES] == 1)
            spk = 323;
        if (g.place[BATTERIES] == 0)
            spk = 183;
        if (g.prop[VEND] == 1)
            spk = 189;
        rspeak(spk);
        return (FALSE);
    }
    return (FALSE);
}
コード例 #27
0
ファイル: beam.c プロジェクト: ProjectAsura/lucille
/*
 * Clipper
 */
void
clip(
          point2d_t   *outer_vlist_out,       /* [out]    */
          int         *outer_len_inout,       /* [out]    */
          point2d_t   *inner_vlist_out,       /* [out]    */
          int         *inner_len_inout,       /* [out]    */
    const point2d_t   *vlist_in,
          int          len_in,
    const plane2d_t   *clip_plane)
{

    int                j;
    ri_float_t         t;
    point2d_t         *s_ptr, *p_ptr;
    point2d_t          newv;

    /* start with last vertex.    */
    s_ptr = (point2d_t *)&vlist_in[len_in - 1];    

    for (j = 0; j < len_in; j++) {

        p_ptr = (point2d_t *)&vlist_in[j];    /* current vertex    */

        printf("p ptx = %f, %f\n", (*p_ptr)[0], (*p_ptr)[1]);

        if (inside( (*p_ptr), clip_plane )) {

            if (inside( (*s_ptr), clip_plane )) {

                output(inner_vlist_out, inner_len_inout, (*p_ptr) );

                /* No outer */

            } else {
    
                t = intersect(newv, (*s_ptr), (*p_ptr), clip_plane);

                printf("t = %f, new = %f, %f, p = %f, %f\n",
                    t, newv[0], newv[1], (*p_ptr)[0], (*p_ptr)[1]);

                if (t < 1.0) {  /* If t == 1.0, don't output newv */
                    printf("IO, output new\n");
                    output(inner_vlist_out, inner_len_inout, newv);
                }
                output(inner_vlist_out, inner_len_inout, (*p_ptr));

                output(outer_vlist_out, outer_len_inout, newv);
            
            }

        } else {

            if (inside( (*s_ptr), clip_plane) ) {

                t = intersect(newv, (*s_ptr), (*p_ptr), clip_plane);

                printf("t = %f, new = %f, %f, p = %f, %f\n",
                    t, newv[0], newv[1], (*p_ptr)[0], (*p_ptr)[1]);

                output(outer_vlist_out, outer_len_inout, newv);
                output(outer_vlist_out, outer_len_inout, (*p_ptr));

                if (t > 0.0) {  /* If t == 0, don't output newv */
                    printf("OI, output new\n");
                    output(inner_vlist_out, inner_len_inout, newv);
                }

            } else {

                output(outer_vlist_out, outer_len_inout, (*p_ptr) );

            }

        }

        s_ptr = p_ptr;
    }
}
コード例 #28
0
    void operator()(MeshType const & input_mesh,
                    MeshType const & output_mesh,
                    viennagrid_plc plc_output_mesh,
                    PointType const & N)
    {
      typedef viennagrid::result_of::const_element_range<MeshType>::type ConstElementRangeType;
      typedef viennagrid::result_of::iterator<ConstElementRangeType>::type ConstElementRangeIterator;

      viennagrid::result_of::element_copy_map<>::type copy_map(output_mesh, false);

      ConstElementRangeType triangles( input_mesh, 2 );
      for (ConstElementRangeIterator tit = triangles.begin(); tit != triangles.end(); ++tit)
      {
        ElementType v[3];
        PointType p[3];
        double dp[3];

        for (int pi = 0; pi != 3; ++pi)
        {
          v[pi] = viennagrid::vertices(*tit)[pi];
          p[pi] = viennagrid::get_point( v[pi] );

          dp[pi] = viennagrid::inner_prod( p[pi], N );
        }

        if ( !inside(dp[0]) && !inside(dp[1]) && !inside(dp[2]) )
        {
          // all points outside -> ignore
          continue;
        }

        int on_plane_count = 0;
        for (int pi = 0; pi != 3; ++pi)
          if ( on_plane(dp[pi]) )
            ++on_plane_count;

        if (on_plane_count == 3)
          continue;

        if (on_plane_count == 2)
        {
//           std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!  on_plane_count = 2" << std::endl;
          int not_on_plane_index = !on_plane(dp[0]) ? 0 : !on_plane(dp[1]) ? 1 : 2;
          if ( inside(dp[not_on_plane_index]) )
          {
            copy_map(*tit);

            int oi0 = (not_on_plane_index == 0) ? 1 : 0;
            int oi1 = (not_on_plane_index == 2) ? 1 : 2;

            add_line(copy_map(v[oi0]), copy_map(v[oi1]));
          }
//           else
//             std::cout << "   outside -> skipping" << std::endl;
          continue;
        }

        if (on_plane_count == 1)
        {
//           std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!  on_plane_count = 1" << std::endl;
          int on_plane_index = on_plane(dp[0]) ? 0 : on_plane(dp[1]) ? 1 : 2;
          int oi0 = (on_plane_index == 0) ? 1 : 0;
          int oi1 = (on_plane_index == 2) ? 1 : 2;

          if ( !inside(dp[oi0]) && !inside(dp[oi1]) )
            continue;

          if ( inside(dp[oi0]) && inside(dp[oi1]) )
          {
            copy_map(*tit);
            continue;
          }

          // oi0 is inside
          if ( !inside(dp[oi0]) )
            std::swap(oi0, oi1);

          ElementType v_ = get_vertex(output_mesh, N, v[oi0], v[oi1]);
          viennagrid::make_triangle( output_mesh, copy_map(v[on_plane_index]), copy_map(v[oi0]), v_);

          add_line(v_, copy_map(v[on_plane_index]));
          continue;
        }


        if ( inside(dp[0]) && inside(dp[1]) && inside(dp[2])  )
        {
          // all points inside -> copy
          copy_map(*tit);
          continue;
        }

        int pos_count = 0;
        for (int pi = 0; pi != 3; ++pi)
          if ( inside(dp[pi]) )
            ++pos_count;

        int pi = (dp[0]*dp[1] > 0) ? 2 : (dp[1]*dp[2] > 0) ? 0 : 1;
        int oi0 = (pi == 0) ? 1 : 0;
        int oi1 = (pi == 2) ? 1 : 2;

        ElementType v1_ = get_vertex(output_mesh, N, v[pi], v[oi0]);
        ElementType v2_ = get_vertex(output_mesh, N, v[pi], v[oi1]);
        add_line(v1_, v2_);

        if (pos_count == 1)
        {
          viennagrid::make_triangle( output_mesh, copy_map(v[pi]), v1_, v2_);
        }
        else
        {
          viennagrid::make_triangle( output_mesh, copy_map(v[oi0]), copy_map(v[oi1]), v1_);
          viennagrid::make_triangle( output_mesh, copy_map(v[oi1]), v1_, v2_);
        }
      }

      std::vector<viennagrid_int> line_ids;
      std::map<ElementType, viennagrid_int> vertices_on_hyperplane;

      for (LinesOnHyperplaneType::iterator it = lines_on_hyperplane.begin(); it != lines_on_hyperplane.end(); ++it)
      {
        vertices_on_hyperplane.insert( std::make_pair((*it).first, -1) );
        vertices_on_hyperplane.insert( std::make_pair((*it).second, -1) );
      }

      for (std::map<ElementType, viennagrid_int>::iterator vit = vertices_on_hyperplane.begin(); vit != vertices_on_hyperplane.end(); ++vit)
      {
        PointType p = viennagrid::get_point( (*vit).first );
        viennagrid_plc_vertex_create(plc_output_mesh, &p[0], &vit->second);
      }

      for (LinesOnHyperplaneType::iterator it = lines_on_hyperplane.begin(); it != lines_on_hyperplane.end(); ++it)
      {
        viennagrid_int line_id;
        viennagrid_plc_line_create(plc_output_mesh,
                                   vertices_on_hyperplane[(*it).first],
                                   vertices_on_hyperplane[(*it).second],
                                   &line_id);
        line_ids.push_back(line_id);
      }

      viennagrid_plc_facet_create(plc_output_mesh, line_ids.size(), &line_ids[0], NULL);
    }
コード例 #29
0
ファイル: TextBox.cpp プロジェクト: mcanthony/sNodes
void TextBox::mousePressed(ofMouseEventArgs& args){
    ofPoint mouse = ofPoint(args.x,args.y);
	mouseDownInRect = inside(mouse);
    lastMousePos = mouse;
}
コード例 #30
0
void ButtonProgress::draw(QPainter &p)
{
    if(visible)
    {
        if(widget != 0)
        {
            widget->fontArista.setPixelSize(height()/3);
            p.setFont(widget->fontArista);
        }

        // Set state
        if(widget != 0)
        {
            if(inside(widget->moveX,widget->moveY))
            {
                if(widget->clicked)
                {
                    setState(widget->stateMap["click"]);
                }
                else
                {
                    setState(widget->stateMap["move"]);
                }
            }
            else
            {
                setState(widget->stateMap["passive"]);
            }
        }

        // Background
        p.drawImage(x(), y(), backgroundImages[state]);
        // Progress
        if(widget != 0)
        {
            QLinearGradient buttonMask(animation.x,animation.y,animation.x+width(),animation.y);
            if(rightDir) // To right Progress
            {
                buttonMask.setColorAt(0, Qt::transparent);
                buttonMask.setColorAt(1, progressColor);
                QBrush buttonMaskBrush(buttonMask);
                p.setBrush(buttonMaskBrush);

                if(state == widget->stateMap["click"])
                { // if Click
                    p.drawRect(animation.x+progressX, animation.y+progressY*1.1,
                               ( backgroundImages[0].width()-progressX*2 )*(progressValue/100),
                               backgroundImages[0].height()-progressY*3);
                }
                else
                { // if Passive or Move
                    p.drawRect(animation.x+progressX, animation.y+progressY,
                               (backgroundImages[0].width()-progressX*2 )*(progressValue/100),
                               backgroundImages[0].height()-progressY*3);
                }
            }
            else if(!rightDir)// To left progress
            {
                buttonMask.setColorAt(1, Qt::transparent);
                buttonMask.setColorAt(0, progressColor);
                QBrush buttonMaskBrush(buttonMask);
                p.setBrush(buttonMaskBrush);

                if(state == widget->stateMap["click"])
                { // if Click
                    p.drawRect(animation.x+width()-progressX, animation.y+progressY*1.1,
                               0 - (( backgroundImages[0].width()-progressX*2 )*(progressValue/100)),
                               backgroundImages[0].height()-progressY*3);
                }
                else
                { // if Passive or Move
                    p.drawRect(animation.x+width()-progressX, animation.y+progressY,
                               0 - (( backgroundImages[0].width()-progressX*2 )*(progressValue/100)),
                               backgroundImages[0].height()-progressY*3);
                }
            }
        }

        // Other
        Button::draw(p);
    }
}