void retargetLocator::drawDiscAll( float lineAlpha, float fillAlpha ) { MPointArray radPoints; getRadPoints( radPoints ); MColor cuColor; if( viewMode == 0 ) cuColor = discActiveColor; else if( viewMode == 1 ) cuColor = discLeadColor; else cuColor = discDefaultColor; glColor4f( cuColor.r, cuColor.g, cuColor.b, lineAlpha ); glBegin( GL_LINE_LOOP ); drawDisc( radPoints ); glEnd(); if( fillAlpha > 0.0f ) { glColor4f( cuColor.r, cuColor.g, cuColor.b, fillAlpha ); glBegin( GL_POLYGON ); drawDisc( radPoints ); glEnd(); } }
//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 }
void reDraw() { if(isInHole[5]=='y' && ((isInHole[1]=='y' && isInHole[2]=='y') || (isInHole[3]=='y' && isInHole[4]=='y') )) { if(score_2p[0] > score_2p[1]) printf("PLAYER1 WINS\n"); else if(score_2p[0] < score_2p[1]) printf("PLAYER2 WINS\n"); else printf("TIE!!\n"); } char buffer[256]; int i,n; //draw dir arrows if(dir == 'y' && chance[1] == 'y') { glColor3f(0.0f,0.0f,0.0f); glBegin(GL_LINE_STRIP); glVertex3f(dir_x,dir_y,-5.0f); glVertex3f(X[0],Y[0],-5.0f); glEnd(); } //condition for collision check_collision(Vx,Vy,r_str,r_cn); //striker if(isInHole[0] == 'n') check_str_wall(Vx,Vy); //condition for striker going into the holes if((distance(X[0],Y[0],1.69f,1.69f)<=0.11f||distance(X[0],Y[0],1.69f,-1.69f)<=0.11f||distance(X[0],Y[0],-1.69f,-1.69f)<=0.11f|| distance(X[0],Y[0],-1.69f,1.69f)<=0.11f)) { isInHole[0]='y'; X[0] = 2.0f; Y[0] = 2.0f; Vx[0] = 0.0f; Vy[0] = 0.0f; } if(isInHole[0]=='n') //draw striker { glColor3f(0.8f,0.5f,0.2f); drawDisc(X[0],Y[0],r_str,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[0],Y[0],r_str-0.04f,1000); glColor3f(0.8f,0.5f,0.2f); drawDisc(X[0],Y[0],r_str-0.05f,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[0],Y[0],0.01f,1000); } //coins for(i=1;i<6;i++) { glColor3f(0.0f,0.0f,1.0f); if(isInHole[i] == 'n') check_cn_wall(Vx,Vy,i);//for striking with wall //condition for coin1 going into holes if((distance(X[i],Y[i],1.69f,1.69f)<=0.11f||distance(X[i],Y[i],1.69f,-1.69f)<=0.11f||distance(X[i],Y[i],-1.69f,-1.69f)<=0.11f|| distance(X[i],Y[i],-1.69f,1.69f)<=0.11f)) { isInHole[i]='y'; X[i] = 2.0f; Y[i] = 2.0f; Vx[i] = 0.0f; Vy[i] = 0.0f; } if(isInHole[i] == 'n') { if(i==1 || i==2)//black coins { glColor3f(0.19f,0.19f,0.19f); drawDisc(X[i],Y[i],r_cn,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[i],Y[i],r_cn-0.03f,1000); glColor3f(0.19f,0.19f,0.19f); drawDisc(X[i],Y[i],r_cn-0.04f,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[i],Y[i],0.01f,1000); } if(i==3 || i==4)//white coins { glColor3f(0.76f,0.76f,0.76f); drawDisc(X[i],Y[i],r_cn,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[i],Y[i],r_cn-0.03f,1000); glColor3f(0.76f,0.76f,0.76f); drawDisc(X[i],Y[i],r_cn-0.04f,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[i],Y[i],0.01f,1000); } if(i==5) { glColor3f(0.8f,0.0f,0.0f); drawDisc(X[i],Y[i],r_cn,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[i],Y[i],r_cn-0.03f,1000); glColor3f(0.8f,0.0f,0.0f); drawDisc(X[i],Y[i],r_cn-0.04f,1000); glColor3f(0.8f,0.2f,0.2f); drawDisc(X[i],Y[i],0.01f,1000); } } } //variable alpha exists so as to make sure that board is made once and then it waits for data if(chance[1]=='n') { if(alpha!=0 && isStrikerHitByOther=='n') { bzero(buffer,256); n = read(sockfd,buffer,255); if (n < 0) error("ERROR reading from socket");//data reading //perform decode decode_copy(buffer); dir = 'n'; } alpha=1; } update_chance(Vx,Vy,chance); }
void BasicLocator::draw(M3dView& view, const MDagPath&, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { MPlug pDrawit(thisMObject(), aIsDrawing); bool drawItV; pDrawit.getValue(drawItV); if (drawItV == false) return; MPlug pTransparent(thisMObject(), aIsTransparent); MPlug pShapeColor(thisMObject(), aShapeColor); MPlug pShapeType(thisMObject(), aShapeType); float r, g, b, a; MObject color; //glStart view.beginGL(); //setup states glPushAttrib(GL_CURRENT_BIT); glDepthMask(GL_FALSE); //setup for draw colors for maya(active, lead etc) MColor solidColor, wireColor; switch (status) { case M3dView::kActive: //white solidColor = MColor(1.0f, 1.0f, 1.0f, 0.1f); break; case M3dView::kLead: //green solidColor = MColor(0.26f, 1.0f, 0.64f, 0.1f); break; case M3dView::kActiveAffected: // maya magenta solidColor = MColor(0.78f, 1.0f, 0.78f); break; case M3dView::kTemplate: // maya template gray solidColor = MColor(0.47f, 0.47f, 0.47f); break; case M3dView::kActiveTemplate: // maya selected template pink solidColor = MColor(1.0f, 0.47f, 0.47f); break; default: pShapeColor.getValue(color); MFnNumericData data(color); data.getData(r, g, b); pTransparent.getValue(a); if (a < 1.0f) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } solidColor = MColor(r, g, b, a); //draw the solidColor glColor4f(solidColor.r, solidColor.g, solidColor.b, solidColor.a); } int sType; pShapeType.getValue(sType); switch (sType) { case 0: drawArrow(); case 1: drawDisc(1.0, 32, true); default : drawArrow(); } glDepthMask(GL_TRUE); glDisable(GL_BLEND); glPopAttrib(); view.endGL(); }