void mgsCooperSymbols::drawFullGrid(float x, float y) {
  for(float x = 0; x < dimensions.width+gw; x += gw){
    for(float y = 0; y < dimensions.width+gh; y += gh){
      if (!singleShapesP) {
        switch((int)ofRandom(1, numberOfShapes+1)) {
          case 1:
            drawSquare(x+shiftCounter, y+rowCounter, gw);
            break;
          case 2:
            drawTri(x+shiftCounter, y+rowCounter, gw);
            break;
          case 3:
            drawCircle(x+shiftCounter+gw/2, y+rowCounter+gh/2, gw/2);
            break;
        }
      } else {
        switch(numberOfShapes) {
          case 1:
            drawSquare(x+shiftCounter, y+rowCounter, gw);
            break;
          case 2:
            drawTri(x+shiftCounter, y+rowCounter, gw);
            break;
          case 3:
            drawCircle(x+shiftCounter+gw/2, y+rowCounter+gh/2, gw/2);
            break;
        }
      }
    }
  }
}
void mgsCooperSymbols::drawGrid(float x, float y) {
  ofPushStyle();
  clearCell(shiftCounter-1,rowCounter,gw+2,gh);
  drawCursor();
  ofSetColor(symbolColor);
  ofNoFill();
  if(randomStrokeP) randomStroke();
  if (!singleShapesP) {
    switch((int)ofRandom(1, numberOfShapes+1)) {
      case 1:
        drawSquare(x+shiftCounter, y+rowCounter, gw);
        break;
      case 2:
        drawTri(x+shiftCounter, y+rowCounter, gw);
        break;
      case 3:
        drawCircle(x+shiftCounter+gw/2, y+rowCounter+gh/2, gw/2);
        break;
    }
  } else {
    switch(numberOfShapes) {
      case 1:
        drawSquare(x+shiftCounter, y+rowCounter, gw);
        break;
      case 2:
        drawTri(x+shiftCounter, y+rowCounter, gw);
        break;
      case 3:
        drawCircle(x+shiftCounter+gw/2, y+rowCounter+gw/2, gw/2);
        break;
    }
  }
  ofPopStyle();
}
Beispiel #3
0
void recursion(){
	/* ----------------Part 4---------------------*/
	//Fib Variables
	int fibNum = 0;
	cout << "Which number of the Fibonnaci Sequence do you want? \n(For this program, we are NOT including 0 as a part of the sequence.)\n";
	cin >> fibNum;
	cout << "That number is " << fib(fibNum) << endl; //original call

	//Pow Variables
	int base = 0,  power = 0;
	cout << "Moving on to power. What number do you want raised to what power\n(use format [number space power])" << endl;
	cin >> base >> power;
	cout << "That comes out to " << pow(base, power) << endl; //original call

	//Tri Variables
	int triNum = 0;
	cout << "Moving on to tri. Which triangular number do you want?\n";
	cin >> triNum;
	cout << "That comes out to " << tri(triNum) << endl << "Your triangle looks something like this:\n"; //original call
	drawTri(triNum);  // random function I wanted to do, because why not?

	//Gcd Variables
	int gcdNum1, gcdNum2;
	cout << "Finally, moving on to gcd. Please enter the two numbers you want \n to find the greatest common denominator of. \n(Use formate [number1 space number2]) \n";
	cin >> gcdNum1 >> gcdNum2;
	if (gcdNum1 < 0 || gcdNum2 < 0){
		gcdNum1 = abs(gcdNum1);
		gcdNum2 = abs(gcdNum2);
	}
	cout << "The greatest common denominator between these two numbers is:\n" << gcd(gcdNum1, gcdNum2) << endl; // original call

	cout << "Now moving on to iterating." << endl;

	/* ----------------Part 5---------------------*/
	//Fib Variables
	int fibNum_iter;
	cout << "Which number of the Fibonnaci Sequence do you want? \n(For this program, we are NOT including 0 as a part of the sequence.)\n";
	cin >> fibNum_iter;
	cout << "That number is " << fib_iter(fibNum_iter) << endl;

	//Pow Variables
	int base_iter, power_iter;
	cout << "Moving on to power. What number do you want raised to what power\n(use format [number space power])" << endl;
	cin >> base_iter >> power_iter;
	cout << "That comes out to " << pow_iter(base_iter, power_iter) << endl;

	//Tri Variables
	int triNum_iter;
	cout << "Moving on to tri. Which triangular number do you want?\n";
	cin >> triNum_iter;
	cout << "That comes out to " << tri_iter(triNum_iter) << endl;

	//GCD Variables
	int gcdNum1_iter, gcdNum2_iter;
	cout << "Finally, moving on to gcd. Please enter the two numbers you want \n to find the greatest common denominator of. \n(Use formate [number1 space number2]) \n";
	cin >> gcdNum1_iter >> gcdNum2_iter;
	cout << "The greatest common denominator between these two numbers is:\n" << gcd_iter(gcdNum1_iter, gcdNum2_iter) << endl;
}
Beispiel #4
0
void drawOverlay ()
{
	Vector4DF clr;

	Matrix4F proj, view, model;
	proj.Scale ( 2.0/window_width, -2.0/window_height, 1 );		
	model.Translate ( cam.getToPos().x, cam.getToPos().y, 1 );
	view.Scale ( cam.getToPos().z, 1, 1 );
	view *= model;
	model.Identity ();

	//----- 2D Drawing (visualizer space)	
	setview2D ( model.GetDataF(), view.GetDataF(), proj.GetDataF() );
	setorder2D ( false, 1 );
	updatestatic2D ( 0 );		// update model/view/proj matrices of each static draw layer
	updatestatic2D ( 1 );
	updatestatic2D ( 2 );
	updatestatic2D ( 3 );
		
	// Selector Bar
	start2D ();					
	  drawRect ( mSelectID*10, 0, mSelectID*10+10, NUM_BIN*25, 1,1,1,1 );

	// Same-State Highlights (yellow)
	int minE = (((0-window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10;
	int maxE = (((window_width - window_width/2.0)/cam.getToPos().z) - cam.getToPos().x) / 10;
	minE = ( minE < 0 ) ? 0 : minE;
	maxE = ( maxE >= mEvents.size() ) ? mEvents.size() : maxE;
	for (int n=0; n < mEvents.size(); n++ ) {
		if ( mEvents[n].bin_id[mSelectBin] == mEvents[mSelectID].bin_id[mSelectBin] && n > minE && n < maxE ) {
			drawRect ( n*10, mSelectBin*25, n*10+10, mSelectBin*25+24, 1,1,0,1 );
			drawRect ( n*10+1, mSelectBin*25+1, n*10+9, mSelectBin*25+23, 1,1,0,1 );
		}
	}
	end2D ();
	
	//----- 2D Drawing (screen space)	
	setview2D ( window_width, window_height );	// change to screen space
	setorder2D ( true, -0.00001 );
	
	start2D ();					// dynamic draw
	int panel_width = 200;
	float xoff = window_width - panel_width;
	float yoff = cam.getToPos().y + (window_height/2);

	// Left panel - Bin Text 
	char name[128];
	char msg[1024];

	int frame = mEvents[mSelectID].frame; 
	frame = (frame < 0 || frame >= mFrames.size() ) ? 0 : frame;
	Frame& f = mFrames[ frame ];

	drawFill ( 0, yoff, +panel_width, yoff + NUM_BIN*25+250, 0.15,0.15,0.2,0.75 );
	
	drawText ( 10, yoff-85, "Frame #:", 1,1,1,1 );
	drawText ( 10, yoff-70, "Frame Draws:", 1,1,1,1 );
	drawText ( 10, yoff-55, "Frame Prims:", 1,1,1,1 );
	drawText ( 10, yoff-40, "Frame Transfer:", 1,1,1,1 );	
	drawText ( 10, yoff-20, "Frame States:", 1,1,1,1 );	
	sprintf ( msg, "%d", frame );					drawText ( 100, yoff - 85, msg, 1,1,1,1 );	
	sprintf ( msg, "%d", f.totalDraw );				drawText ( 100, yoff - 70, msg, 1,1,1,1 );
	sprintf ( msg, "%d", f.totalPrim );				drawText ( 100, yoff - 55, msg, 1,1,1,1 );
	sprintf ( msg, "%d bytes", f.totalTransfer );	drawText ( 100, yoff - 40, msg, 1,1,1,1 );

	setText ( 0.8, 0 );
	drawText ( 100, yoff - 20, "Modify", 1,0,0,1 );
	drawText ( 125, yoff - 10, "Switch", 1,0.5,0,1 );
	drawText ( 150, yoff - 20, "Reuse", 0,1,0,1 );
	drawText ( 175, yoff - 10, "Unique", 1,1,1,1 );
	drawTri ( 100, yoff-10, 100+10, yoff-10, 100, yoff, 1, 0,0, 1);
	drawTri ( 125, yoff-10, 125+10, yoff-10, 125, yoff, 1,.5,0, 1);
	drawTri ( 150, yoff-10, 150+10, yoff-10, 150, yoff, 0, 1,0, 1);
	setText ( 1.0, -0.5 );

	for (int b=0; b < NUM_BIN; b++ ) {
		strncpy ( name, binNames[b].c_str(), 128 );
		drawText ( 8, yoff + b*25+12, name, 1,1,1,1 );

		clr.x = float(f.binChange[b]) / f.totalDraw;	if ( clr.x > 1 ) clr.x = 1;
		sprintf ( msg, "%d", f.binChange[b] );	drawText ( 100, yoff + b*25+12-2, msg, clr.x*0.7+0.3, 0,0,1 );	
		
		clr.x = float(f.binSwitch[b]) / f.totalDraw;	if ( clr.x > 1 ) clr.x= 1;
		sprintf ( msg, "%d", f.binSwitch[b] );	drawText ( 125, yoff + b*25+12+2, msg, clr.x*0.7+0.3,clr.x*.4+0.2,0,1 );
		
		clr.x = float(f.binReuse[b]) / f.totalDraw; 	if ( clr.x > 1 ) clr.x= 1;
		sprintf ( msg, "%d", f.binReuse[b] );	drawText ( 150, yoff + b*25+12-2, msg, 0, clr.x*0.7+0.3, 0,1 );

		sprintf ( msg, "%d", f.binUnique[b] );	drawText ( 175, yoff + b*25+12+2, msg, .7, .7, .7,1 );
	}

	int ys = NUM_BIN*25;
	float ypos; 
	sprintf ( msg, "%d", mMaxPrim/4 ); 
	drawLine ( 0, yoff + ys+25, 200, yoff+ys+25, .6, .6, .6, 1);	
	drawText ( 10, yoff+ys+25+15, msg, .8,.8,.8,1 );
	drawText ( 10, yoff + ys+80, "# Prims", 1, 1, 1, 1 );
	drawText ( 10, yoff+ys+125, "0", .8,.8,.8,1 );
	drawLine ( 0, yoff + ys+125, 200, yoff+ys+125, .6, .6, .6, 1);
	ypos = mEvents[ mSelectID ].bin_id[ BIN_DRAW ] * 400 / mMaxPrim;		// prim count	
	clr = getClr ( mEvents[ mSelectID ].bin_id[9] + 9*16384 );
	if ( ypos > 100 ) ypos = 100;			
	sprintf ( msg, "%d", mEvents[ mSelectID ].bin_id[BIN_DRAW] );
	drawLine ( 150, yoff+ys+(125-ypos), 200, yoff+ys+(125-ypos), clr.x,clr.y,clr.z,1 );
	drawText ( 150, yoff+ys+(125-ypos), msg, clr.x,clr.y,clr.z,1 );

	sprintf ( msg, "%d", mMaxSize ); 
	drawLine ( 0, yoff + ys+150, 200, yoff+ys+150, .6, .6, .6, 1);
	drawText ( 10, yoff+ys+150+15, msg, .8,.8,.8,1 );
	drawText ( 10, yoff + ys+200, "Transfer (bytes)" , 1, 1, 1, 1);
	drawText ( 10, yoff+ys+250, "0", .8,.8,.8,1 );
	drawLine ( 0, yoff + ys+250, 200, yoff+ys+250, .6, .6, .6, 1);
	ypos = mEvents[ mSelectID ].bin_size [ BIN_SIZE ] * 100 / mMaxSize;		// prim count
	if ( ypos > 100 ) ypos = 100;	
	sprintf ( msg, "%d", mEvents[ mSelectID ].bin_size [BIN_SIZE] );
	drawLine ( 150, yoff+ys+(250-ypos), 200, yoff+ys+(250-ypos), 1,1,1,1 );
	drawText ( 150, yoff+ys+(250-ypos), msg, 1,1,1,1 );
		
	// Right panel - Call Text		
	drawFill ( xoff, yoff, xoff + panel_width, yoff + NUM_BIN*25+250, 0.15,0.15,0.2,0.75 );	
	int cid;
	glColor3f ( 1, 1, 1);
	
	for (int c = 0; c < mEvents[ mSelectID ].call_num; c++ ) {	
		cid = mEvents[ mSelectID ].call_start + c;		
		clr = getClr ( mCalls[cid].val_id + mCalls[cid].bin_id*16384 );
		clr.w = 1;
		drawFill ( xoff+100, yoff + c*15, xoff+125, yoff+c*15+13, clr.x, clr.y, clr.z, clr.w );

		sprintf ( msg, "%s", mCalls[cid].name.c_str() );  
		drawText ( xoff+5, yoff + c*15+15, msg, 1,1,1,1 );

		sprintf ( msg, "%02d  %d %d", mCalls[cid].bin_id, mCalls[cid].size, mCalls[cid].val_id );
		drawText ( xoff+130, yoff + c*15+15, msg, 1,1,1,1 );
	}
	end2D ();
	
	

	#ifdef USE_DX
		g_pContext->OMSetDepthStencilState( g_pDepthStencilState, 1 );
	#endif
}
Beispiel #5
0
void drawMatrix ()
{
	Vector3DF id_clr;
	float ypos, yposl;
	int b, num = (int) mEvents.size();	

	Matrix4F proj, view, model;
	proj.Scale ( 2.0/window_width, -2.0/window_height, 1 );		
	model.Translate ( cam.getToPos().x, cam.getToPos().y, 1 );
	view.Scale ( cam.getToPos().z, 1, 1 );
	view *= model;
	model.Identity ();

	//----- 2D Drawing (visualizer space)		
	setview2D ( model.GetDataF(), view.GetDataF(), proj.GetDataF() );
	setorder2D ( false, 1 );

	// Event ID	bars	
	static2D ();	
	int fl = -1;
	char msg[100];
	for (int n=0; n < num; n++ ) {
		if ( mEvents[n].frame != fl ) {
			sprintf ( msg, "frame %d", mEvents[n].frame ); drawText ( n*10, -2, msg, 1,1,1,1 );
		}
		for (b=0; b < NUM_BIN; b++) {
			if ( mEvents[n].bin_id[b] == -1  ) {
				id_clr.Set ( 1, 1, 1 );
			} else if ( mEvents[n].bin_change[b] == 0 ) {
				id_clr.Set ( .2, .2, .2 );
			} else {
				id_clr = getClr ( mEvents[n].bin_id[b] + b*16384 );
			}
			drawFill ( n*10.0, b*25, n*10+10.0, b*25+24, id_clr.x, id_clr.y, id_clr.z, 1 );						
		}
		fl = mEvents[n].frame;
	}
	end2D ();

	// Change State bars
	static2D ();
	for (int n=0; n < num; n++ ) {
		for (b=0; b < NUM_BIN; b++) {
			if ( mEvents[n].bin_id[b] != -1 ) {
				switch ( mEvents[n].bin_change[b] ) {
				case BIN_NOTUSED:		id_clr.Set ( .2, .2, .2 );	break;		
				case BIN_CREATE:		id_clr.Set ( 1, 0, 0 );		break;
				case BIN_CHANGE:		id_clr.Set ( 1, 0, 0 );		break;
				case BIN_SWITCH:		id_clr.Set ( 1, .5, 0 );	break;
				case BIN_REUSE:		id_clr.Set ( 0, 1, 0 );		break;
				};				
				drawTri ( n*10, b*25, n*10+10, b*25, n*10, b*25+10, id_clr.x, id_clr.y, id_clr.z, 1 );
			}
		}
	}
	end2D ();

	int ys = NUM_BIN*25;
		
	// Prim count bars
	static2D();
	b = BIN_DRAW;
	for (int n=0; n < num; n++ ) {
		id_clr = getClr ( mEvents[n].bin_id[9] + 9*16384 );	
		ypos = mEvents[n].bin_id[ b ] * 400 / mMaxPrim;		// prim count
		if ( ypos > 100 ) ypos = 100;		
		drawFill ( n*10, ys+(125-ypos), n*10+10, ys+125, id_clr.x, id_clr.y, id_clr.z, 1 );
	}
	end2D ();
	
	// Mem transfer line
	static2D();
	yposl = 0;
	b = BIN_SIZE;
	for (int n=0; n < num; n++ ) {
		id_clr.Set(1,1,1);		
		ypos = mEvents[n].bin_size[ b ] * 100 / mMaxSize;		// size (bytes)
		if ( ypos > 100 ) ypos = 100;		
		drawLine ( n*10+5, ys+(250-ypos), n*10-5, ys+(250-yposl), 1, 1, 1, 1 );
		yposl = ypos;
	}
	drawLine ( 5, ys+250, num*10-5, ys+250, .5, .5, .5, 1 );
	end2D ();
}
Beispiel #6
0
void Player::draw() {
	h.draw();
	drawTri();
}
//Draws the 3D scene
void drawScene() {
	int i;
	//Clear information from last draw
	glClear(GL_COLOR_BUFFER_BIT);
	
	glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
	glLoadIdentity(); //Reset the drawing perspective
	
	glColor3f(0.0f,0.0f,0.0f);
	glBegin(GL_QUADS);
	glVertex3f(-2.0f,-2.0f,-5.0f);
	glVertex3f(-2.0f,2.0f,-5.0f);
	glVertex3f(2.0f,2.0f,-5.0f);
	glVertex3f(2.0f,-2.0f,-5.0f);
	glEnd();//outer black quad
	
	glColor3f(0.99f, 0.84f, 0.61f);
	glBegin(GL_QUADS);
	glVertex3f(-1.8f,-1.8f,-5.0f);
	glVertex3f(-1.8f,1.8f,-5.0f);
	glVertex3f(1.8f,1.8f,-5.0f);
	glVertex3f(1.8f,-1.8f,-5.0f);
	glEnd();//board 
	
	glColor3f(0.0f,0.0f,0.0f);
	drawDisc(0.0f,0.0f,0.42f,1000);
	glColor3f(0.99f, 0.84f, 0.61f);
	drawDisc(0.0f,0.0f,0.40f,1000);
	glColor3f(0.0f, 0.0f, 0.0f);
	drawDisc(0.0f,0.0f,0.38f,1000);
	glColor3f(0.99f, 0.84f, 0.61f);
	drawDisc(0.0f,0.0f,0.36f,1000);//central circle
	
	glColor3f(0.0f,0.0f,0.0f);
	drawDisc(0.0f,0.0f,0.08f,1000);
	glColor3f(1.0f,0.0f,0.0f);
	drawDisc(0.0f,0.0f,0.06f,1000);//central disc
	
	
	
	drawCircle(0.0f,0.0f,0.08f);
	drawTri();//for stars
	
	for(i=0;i<4;i++){
	//symmetric codes
	glColor3f(0.52f, 0.37f, 0.26f);
	drawDisc(1.69f, 1.69f, 0.11f,1000);//holes
	
	//drawArc(0.6f,0.6f,0.2121f);
	glColor3f(0.0f, 0.0f, 0.0f);
	//drawArc(0.6f,0.6f,0.2121f);
	glBegin(GL_LINE_STRIP);
	glVertex3f(0.45f,0.45f,-5.0f);//45 degree line
	glVertex3f(1.4f,1.4f,-5.0f);
	glBegin(GL_LINE_STRIP);
	glVertex3f(1.4f,1.4f,-5.0f);//arrows
	glVertex3f(1.36f,1.4f,-5.0f);
	glVertex3f(1.4f,1.4f,-5.0f);//arrows
	glVertex3f(1.4f,1.36f,-5.0f);
	glEnd();
	drawArc(0.6f,0.6f,0.2121f);
		
	glColor3f(0.0f,0.0f,0.0f);
	glBegin(GL_QUADS);//base line
	glVertex3f(1.1f, 1.2f, -5.0f);
	glVertex3f(1.1f, 1.21f, -5.0f);
	glVertex3f(-1.1f, 1.21f, -5.0f);
	glVertex3f(-1.1f, 1.2f, -5.0f);
	
	glVertex3f(1.1f, 1.35f, -5.0f);
	glVertex3f(1.1f, 1.33f, -5.0f);
	glVertex3f(-1.1f, 1.33f, -5.0f);
	glVertex3f(-1.1f, 1.35f, -5.0f);
	glEnd();
	
	glColor3f(1.0f, 0.0f, 0.0f);//base line circles
	drawDisc(1.1f, 1.275f, 0.075f,1000);
	drawDisc(-1.1f, 1.275f, 0.075f,1000);
	glColor3f(0.0f,0.0f,0.0f);
	drawCircle(1.1f, 1.275f, 0.075f);
	drawCircle(-1.1f, 1.275f, 0.075f);
	glRotatef(90.0f,0.0f,0.0f,1.0f);
	}
	reDraw();
	glutSwapBuffers(); //Send the 3D scene to the screen
}
Beispiel #8
0
void drawTris( list<PhantomTriangle *>& pTri, const Vector& stain )
{
  for( list<PhantomTriangle*>::iterator iter = pTri.begin() ; iter != pTri.end(); ++ iter )
    drawTri( *iter, stain ) ;
}
Beispiel #9
0
void drawTri( PhantomTriangle * pTri, const Vector& color )
{
  drawTri( 0, pTri, color ) ;
}
Beispiel #10
0
void drawHabitat() {
	for(int i=0; i<habcount; i++) {
	drawTri(habitat[i].topleft, habitat[i].topright, habitat[i].botright);
	}
}
Beispiel #11
0
void drawWalls() {
	for(int i=0; i<tricount; i++) {
	drawTri(triangle[i].topleft, triangle[i].topright, triangle[i].botright);
	}
}