示例#1
0
inline
void drawScene()
{
	glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
	glLightfv(GL_LIGHT1, GL_POSITION, LightPosition1);

//	glDisable(GL_LIGHTING);
//	glPointSize(10.0);
//	glBegin(GL_POINTS);
//	glVertex3f(LightPosition[0], LightPosition[1], LightPosition[2]);
//	glEnd();
//	glPointSize(1.0);

	glEnable(GL_LIGHTING);

	glDisable(GL_LIGHTING);

	glPushMatrix();
	glTranslatef(-0.5, -0.5, -0.5);
		if(Digitized)
			drawVoxels(*Digitized);
		if(Boundary)
			drawBoundary(*Boundary, *Digitized);
	glPopMatrix();
}
示例#2
0
void Lines::paintEvent(QPaintEvent *e){
	Q_UNUSED(e);
	QPainter qp(this);
	/*Create serial object */
	try { 

			// Make a SimpleSerial object with the parameter for your Wunderboard/OS
			
			
			this->tmp = this->wunder->readLine();

			/*handles odd SimpleSerial Problems*/
			if(this->tmp.length() != 3)
				adcval = MADC; //send it back to the middle
			else
				adcval = atoi(this->tmp.c_str()) - MADC ;

		} catch(boost::system::system_error& e)
		{
			std::cerr<<tmp<<": Error: "<<std::endl;//<<e.what()<<std::endl;
		}
	qp.setWindow(0,0, 800, 600);
	drawBoundary(&qp);
	drawPaddle(&qp);
	drawBall(&qp);
	drawBlocks(&qp);
	check_collision();

	
}
void labeling(void)
{
	verticalProject(&cImg, vProjection);
	setBoundary(&cImg, vProjection, boundary);
	getYVals(&cImg, vProjection, boundary, heights);
	drawProject(&cImg, vProjection);
	drawBoundary(&cImg, boundary);
}
void drawWinnerBlur()
{
	drawRectangle(width,height);
	drawComponents();
	drawBoundary(width,height);
	calcScore();

	drawLeftBlock(x[1],y[1],height);
	drawRightBlock(x[2],y[2],height);
	drawBall(x[0],y[0],radius,radius);

	if(scoreRight==7)
	{
		glColor4d(1,1,1,0.7);
		glBegin(GL_POLYGON);
		glVertex2d(width/2,0);
		glVertex2d(width,0);
		glVertex2d(width,height);
		glVertex2d(width/2,height);
		glEnd();

		glColor4d(0,0,0,0.7);
		glBegin(GL_POLYGON);
		glVertex2d(0,0);
		glVertex2d(width/2,0);
		glVertex2d(width/2,height);
		glVertex2d(0,height);
		glEnd();
	}else
	{
		glColor4d(1,1,1,0.7);
		glBegin(GL_POLYGON);
		glVertex2d(0,0);
		glVertex2d(width/2,0);
		glVertex2d(width/2,height);
		glVertex2d(0,height);
		glEnd();

		glColor4d(0,0,0,0.7);
		glBegin(GL_POLYGON);
		glVertex2d(width/2,0);
		glVertex2d(width,0);
		glVertex2d(width,height);
		glVertex2d(width/2,height);
		glEnd();
	}
}
示例#5
0
文件: game.cpp 项目: mdriess/Snake
void Game::playGame()
{
    resizeConsole(x_max+1,y_max+1);//game size
    screen.clear();
    drawBoundary();

    while(!dead)
    {
        displayScore();

        if(!paused)
        {
            snake.clear(screen);
            snake.move();
            snake.draw(screen);

            food.draw(screen);

            Sleep(100-speed);


            if(snake.hit(x_min,x_max,y_min,y_max))
            {
                dead = true;
            }
            else if(snake.getHead().equals(food))
            {
                snake.grow();
                generateFood();
                harder();
            }
        }

        if(kbhit())
        {
            getKeys();
        }

    }
    //endgame();
    updateUser();
}
示例#6
0
void drawPauseSpace()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(0,0,0,0);
	drawRectangle(width,height);

	drawComponents();
	drawBoundary(width,height);
	calcScore();

	drawLeftBlock(x[1],y[1],height);
	drawRightBlock(x[2],y[2],height);
	drawBall(x[0],y[0],radius,radius);

	glColor4d(1,1,1,0.7);
	glBegin(GL_POLYGON);
	glVertex2d(-50,-50);
	glVertex2d(width+50,-50);
	glVertex2d(width+50,height+100);
	glVertex2d(-50,height+100);
	glEnd();
}
示例#7
0
void SlideNavmesh::draw(const float* view, const float zoom, bool highlight)
{
	if (!visible(view))
		return;
	
	drawCorner(!m_expanded);
	
	if (!m_expanded)
		return;
	
	glPushMatrix();
	glTranslatef(m_pos[0],m_pos[1],0);

//	drawDropShadow(0,0, m_dim[0],m_dim[1], highlight ? 2 : 1);
	
/*	if (highlight)
		glColor4ub(255,255,255,128);
	else
		glColor4ub(255,255,255,96);*/

	setcolor(COL_BACK);
//	drawBG(0,0,m_dim[0],m_dim[1]);
	
	
	glPushMatrix();
	glTranslatef(PADDING_SIZE,PADDING_SIZE,0);

	drawBoundary(m_scene.boundary, m_scene.nboundary, zoom);
	
	// Draw navmesh
	if (m_drawGraph)
		navmeshDraw(m_scene.nav, zoom);

	// Draw Agent
	int aflags = 0;
	if (m_drawCorner)
		aflags |= AGENTDRAW_CORNER;
	if (m_drawCorridor)
		aflags |= AGENTDRAW_CORRIDOR;
	if (m_drawVisited)
		aflags |= AGENTDRAW_VISITED;

	NavmeshAgent* ag = &m_scene.agents[0];
	
	agentTrailDraw(ag, m_scene.nav, zoom);
	agentDraw(ag, m_scene.nav, aflags, zoom);

	// Actual
	if (m_drawDelta)
	{
		glLineWidth(2.0f*zoom);
		setcolor(COL_DARK);
		drawarrow(ag->pos[0],ag->pos[1],
				  ag->pos[0]+ag->vel[0], ag->pos[1]+ag->vel[1],0.1f);
	}
	
	glPopMatrix();

	drawButtons();

/*
	setcolor(clerp(COL_DIM,COL_BACK,128));
	glPointSize(1.0f);
	glLineWidth(1.0f);
	
//	drawtext(PADDING_SIZE,PADDING_SIZE/2, 0.07f, "M A S T E R   P L A N");
	const float ts = 0.07f;
	float sx;
	float x = PADDING_SIZE;
	float y = PADDING_SIZE/3;
	sx = x;
	drawtext(x,y, ts, "Corner");
	x += 0.7f;
	drawtext(x,y, ts, "Corridor");
	x += 0.7f;
	drawtext(x,y, ts, "Mesh");
	x += 0.7f;

	glBegin(GL_LINES);
	glVertex2f(x,y+ts*1.5f);
	glVertex2f(sx,y+ts*1.5f);
	glEnd();
	
	x += 0.5f;

	sx = x;
	drawtext(x,y, ts, "Straight");
	x += 0.7f;
	drawtext(x,y, ts, "Smooth");
	x += 0.7f;
	drawtext(x,y, ts, "Drunk");
	x += 0.7f;

	glBegin(GL_LINES);
	glVertex2f(x,y+ts*1.5f);
	glVertex2f(sx,y+ts*1.5f);
	glEnd();
*/
	
	glPopMatrix();
}
void
SolutionImageWriter::write(
		const Crag& crag,
		const CragVolumes& volumes,
		const CragSolution& solution,
		const std::string& basename,
		bool boundary) {

	LOG_DEBUG(solutionimagewriterlog) << "storing solution in " << basename << std::endl;

	if (_volumesBB.isZero())
		_volumesBB = volumes.getBoundingBox();

	LOG_DEBUG(solutionimagewriterlog) << "using bounding box of " << _volumesBB << std::endl;

	util::point<float, 3> resolution;
	for (Crag::CragNode n : crag.nodes()) {

		if (!crag.isLeafNode(n))
			continue;
		resolution = volumes[n]->getResolution();
		break;
	}

	LOG_DEBUG(solutionimagewriterlog) << "using resolution of " << resolution << std::endl;

	// create a vigra multi-array large enough to hold all volumes
	vigra::MultiArray<3, float> components(
			vigra::Shape3(
				_volumesBB.width() /resolution.x(),
				_volumesBB.height()/resolution.y(),
				_volumesBB.depth() /resolution.z()),
			std::numeric_limits<int>::max());

	// background for areas without candidates
	if (boundary)
		components = 0.25;
	else
		components = 0;

	for (Crag::CragNode n : crag.nodes()) {

		LOG_ALL(solutionimagewriterlog) << "drawing node " << crag.id(n) << std::endl;

		// draw only selected nodes
		if (!solution.selected(n))
			continue;

		const util::point<float, 3>&      volumeOffset     = volumes[n]->getOffset();
		const util::box<unsigned int, 3>& volumeDiscreteBB = volumes[n]->getDiscreteBoundingBox();

		util::point<unsigned int, 3> begin = (volumeOffset - _volumesBB.min())/resolution;
		util::point<unsigned int, 3> end   = begin +
				util::point<unsigned int, 3>(
						volumeDiscreteBB.width(),
						volumeDiscreteBB.height(),
						volumeDiscreteBB.depth());

		LOG_ALL(solutionimagewriterlog) << "\toffset      : " << volumeOffset << std::endl;
		LOG_ALL(solutionimagewriterlog) << "\tdiscrete bb : " << volumeDiscreteBB << std::endl;
		LOG_ALL(solutionimagewriterlog) << "\ttarget area : " << begin << " -- " << end << std::endl;

		// fill id of connected component
		vigra::combineTwoMultiArrays(
			volumes[n]->data(),
			components.subarray(TinyVector3UInt(&begin[0]),TinyVector3UInt(&end[0])),
			components.subarray(TinyVector3UInt(&begin[0]),TinyVector3UInt(&end[0])),
			vigra::functor::ifThenElse(
					vigra::functor::Arg1() == vigra::functor::Param(1),
					vigra::functor::Param(solution.label(n)),
					vigra::functor::Arg2()
		));
	}

	if (boundary) {

		// gray boundary for all leaf nodes
		for (Crag::CragNode n : crag.nodes())
			if (crag.isLeafNode(n))
				drawBoundary(volumes, n, components, 0.5);

		// black boundary for all selected nodes
		for (Crag::CragNode n : crag.nodes())
			if (solution.selected(n))
				drawBoundary(volumes, n, components, 0);
	}

	if (components.shape(2) > 1) {

		boost::filesystem::create_directory(basename);
		for (unsigned int z = 0; z < components.shape(2); z++) {

			std::stringstream ss;
			ss << std::setw(4) << std::setfill('0') << z;
			vigra::exportImage(
					components.bind<2>(z),
					vigra::ImageExportInfo((basename + "/" + ss.str() + ".tif").c_str()));
		}

	} else {

		vigra::exportImage(
				components.bind<2>(0),
				vigra::ImageExportInfo((basename + ".tif").c_str()));
	}
}
示例#9
0
void stateRunning()
{
	char c;
	char score[7];
//	if(loopTime==0){
	glClear(GL_COLOR_BUFFER_BIT );
	glClearColor(0,0,0,0);

	drawRectangle(width,height);

	drawComponents();

	///////////////////for Ball///////////////////

	if(y[0]+radius>=500)
	{
    	speedy*=-1; 
    	y[0]=500-radius;
	}
	if(y[0]-radius<=0)
	{
		speedy*=-1; 
    	y[0]=radius;
	}

	if(x[0]-radius-5<=x[1] && x[0]+radius+5>=x[2] )
	{
		if((y[0]>=y[1]-height/10 && y[0]<=y[2]+height/10) || (y[0]>=y[2]-height/10 && y[0]<=y[1]+height/10))
		{
			x[1]=x[0]-2*radius;
			x[2]=x[0]+2*radius;
		}
	}

    if((x[0]-radius>x[1] && x[0]+speedx-radius<x[1]) || (x[0]+radius<x[1]-10 && x[0]+speedx+radius>x[1]-10))
	{
		yi=(speedy/speedx)*(x[1]-x[0])+y[0];
		xi=x[0];
		if(yi<y[1]+height/10 && yi>y[1]-height/10)
		{
			if(x[0]>x[1])
				x[0]=x[1]+radius;
			else
				x[0]=x[1]-radius;
			y[0]=(speedy/speedx)*(x[0]-xi)+y[0];
		}
	}

	if(y[0]-radius<=y[1]+height/10 && y[0]+radius>=y[1]-height/10){
    if((x[0]-radius<=x[1] && x[0]-radius>=x[1]-10))
    {
    	x[0]=x[1]+radius;
    	speedx=abs(speedx);
    	speedx+=xspeeder;
    	speedy+=yspeeder;    	
    }else if(x[0]+radius>=x[1]-10 && x[0]+radius<=x[1])
    {
    	x[0]=x[1]-radius-10;
    	speedx=abs(speedx)*-1;
    	speedx+=xspeeder;
    	speedy+=yspeeder;    	
    }
}
	if(x[0]<=x[1] && x[0]>=x[1]-10){
    if((y[0]-radius<=y[1]+height/10 && y[0]-radius>=y[1]))
    {
    	y[0]=y[1]+height/10+radius;
    	speedy=abs(speedy);
    	speedx+=xspeeder;
    	speedy+=yspeeder;    	
    }else if(y[0]+radius>=y[1]-height/10 && y[0]-radius<=y[1])
    {
    	y[0]=y[1]-height/10-radius;
    	speedy=abs(speedy)*-1;
    	speedx+=xspeeder;
    	speedy+=yspeeder;    	
    }
}

	if((x[0]-radius>x[2]+10 && x[0]+speedx-radius<x[2]+10) || (x[0]+radius<x[2] && x[0]+speedx+radius>x[2]))
	{
		yi=(speedy/speedx)*(x[2]-x[0])+y[0];
		xi=x[0];
		if(yi<y[2]+height/10 && yi>y[2]-height/10)
		{
			if(x[0]>x[2])
				x[0]=x[2]+radius+10;
			else
				x[0]=x[2]-radius;
			y[0]=(speedy/speedx)*(x[0]-xi)+y[0];
		}
	}

	if(y[0]-radius<=y[2]+height/10 && y[0]+radius>=y[2]-height/10){
    if((x[0]+radius>=x[2] && x[0]+radius<=x[2]+10))
    {
    	x[0]=x[2]-radius;
    	speedx=abs(speedx)*-1;
    	speedx+=xspeeder;
    	speedy+=yspeeder;
    	
    }else if(x[0]-radius<=x[2]+10 && x[0]-radius>=x[2])
    {
    	x[0]=x[2]+10+radius;
    	speedx=abs(speedx);
    	speedx+=xspeeder;
    	speedy+=yspeeder;

    }
}

if(x[0]>=x[2] && x[0]<=x[2]+10){
    if((y[0]-radius<=y[2]+height/10 && y[0]-radius>=y[2]))
    {
    	y[0]=y[2]+height/10+radius;
    	speedy=abs(speedy);
    	speedx+=xspeeder;
    	speedy+=yspeeder;    	
    }else if(y[0]+radius>=y[2]-height/10 && y[0]-radius<=y[2])
    {
    	y[0]=y[2]-height/10-radius;
    	speedy=abs(speedy)*-1;
    	speedx+=xspeeder;
    	speedy+=yspeeder;    	
    }
}

    x[0]=x[0]+speedx;
	y[0]=y[0]+speedy;	

	if(x[0]-radius<=0)
	{
		if((y[0]>=height*3/4 && y[0]<=height) || (y[0]<=height/4 && y[0]>=0))
		{
		speedx*=-1;
		x[0]=radius;
	}
	}

	if(x[0]-radius==0 && x[0]+radius>=x[1]-10)
	{
		if((y[0]>=y[1]-height/10 && y[0]<=y[1]+height/10))
		{
			x[1]=x[0]+3*radius;
		}
	}

	if(x[0]+radius>=width)
	{
		if((y[0]>=height*3/4 && y[0]<=height) || (y[0]<=height/4 && y[0]>=0))
		{
		speedx*=-1;
		x[0]=width-radius;
	}
	}

	if(x[0]+radius==width && x[0]-radius<=x[2]+10)
	{
		if((y[0]>=y[2]-height/10 && y[0]<=y[2]+height/10))
		{
			x[2]=x[0]-3*radius;
		}
	}

	drawBall(x[0],y[0],radius,radius);
   
	/////////////////for Block 1///////////////////////

	if(x[1]<500 && x[1]-10>0){
	if(y[1]+height/10<500 && y[1]-height/10>0)
	{
	if(up[0]==1)
	{
		y[1]+=5;
		yspeeder+=0.1;
    }
    if(down[0]==1)
    {
    	y[1]-=5;
    	yspeeder-=0.1;
    }
    if(left[0]==1)
    {
    	x[1]-=5;
    	xspeeder-=0.1;
    }
    if(right[0]==1)
    {
    	x[1]+=5;
    	xspeeder+=0.1;
    }
}else {
	if(y[1]+height/10>=500)
		y[1]-=6;
	else if(y[1]-height/10<=0)
		y[1]+=6;
}
}else{
	if(x[1]>=500)
		x[1]-=6;
	else if(x[1]-10<=0)
		x[1]+=6;
	
}
    drawLeftBlock(x[1],y[1],height);

    /////////////////////for block 2//////////////////

   if(x[2]+10<1000 && x[2]>500){
	if(y[2]+height/10<500 && y[2]-height/10>0)
	{
	if(up[1]==1)
	{
		y[2]+=5;
		yspeeder+=0.1;
    }
    if(down[1]==1)
    {
    	y[2]-=5;
    	yspeeder-=0.1;
    }
    if(left[1]==1)
    {
    	x[2]-=5;;
    	xspeeder-=0.1;
    }
    if(right[1]==1)
    {
    	x[2]+=5;
    	xspeeder+=0.1;
    }
}else {
	if(y[2]+height/10>=500)
		y[2]-=6;
	else if(y[2]-height/10<=0)
		y[2]+=6;
}
}else{
	if(x[2]<=500)
		x[2]+=6;
	else if(x[2]>=990)
		x[2]-=6;
	
}
	drawRightBlock(x[2],y[2],height); 

	drawBoundary(width,height); 
	
	calcScore();

	loopTime++;	
}
void SeedingIdeaData::draw()
{
    drawBoundary();
}