示例#1
0
// MW-2011-09-06: [[ Redraw ]] Added 'sprite' option - if true, ink and opacity are not set.
void MCColors::draw(MCDC *dc, const MCRectangle &dirty, bool p_isolated, bool p_sprite)
{
	uint2 xcells;
	uint2 ycells;
	getcells(xcells, ycells);

	uint2 i;
	uint2 j;
	MCRectangle rrect = MCU_reduce_rect(rect, borderwidth);
	MCRectangle trect;
	MCColor c;

	c = dc->getwhite();
	dc->setfillstyle(FillSolid, nil, 0, 0);
	for (i = 0 ; i < ycells ; i++)
		for (j = 0 ; j < xcells ; j++)
		{
			trect.x = j * rrect.width / xcells;
			trect.y = i * rrect.height / ycells;
			trect.width = (j + 1) * rrect.width / xcells - trect.x;
			trect.height = (i + 1) * rrect.height / ycells - trect.y;
			trect.x += rrect.x;
			trect.y += rrect.y;
			MCscreen->getpaletteentry(i * xcells + j, c);
			dc->setforeground(c);
			dc->fillrect(trect);
			if (c.pixel == selectedcolor)
				draw3d(dc, trect, ETCH_SUNKEN, borderwidth);
		}
	if (flags & F_SHOW_BORDER)
		if (flags & F_3D)
			draw3d(dc, rect, ETCH_SUNKEN, borderwidth);
		else
			drawborder(dc, rect, borderwidth);
}
示例#2
0
/* Metodo invocado quando trocamos de separador
*/
void MainWindow::on_tabSet_currentChanged( int index )
{
    Compass::Direction dir;

    switch( index )
        {
        case MainWindow::TAB_FP2D_INDEX:
            draw2d();
            assert( current_player >= 0  &&  current_player < MAX_PLAYERS  &&
                    current_player < num_players );  // Verificacoes basicas
            dir = players[current_player].compass.getDirection();
            break;
        case MainWindow::TAB_FP3D_INDEX:
            draw3d();
            assert( current_player >= 0  &&  current_player < MAX_PLAYERS  &&
                    current_player < num_players );  // Verificacoes basicas
            dir = players[current_player].compass.getDirection();
            break;
        default:  // MainWindow::TAB_MAP_INDEX e MainWindow::TAB_ABOUT_INDEX
            assert( num_players >= 0 );  // Verificacao basica
            dir = Compass::NORTH;
            break;
        }
    ui->dialCompass->setValue( dir );
}
示例#3
0
文件: testApp.cpp 项目: popsure/guppy
//--------------------------------------------------------------
void testApp::update(){
    sideCam->update();
    topCam->update();
    
    ofEnableAlphaBlending();
	
    rgbaFbo.begin();
    draw3d();
    rgbaFbo.end();
    
    
    Tweener.update();
    Tweener.addTween(position.x, ofMap(sideCam->blobX, 0, 320, -125, 125), 2); // aquarium case x
    Tweener.addTween(position.y, ofMap(sideCam->blobY, 0, 240, -125, 125), 2); // aquarium case y
    Tweener.addTween(position.z, ofMap(topCam->blobY, 0, 240, -125, 125), 2); // aquarium case z
    
    if(toggleArdSend) {
        //if (position.x != motorX || position.y != motorY || position.z != motorZ) {
            if(arduino.ardReady) {
                printf("sending coordinates to arduino\n");
                arduino.writeString(ofToString(int(position.x)) + "," + ofToString(int(position.y)) + "," + ofToString(int(position.z)) + ",;");
            }
        //}
    }   
    
    arduino.update(); // nothing happening yet..
}
示例#4
0
void draw(float stateBlend) {
	display->updateViewport();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if (stereo.enabled) {
		int height = display->height();
		int width = display->width();
		float sep = stereo.separation;
		if (stereo.cross) {
			sep = -sep;
		}
		glViewport(0, height / 4, width / 2, height / 2);
		draw3d(stateBlend, narf::Matrix4x4f::translate(sep, 0, 0));
		glViewport(width / 2, height / 4, width / 2, height / 2);
		draw3d(stateBlend, narf::Matrix4x4f::translate(-sep, 0, 0));
		glViewport(0, 0, width, height);
	} else {
		draw3d(stateBlend, narf::Matrix4x4f::translate(0, 0, 0));
	}

	draw2d();

	display->swap();

	if (screenshot) {
		screenshot = false;
		auto dwidth = static_cast<int>(display->width());
		auto dheight = static_cast<int>(display->height());
		SDL_Surface* image = SDL_CreateRGBSurface(SDL_SWSURFACE, dwidth, dheight, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
		glReadPixels(0, 0, dwidth, dheight, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
		narf::console->println("Taking a screenshot. " + std::to_string(image->w) + "x" + std::to_string(image->h) + "x24");

		// Flip upside down
		auto linesize = image->w * 3;
		auto pixels = static_cast<uint8_t*>(image->pixels);
		auto halfHeight = image->h / 2;
		for (int32_t y = 0; y < halfHeight; y++) {
			auto p1 = pixels + y * linesize;
			auto p2 = pixels + (image->h - y - 1) * linesize;
			std::swap_ranges(p1, p1 + linesize, p2);
		}
		SDL_SaveBMP(image, "pic.bmp");
		SDL_FreeSurface(image);
	}
}
示例#5
0
/* Este metodo e' chamado quando o utilizador carrega em "OK" apos escolher o
   tamanho do labirinto, e apos ter sido chamado resetStateNew().
   Ele inicia o processo de desenhar um novo labirinto.

   Restricoes (verificadas no assert(), abaixo):
	width  >= 3 e impar
	height >= 3 e impar
	0 < complexity <= 100
*/
void MainWindow::buildMaze( int width, int height, int complexity )
{
    Map *map_old;
    int p, num;

    // Verificacoes basicas
    assert( ui != NULL                          &&
            width  >= 3  &&  (width  & 1) == 1  &&
            height >= 3  &&  (height & 1) == 1  &&
            complexity > 0  &&  complexity <= 100 );

    // Feedback visual de "a trabalhar"
    ui->pushNew->setEnabled( false );
    setCursor( QCursor(Qt::WaitCursor) );

    num_players = 0;

    // Criar o labirinto
    map_old = map;  // Para o apagar *depois* de associar o novo aos QGLWidgets
    map = new Map( width, height );
    ui->glViewMap->setMap( map );
    ui->glView2D ->setMap( map );
    ui->glView3D ->setMap( map );

    // Apagar o labirinto anterior (se existir)
    if( map_old != NULL )
        delete map_old;

    // Construir agora o labirinto
    MapCreate::walls   ( map, complexity );
    MapCreate::features( map );

    // Posicionar os jogadores
    // Nota: por enquanto so' usamos um jogador (o jogador 0). Futuramente,
    // se quisermos mais de um jogador, eles devem ter um posicionamento
    // aleatorio dentro do labirinto, ou obtido pela rede.
    num = 1;
    for( p = 0;  p < num;  p++ )
        {
        players[p].x = players[p].y = 1;
        players[p].compass = Compass( Compass::NORTH );
        // this->map->setPlayer() e' chamado por this->draw2d() e this->draw3d()
        }
    current_player = 0;
    num_players = num;
    draw2d();
    draw3d();

    // Feedback visual de "pronto a jogar"
    setCursor( QCursor(Qt::ArrowCursor) );
    ui->pushNew->setEnabled( true );
    resetStatePlay();
}
示例#6
0
// MW-2011-09-06: [[ Redraw ]] Added 'sprite' option - if true, ink and opacity are not set.
void MCPlayer::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool p_sprite)
{
	MCRectangle dirty;
	dirty = p_dirty;
    
	if (!p_isolated)
	{
		// MW-2011-09-06: [[ Redraw ]] If rendering as a sprite, don't change opacity or ink.
		if (!p_sprite)
		{
			dc -> setopacity(blendlevel * 255 / 100);
			dc -> setfunction(ink);
		}
        
		// MW-2009-06-11: [[ Bitmap Effects ]]
		if (m_bitmap_effects == NULL)
			dc -> begin(false);
		else
		{
			if (!dc -> begin_with_effects(m_bitmap_effects, rect))
				return;
			dirty = dc -> getclip();
		}
	}
    
	if (MClook == LF_MOTIF && state & CS_KFOCUSED && !(extraflags & EF_NO_FOCUS_BORDER))
		drawfocus(dc, p_dirty);
    
	setforeground(dc, DI_BACK, False);
	dc->setbackground(MCscreen->getwhite());
	dc->setfillstyle(FillOpaqueStippled, nil, 0, 0);
	dc->fillrect(rect);
	dc->setbackground(MCzerocolor);
	dc->setfillstyle(FillSolid, nil, 0, 0);
    
	if (getflag(F_SHOW_BORDER))
	{
		if (getflag(F_3D))
			draw3d(dc, rect, ETCH_SUNKEN, borderwidth);
		else
			drawborder(dc, rect, borderwidth);
	}
	
	if (!p_isolated)
	{
		dc -> end();
	}
}
示例#7
0
//--------------------------------------------------------------
void testApp::draw() {
	switch (mode) {
		case 0:
			draw3d();
			break;
		case 1:
			client.getTextureReference().draw(0.0, 0.0);
			break;
		default:
			client.getDepthTextureReference().draw(0.0, 0.0);
			break;
	}
	
	gui.draw();

	// Show framerate.
	stringstream ss;
	ss << "FPS: " << ofGetFrameRate();
	ofDrawBitmapString(ss.str(), 520, 460);
}
示例#8
0
void MainWindow::on_pushTurnRight3D_clicked()
{
    turnRight();
    draw3d( true );  // Animar esta accao
}
示例#9
0
void MainWindow::on_pushMoveFwd3D_clicked()
{
    moveFwd();
    draw3d( true );  // Animar esta accao
}
	/*
	void Calibration::drawUndistortion() const {
		vector<ofVec2f> src, dst;
		cv::Point2i divisions(32, 24);
		for(int y = 0; y < divisions.y; y++) {
			for(int x = 0; x < divisions.x; x++) {
				src.push_back(ofVec2f(
					ofMap(x, -1, divisions.x, 0, addedImageSize.width),
					ofMap(y, -1, divisions.y, 0, addedImageSize.height)));
			}
		}
		undistort(src, dst);
		ofMesh mesh;
		mesh.setMode(OF_PRIMITIVE_LINES);
		for(int i = 0; i < src.size(); i++) {
			mesh.addVertex(src[i]);
			mesh.addVertex(dst[i]);
		}
		mesh.draw();
	}
	*/
	void Calibration::draw3d() const {
		for(int i = 0; i < size(); i++) {
			draw3d(i);
		}
	}
示例#11
0
文件: eps.cpp 项目: alilloyd/livecode
// MW-2011-09-06: [[ Redraw ]] Added 'sprite' option - if true, ink and opacity are not set.
void MCEPS::draw(MCDC *dc, const MCRectangle &dirty, bool p_isolated, bool p_sprite)
{
	MCRectangle trect = rect;
	if (flags & F_SHOW_BORDER)
		trect = MCU_reduce_rect(trect, borderwidth);

	if (flags & F_OPAQUE)
	{
		setforeground(dc, DI_BACK, False);
		dc->fillrect(trect);
	}
	if (state & (CS_SIZE | CS_MOVE))
	{
		dc->setlineatts(0, LineDoubleDash, CapButt, JoinBevel);
		dc->setforeground(dc->getblack());
		dc->setbackground(dc->getwhite());
		dc->setfillstyle(FillSolid, nil, 0, 0);
		dc->setdashes(0, dashlist, 2);
		MCLineSegment segs[2];
		segs[0].x1 = segs[1].x1 = trect.x;
		segs[0].x2 = segs[1].x2 = trect.x + trect.width;
		segs[0].y1 = segs[1].y2 = trect.y;
		segs[0].y2 = segs[1].y1 = trect.y + trect.height;
		dc->drawsegments(segs, 2);
		dc->setlineatts(0, LineSolid, CapButt, JoinBevel);
		dc->setbackground(MCzerocolor);
	}

#ifdef HAVE_EPS
	else
	{
		const char *psprolog = postscript;
		uint4 psprologlength = 0;
		const char *ps;
		uint4 length;
		if ((pagecount == 0) || (pagecount == 1))
		{
			ps = postscript;
			length = strlen(postscript);
		}
		else
		{
			psprologlength = pageIndex[0];
			ps = &postscript[pageIndex[curpage - 1] - 1];
			if (curpage != pagecount)
				length = pageIndex[curpage] - pageIndex[curpage - 1];
			else
				length = size - pageIndex[curpage - 1];
		}
		setforeground(dc, DI_FORE, False);
		const char *fontname;
		uint2 fheight, fontsize, fontstyle;
		MCFontStruct *font;
		getfontatts(fontname, fheight, fontsize, fontstyle, font);
		dc->draweps(trect.x * xf, -(trect.y * yf), angle, xscale, yscale,
		            tx, ty, prolog, psprolog, psprologlength, ps, length,
		            fontname, fontsize, fontstyle, font, trect);
	}
#endif

	if (flags & F_SHOW_BORDER)
		trect = MCU_reduce_rect(trect, -borderwidth);
	if (flags & F_SHOW_BORDER)
		if (flags & F_3D)
			draw3d(dc, trect, ETCH_SUNKEN, borderwidth);
		else
			drawborder(dc, trect, borderwidth);
	if (getstate(CS_KFOCUSED))
		drawfocus(dc, dirty);
	if (state & CS_SELECTED)
		drawselected(dc);
}
示例#12
0
void ofxAruco::draw()
{
  if ( camParams.isValid() ) 
    draw3d();
  else draw2d();
}
void TransIcelandicExpress::redraw( void ) {	

	static tex_init = 0;	

	
	if (!tex_init) {		

		ilutRenderer( ILUT_OPENGL );

		ilGenImages( 1, &ImageName );

		ilBindImage( ImageName );
		glEnable( GL_TEXTURE_2D );
		glEnable( GL_BLEND );
		glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	
		if (!ilLoadImage( "ludum48.png" )) {
			printf("Loading image failed\n");
		}

		
		gl_tex_id = ilutGLBindTexImage();
		ilutGLTexImage( 0 );

		tex_init = 1;
	} 

	glBindTexture (GL_TEXTURE_2D, gl_tex_id );

	glClearColor( 0.3f, 0.4f, 0.6f, 1.0f );
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	//glEnable( GL_CULL_FACE );
	glEnable( GL_DEPTH_TEST );

	// 3d part
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluPerspective( 60.0, 800.0/600.0, 0.05, 100.0 );



	gluLookAt(	player->pos[0]+cameraPos[0], 
				player->pos[1]+cameraPos[1]+c_PlayerHeight, 
				player->pos[2]+cameraPos[2],

				player->pos[0], 
				player->pos[1]+ c_PlayerHeight, 
				player->pos[2],

				0.0, 1.0, 0.0 );
				

	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	// apply some of the camera xform to the light just to make
	// it more shiny
	glPushMatrix();
	float viewHead = atan2( cameraPos[2], cameraPos[0] );	
	glRotated( viewHead * SG_RADIANS_TO_DEGREES, 0.0f, 1.0f, 0.0f );
	setupLights();
	glPopMatrix();

	draw3d();

	// 2d part
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();	
	gluOrtho2D( 0, 800, 0, 600 ) ;

	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	glDisable( GL_LIGHTING );
	draw2d();

	SDL_GL_SwapBuffers();

}
示例#14
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackground(200,200,170);
    //ofBackground(30);
    
   //ofBackgroundGradient(ofColor(255), ofColor(214, 240, 214));
    //ofBackgroundGradient(ofColor(255), ofColor(127, 127, 255));
    
    ofSetColor(255);
    if(bBlack){
        img.draw(0,0,ofGetWidth(),ofGetHeight());
        //movie.draw(0, 0);
        return;
    }
    
//    ofSetColor(200,200,170);
//    ofRect(0, 0, ofGetWidth(), ofGetHeight());
    
    
//    if(bHideGui)    movie.draw(0, 0);
    
    //ここから3D CG
    draw3d();
    //ここまで3D CG
    
    ofEnableAlphaBlending();
    ofSetColor(200,100);
    ofRect(0, 0, ofGetWidth(), judgeLine_yoko*2);

    ofSetColor(color3);
    
    if(timelineMethod<=1){
    ofSetLineWidth(2);
    //ofLine(0, 40, ofGetWidth(), 40);
    ofLine(0, judgeLine_yoko, ofGetWidth(), judgeLine_yoko);
    //ofLine(0, 200, ofGetWidth(), 200);
    //ofLine(0, 250, ofGetWidth(), 250);
    ofLine(judgeLine, 0, judgeLine, judgeLine_yoko*2);
    ofNoFill();
    ofCircle(judgeLine, judgeLine_yoko, 40);
    ofFill();
    for(int i=0;i<16;i++){
//        ofCircle(i*80+40, 40, 6.5);
//        ofCircle(i*80+40, 120, 6.5);
//        ofCircle(i*80+40, 200, 6.5);
        ofLine(i*80+40, judgeLine_yoko-5, i*80+40, judgeLine_yoko+5);
    }
//    for(int i=0;i<3;i++){
//        ofSetColor(150);
//        ofCircle(judgeLine, i*80+40, 35);
//    }
    
//    ofSetColor(150);
//    ofCircle(judgeLine, 120, 35);
    }
    
    //タイムラインのガイドライン
    if(timelineMethod>1){
        ofSetLineWidth(1);
        Obj buf_o;
        buf_o.setDrawMethod(timelineMethod);
        buf_o.setup(0,0,0);
        ofVec2f p1,p2;
        p1=buf_o.positionStart;
        for(int i=0;i<buf_o.frightCount;i++){
            buf_o.update();
            p2=buf_o.position;
            ofLine(p1,p2);
            p1=p2;
        }
        ofNoFill();
        ofCircle(buf_o.positionEnd, 35);
        ofFill();
    }
    
    ofEnableAlphaBlending();
    ofSetColor(255);
    for (int i = 0; i < Objects1.size(); i++) {
        Objects1[i].draw1();
    }
    for (int i = 0; i < Objects2.size(); i++) {
        Objects2[i].draw2();
    }
    for (int i = 0; i < Objects3.size(); i++) {
        Objects3[i].draw3();
    }
    for (int i = 0; i < Objects4.size(); i++) {
        Objects4[i].draw4();
    }
    
    //ofSetColor(0, 255, 0);
    for (int i = 0; i < longObjects.size(); i++) {
        longObjects[i].drawLong();
        
//        if(bPressed[i]){
//            longObjects[i].fillRed();
//        }

    }

    for (int i = 0; i < bigObjects.size(); i++) {
        bigObjects[i].drawBig();
    }
    
    ofDisableAlphaBlending();

    //ofSetColor(255);
    //ofRect(0, 0, judgeLine-80, 250);
    
//    float timer = ofGetElapsedTimeMillis() - startTime;
//    int x = ofGetWidth() - timer/3.561f;
//    int y = ofGetHeight()/2;
//    
//    ofSetColor(0, 0, 255);
//    ofCircle(x,y,30);

    //こっから動体描画
    if(bDraw2d){
        for (int i = 0; i < ObjHumans.size(); i++) {
            ObjHumans[i].draw();
        }
    }
    
    //シンクロ率表示
    ofSetColor(color3);
    if(cameraCount%2==0){
        if(sizes.size() || sizes2.size()){
            syncScore = ((int)(sizes.size()*100/(sizes.size()+sizes2.size())) + syncScore*3)/4;
            if(syncScore > 98){
                syncScore = 100;
            }
        }
    }
    font.drawString(ofToString(syncScore),ofGetWidth()/2,ofGetHeight()/2);
    font2.drawString("%",ofGetWidth()/2+115,ofGetHeight()/2);
    
    if(bHideGui) gui.draw();
    
    string info = "FPS: "+ofToString(ofGetFrameRate(), 3);
    //info += "\nObjects num: "+ofToString(Objects.size());
    //info += "\nlongObjects num: "+ofToString(longObjects.size());
    info += "\npress z: clap x: right c: left";
    info += "\npress p: music play s: stop r: reset";
    if(bMusicPlay) info += "\nmusic: play";
    else if(bMusicStop) info += "\nmusic: stop";
    else if(bMusicReset) info += "\nmusic: reset";
    info += "\nScore: "+ofToString(score);
    info += "\nelapsed time: "+ofToString(ofGetElapsedTimeMillis());
//    info += "\ntimer: "+ofToString(timer)+" ms";
    info += "\nobjVel: "+ofToString(objVelocity);
    info += "\nParticle Matsu: "+ofToString(NUM_BILLBOARDS);
    info += "\nTexture LineID: "+ofToString(texlibnum);
    ofSetColor(0);
    if(!bHideInfo) ofDrawBitmapString(info, 20, ofGetHeight()-100);
    
//    ofFill();
//    ofRect(0, 0, 240, 1080);
//    ofRect(1680, 0, 240, 1080);

}