void GPUOctree::drawBoxNode(const XYZ& center, float size, int x, int y) const { drawBox(center, size); int pools = x * 2; int poolt = y * 2; float halfSize = size/2; XYZ halfCenter; for (int k=0;k<2;k++) { for (int j=0;j<2;j++) { for (int i=0;i<2;i++) { unsigned long poolloc = (poolt + j)*INDIRECTIONPOOLWIDTH + pools + i; if(i==0) halfCenter.x = center.x - halfSize; else halfCenter.x = center.x + halfSize; if(j==0) halfCenter.y = center.y - halfSize; else halfCenter.y = center.y + halfSize; if(k==0) halfCenter.z = center.z - halfSize; else halfCenter.z = center.z + halfSize; if(k==0) { x = m_idr[poolloc*4]; y = m_idr[poolloc*4+1]; if(x >=0) drawBoxNode(halfCenter, halfSize, x, y); } else { x = m_idr[poolloc*4+2]; y = m_idr[poolloc*4+3]; if(x >=0) drawBoxNode(halfCenter, halfSize, x, y); } } } } }
void ScummDebugger::printBox(int box) { if (box < 0 || box >= _vm->getNumBoxes()) { DebugPrintf("%d is not a valid box!\n", box); return; } BoxCoords coords; int flags = _vm->getBoxFlags(box); int mask = _vm->getMaskFromBox(box); int scale = _vm->getBoxScale(box); _vm->getBoxCoordinates(box, &coords); // Print out coords, flags, zbuffer mask DebugPrintf("%d: [%d x %d] [%d x %d] [%d x %d] [%d x %d], flags=0x%02x, mask=%d, scale=%d\n", box, coords.ul.x, coords.ul.y, coords.ll.x, coords.ll.y, coords.ur.x, coords.ur.y, coords.lr.x, coords.lr.y, flags, mask, scale); // Draw the box drawBox(box); }
void QGLE::drawOSnap(QPainter *p, QPair<QPointF, int> snap) { p->setPen(osnapPen()); // Switch on snap.second switch(snap.second) { case PerpendicularSnap: drawPerpMark(p,snap.first,osnapPen()); break; case TangentSnap: drawTangentMark(p,snap.first,osnapPen()); break; case IntersectSnap: drawIntersectMark(p, snap.first, osnapPen()); break; default: drawBox(p,snap.first,OSNAP_BOX_SIZE,osnapPen()); } }
unsigned int nRenderer::drawNode(nRTreeNode *node, unsigned int lev){ if(node->isNull() || (node->isLeaf() && node->getChildren().size() == 1)) { return 0; } unsigned int nodes = 1; unsigned int mod = lev % 7 + 1; glColor3d((mod & 0b001) ? 1 : 0, (mod & 0b010) ? 1 : 0, (mod & 0b100) ? 1 : 0); DrawMode m = getDrawMode(); setDrawMode(WireFrame); setAttribute(BackFaceCulling, false); drawBox(nBoundingBox::create(node->getNegative(), node->getPositive())); if(!node->isLeaf()) { list<nRTreeNode *> lst = node->getSubNodes(); for(list<nRTreeNode *>::iterator it = lst.begin(); it != lst.end(); it++) { nodes += drawNode(*it, lev + 1); } } setAttribute(BackFaceCulling, true); setDrawMode(m); nMaterial::release(); return nodes; }
void drawCursor() { Entity *e; if (cursor.type == TILES) { drawImage(tileImage(cursor.tileID), cursor.x, cursor.y, FALSE, 255); drawImage(tileImage(BLANK_TILE), cursor.x, cursor.y, FALSE, 255); } else { e = isSpaceEmpty(&cursor.entity); if (isValidOnMap(&cursor.entity) == 0 || e != NULL) { drawBox(game.screen, cursor.x, cursor.y, cursor.entity.w, cursor.entity.h, 255, 0, 0); } if (e != NULL) { setStatusPanelMessage("%s : %d %d", (strlen(e->objectiveName) == 0 ? e->name : e->objectiveName), (int)e->x, (int)e->y); } else { setStatusPanelMessage(""); } cursor.entity.x = getMapStartX() + cursor.x; cursor.entity.y = getMapStartY() + cursor.y; self = &cursor.entity; self->draw(); } }
void RadioButton::draw(Graphics* graphics) { graphics->pushClipArea(Rectangle(1, 1, getWidth() - 1, getHeight() - 1)); drawBox(graphics); graphics->popClipArea(); graphics->setFont(getFont()); graphics->setColor(getForegroundColor()); if (isFocused()) { int fh; if (getHeight()%2 == 0) { fh = getHeight() - 4; } else { fh = getHeight() - 3; } int hh = (fh + 1) / 2; graphics->drawLine(0, hh + 1, hh + 1, 0); graphics->drawLine(hh + 2, 1, fh + 2, hh + 1); graphics->drawLine(fh + 1, hh + 2, hh + 1, fh + 2); graphics->drawLine(hh + 1, fh + 2, 1, hh + 2); } int h = getHeight() + getHeight() / 2; graphics->drawText(getCaption(), h - 2, 0); }
void GLWidget::paintGL() { glClearColor(0.0, 0.3, 0.0, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); drawInfo(); m_camera->setUp(); m_light->setUp(); m_forklift->draw(); drawBox(); glFlush(); }
// Select a card to play void printSelect(GlobalState* globalData) { // LCD menu clean(RED); drawBoxFill(0, 0, 20, V - 1, RED); drawBox(0, 0, 20, V - 1, 2, WHITE); // Prints messages to LCD based off of keypad input switch(globalData->keyStatus) { case 0: prints(35, 7, WHITE, RED, "Choose a card by its slot number:", 1); break; case 1: prints(35, 7, WHITE, RED, "Invalid input. Please enter a key between 1 to 4:", 1); break; case 2: prints(35, 7, WHITE, RED, "No card found. Please try again:", 1); break; } // Display commands to select a slot - the LED's should indicate if a card is read prints(35, 30, WHITE, BLACK, "Slot 1", 1); prints(35, 60, WHITE, BLACK, "Slot 2", 1); prints(35, 90, WHITE, BLACK, "Slot 3", 1); prints(35, 120, WHITE, BLACK, "Slot 4", 1); }
void PainterShow (KinoWidget w, LargeRegion r, Boolean move) { #ifdef DEBUG fprintf (stderr, "+++ %s: (%d|%d)-(%dx%d)\n", __PRETTY_FUNCTION__, r.x, r.y, r.width, r.height); #endif if (XtWindow (w) != None && w->kino.document && w->kino.painterEnable) { /* move all insets to their new places */ if (move) PainterRepositionInsets (w); /* clear the exposed area */ XClearArea (XtDisplay (w), XtWindow (w), r.x, r.y, r.width, r.height, False); /* draw all Node elements */ drawBox (w, w->kino.document->root, 0, 0, r); } }
void drawSkyDome(Vector position, int size, Texture *texture) { glDepthMask(GL_FALSE); glDisable(GL_FOG); glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(GL_TEXTURE_2D, texture->data); drawBox(position, 24, 24, 24, mission->skySphereSize); glEnable(GL_FOG); glDepthMask(GL_TRUE); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); }
void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glTranslatef(-0.2, 0, 0); // 平移 //glScalef(2, 1, 1); // 缩放 times++; if(times > 100) { times = 0; } if(times % 100 == 0) { rotate += 0.3; } glRotatef(rotate, 0, 1, 0); glRotatef(rotate, 1, 0, 0); // glColor3f(1, 0, 0); // // DrawCube(); drawBox(0,0,0,0.5,0.5,0.5); glPopMatrix(); glutSwapBuffers(); }
void drawTowerExplain() { int startX = 125; int startY = 20; drawBox(startX,startY,40,22,0); mvaddstr(startY+2,startX+8,"Tower Types"); mvaddch(startY+4, startX+3, basicLine | A_ALTCHARSET); mvaddstr(startY+4,startX+5,"- Single shot tower (Attacks only"); mvaddstr(startY+5,startX+5," a single unit at a time)"); mvaddch(startY+7, startX+3, AOE | A_ALTCHARSET); mvaddstr(startY+7,startX+5,"- Area of effect tower (Attacks"); mvaddstr(startY+8,startX+5," all units in the area)"); mvaddch(startY+10, startX+3, bomb | A_ALTCHARSET); mvaddstr(startY+10,startX+5,"- Bomb tower (Attacks one unit,"); mvaddstr(startY+11,startX+5," and does splash damage to"); mvaddstr(startY+12,startX+5," nearby units)"); mvaddch(startY+14, startX+3, collat | A_ALTCHARSET); mvaddstr(startY+14,startX+5,"- Collateral (Attacks one unit,"); mvaddstr(startY+15,startX+5," and chains to multiple"); mvaddstr(startY+16,startX+5," following units)"); mvaddch(startY+18, startX+3, reset | A_ALTCHARSET); mvaddstr(startY+18,startX+5,"- Reset tower (Moves a unit to"); mvaddstr(startY+19,startX+5," the beginning of the pathway)"); }
static void drawTree( btIDebugDraw* idraw, const btDbvtNode* node, int depth, const btVector3& ncolor, const btVector3& lcolor, int mindepth, int maxdepth) { if(node) { if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0))) { drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth); drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth); } if(depth>=mindepth) { const btScalar scl=(btScalar)(node->isinternal()?1:1); const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl; const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl; drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor); } } }
void perceptualGrouping(CCL_Object positiveSource,CCL_Object negativeSource,IplImage *img) { printf("Performing perceptual grouping...\n"); IplImage *displayImage = cvCreateImage(cvSize(img->width,img->height),IPL_DEPTH_8U,3); cvCvtColor(img,displayImage,CV_GRAY2BGR); int positiveMappings[positiveSource.classCount]; for(int i = 0;i < positiveSource.classCount;i++){ positiveMappings[i] = -1;} int negativeMappings[negativeSource.classCount]; for(int i = 0;i < negativeSource.classCount;i++){ negativeMappings[i] = -1;} //POSITIVE PASS //count the number of non-zero classes int c = 0; for(int i = 0;i < positiveSource.classCount;i++) { if(positiveSource.classSizes[i] > 0) c++; } //build the blob data structure Blob positiveBlobs[c]; int p = 0; for(int i = 0;i < positiveSource.classCount;i++) { if(positiveSource.classSizes[i] > 0) { positiveBlobs[p].size = positiveSource.classSizes[i]; positiveBlobs[p].top.i = positiveSource.minI[i]; positiveBlobs[p].top.j = positiveSource.minJ[i]; positiveBlobs[p].bottom.i = positiveSource.maxI[i]; positiveBlobs[p].bottom.j = positiveSource.maxJ[i]; positiveBlobs[p].centre = findCentre(positiveBlobs[p].top,positiveBlobs[p].bottom); positiveBlobs[p].linked = -1; positiveBlobs[p].group = -1; positiveMappings[i] = p; p++; } } int groupCount = 0; for(int i = 0;i < c;i++) { float maxPilu = 0; int pointer = 0; for(int j = 0;j < c;j++) { if(i != j && positiveBlobs[j].linked != i) { float pilu = piluOperator(positiveBlobs[i].top,positiveBlobs[i].bottom,positiveBlobs[j].top,positiveBlobs[j].bottom); if(pilu > maxPilu) { maxPilu = pilu; pointer = j; } } } if(maxPilu >= PILULIMIT) { positiveBlobs[i].next = positiveBlobs[pointer].centre; positiveBlobs[i].linked = pointer; //update groups if(positiveBlobs[i].group == -1) //i.e new group { if(positiveBlobs[pointer].group != -1) //ie next is already in a group { //update group equivalences for(int k = 0;k < c;k++) { if(positiveBlobs[k].group == positiveBlobs[pointer].group) positiveBlobs[k].group = groupCount; } } positiveBlobs[pointer].group = groupCount; positiveBlobs[i].group = groupCount; groupCount++; } else { if(positiveBlobs[pointer].group == -1) positiveBlobs[pointer].group = positiveBlobs[i].group; else { //update group equivalences for(int k = 0;k < c;k++) { if(positiveBlobs[k].group == positiveBlobs[pointer].group) positiveBlobs[k].group = positiveBlobs[i].group; } } } //draw line, image, pt1, pt2, colour, thickness, type, offset cvLine(displayImage,cvPoint(positiveBlobs[i].centre.j,positiveBlobs[i].centre.i),cvPoint(positiveBlobs[i].next.j,positiveBlobs[i].next.i),cvScalar(155,0,0,0),2,8,0); } } ///////////////////////////////////////////////////////////////////////// //NEGATIVE PASS //count the number of non-zero classes int n = 0; for(int i = 0;i < negativeSource.classCount;i++) { if(negativeSource.classSizes[i] > 0) n++; } //build the blob data structure Blob negativeBlobs[n]; p = 0; for(int i = 0;i < negativeSource.classCount;i++) { if(negativeSource.classSizes[i] > 0) { negativeBlobs[p].size = negativeSource.classSizes[i]; negativeBlobs[p].top.i = negativeSource.minI[i]; negativeBlobs[p].top.j = negativeSource.minJ[i]; negativeBlobs[p].bottom.i = negativeSource.maxI[i]; negativeBlobs[p].bottom.j = negativeSource.maxJ[i]; negativeBlobs[p].centre = findCentre(negativeBlobs[p].top,negativeBlobs[p].bottom); negativeBlobs[p].linked = -1; negativeBlobs[p].group = -1; negativeMappings[i] = p; p++; } } for(int i = 0;i < n;i++) { float maxPilu = 0; int pointer = 0; for(int j = 0;j < n;j++) { if(i != j && negativeBlobs[j].linked != i) { float pilu = piluOperator(negativeBlobs[i].top,negativeBlobs[i].bottom,negativeBlobs[j].top,negativeBlobs[j].bottom); if(pilu > maxPilu) { maxPilu = pilu; pointer = j; } } } if(maxPilu >= PILULIMIT) { negativeBlobs[i].next = negativeBlobs[pointer].centre; negativeBlobs[i].linked = pointer; //update groups if(negativeBlobs[i].group == -1) //i.e new group { if(negativeBlobs[pointer].group != -1) //ie next is already in a group { //update group equivalences for(int k = 0;k < n;k++) { if(negativeBlobs[k].group == negativeBlobs[pointer].group) negativeBlobs[k].group = groupCount; } } negativeBlobs[pointer].group = groupCount; negativeBlobs[i].group = groupCount; groupCount++; } else { if(negativeBlobs[pointer].group == -1) negativeBlobs[pointer].group = negativeBlobs[i].group; else { //update group equivalences for(int k = 0;k < n;k++) { if(negativeBlobs[k].group == negativeBlobs[pointer].group) negativeBlobs[k].group = negativeBlobs[i].group; } } } //draw line, image, pt1, pt2, colour, thickness, type, offset cvLine(displayImage,cvPoint(negativeBlobs[i].centre.j,negativeBlobs[i].centre.i),cvPoint(negativeBlobs[i].next.j,negativeBlobs[i].next.i),cvScalar(155,0,0,0),2,8,0); } } ///////////////////////////////////////////////////////////////// //array of BBoxes BBox boxes[groupCount]; //build BBoxes for(int i = 0;i < groupCount;i++) { //initialise box - inside out boxes[i].top.i = 9999; boxes[i].top.j = 9999; boxes[i].bottom.i = -1; boxes[i].bottom.j = -1; boxes[i].size = 0; //for each positive blob for(int j = 0;j < c;j++) { //if its in this group if(positiveBlobs[j].group == i) { //add it to the bbox boxes[i].size++; boxes[i] = extendBox(boxes[i],positiveBlobs[j].top,positiveBlobs[j].bottom); } } //for each negative blob for(int j = 0;j < n;j++) { //if its in this group if(negativeBlobs[j].group == i) { //add it to the bbox boxes[i].size++; boxes[i] = extendBox(boxes[i],negativeBlobs[j].top,negativeBlobs[j].bottom); } } } //for each box for(int i = 0;i < groupCount;i++) { //if its got more than one thing in it //printf("%i \n",boxes[i].size); if(boxes[i].size > 1) { //draw it drawBox(boxes[i],displayImage); } } //show the image cvSaveImage("grouping.png",displayImage); cvNamedWindow("ImageWindow", CV_WINDOW_AUTOSIZE); cvShowImage("ImageWindow", displayImage); printf("Image displayed...\n"); //wait till key is pressed printf("PRESS A KEY NOW...\n"); cvWaitKey(0); //update img int target[positiveSource.height][positiveSource.width]; for(int i = 0;i < positiveSource.height;i++) { for(int j = 0;j < positiveSource.width;j++) { int pos = positiveSource.labels[(i * positiveSource.width) + j]; pos = positiveMappings[pos]; if(pos != -1) { pos = positiveBlobs[pos].group; pos = boxes[pos].size; } int neg = negativeSource.labels[(i * negativeSource.width) + j]; //int neg = -1; neg = negativeMappings[neg]; if(pos != -1) { neg = negativeBlobs[neg].group; neg = boxes[neg].size; } if(pos > 1 || neg > 1) { target[i][j] = 255; }else { target[i][j] = 0; } } } uchar* data = (uchar *)img->imageData; //copy new data into image for(int i = 0; i < positiveSource.height;i++) { for(int j = 0; j < positiveSource.width; j++) { data[(i*img->widthStep) + j ] = target[i][j]; //printf("%i %i %u \n",i,j,test[i][j]); } } img->imageData = (char*)data; printf("Done\n"); }
void EndLevel::draw() { if(m_visible) { txtcord+=dirmov*ft; const Vector3D m_taille=m_size; double mosaic=1; Lighting::getInstance()->glEnableLighting(); if(m_selected) drawBox(); glColor4ub(255,255,255,255); if(m_texture!=NULL) m_texture->bind(); glPushMatrix(); glTranslated(m_position.X,m_position.Y,m_position.Z); Lighting::getInstance()->glDisableLighting(); glTranslated(0,0,m_taille.Z*2*0); glDisable(GL_CULL_FACE); m_texture->bind(); glBlendFunc(GL_SRC_ALPHA,GL_ONE); glEnable(GL_BLEND); glBegin(GL_QUADS); glNormal3d(0.0,1.0,0.0); glTexCoord2d(0-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(m_taille.X,m_taille.Y,m_taille.Z*2); glTexCoord2d(0-txtcord.Y/100,0-txtcord.X/100); glVertex3d(m_taille.X,m_taille.Y,0); glTexCoord2d(m_taille.X*2/mosaic-txtcord.Y/100,0-txtcord.X/100); glVertex3d(-m_taille.X,m_taille.Y,0); glTexCoord2d(m_taille.X*2/mosaic-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(-m_taille.X,m_taille.Y,m_taille.Z*2); glNormal3d(1.0,0.0,0.0); glTexCoord2d(0-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(m_taille.X,-m_taille.Y,m_taille.Z*2); glTexCoord2d(0-txtcord.Y/100,0-txtcord.X/100); glVertex3d(m_taille.X,-m_taille.Y,-m_taille.Z*0); glTexCoord2d(m_taille.Y*2/mosaic-txtcord.Y/100,0-txtcord.X/100); glVertex3d(m_taille.X,m_taille.Y,-m_taille.Z*0); glTexCoord2d(m_taille.Y*2/mosaic-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(m_taille.X,m_taille.Y,m_taille.Z*2); glNormal3d(0.0,-1.0,0.0); glTexCoord2d(0-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(-m_taille.X,-m_taille.Y,m_taille.Z*2); glTexCoord2d(0-txtcord.Y/100,0-txtcord.X/100); glVertex3d(-m_taille.X,-m_taille.Y,-m_taille.Z*0); glTexCoord2d(m_taille.X*2/mosaic-txtcord.Y/100,0-txtcord.X/100); glVertex3d(m_taille.X,-m_taille.Y,-m_taille.Z*0); glTexCoord2d(m_taille.X*2/mosaic-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(m_taille.X,-m_taille.Y,m_taille.Z*2); glNormal3d(-1.0,0.0,0.0); glTexCoord2d(0-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(-m_taille.X,m_taille.Y,m_taille.Z*2); glTexCoord2d(0-txtcord.Y/100,0-txtcord.X/100); glVertex3d(-m_taille.X,m_taille.Y,-m_taille.Z*0); glTexCoord2d(m_taille.Y*2/mosaic-txtcord.Y/100,0-txtcord.X/100); glVertex3d(-m_taille.X,-m_taille.Y,-m_taille.Z*0); glTexCoord2d(m_taille.Y*2/mosaic-txtcord.Y/100,m_taille.Z*2/mosaic-txtcord.X/100); glVertex3d(-m_taille.X,-m_taille.Y,m_taille.Z*2); glEnd(); glDisable(GL_BLEND); glPopMatrix(); glColor3ub(255,255,255); Lighting::getInstance()->glEnableLighting(); } }
//senquack - partial conversion to fixed point //void drawTitle() { // int i; // int r, g, b; // int sx, sy; // char *stgChr = "STAGE"; // char *quitChr = "QUIT"; // char *mdChr[] = {"NORMAL MODE", "PSY MODE", "IKA MODE", "GW MODE"}; // int mdChrX[] = {270, 330, 330, 350}; // char mdIni[] = {'N', 'P', 'I', 'G'}; // drawTitleBoard(); // // for ( i=-MODE_NUM ; i<STAGE_NUM+1 ; i++ ) { // if ( i < 0 ) { // if ( 4+i == mode ) { // r = 100; g = 100; b = 240; // } else { // r = 150; g = 150; b = 200; // } // } else if ( i < QUIT_STAGE_NUM && hiScore.cleard[mode][i] ) { // r = 240; g = 180; b = 180; // } else { // r = 210; g = 210; b = 240; // } // sx = stageX[i+MODE_NUM]; sy = stageY[i+MODE_NUM]; // if ( i == slcStg ) { // int sz = STG_BOX_SIZE*3/2; // if ( titleCnt < 16 ) sz = sz*titleCnt/16; // drawBox(sx, sy, sz, sz, r, g, b); // sz = sz*3/5; // if ( i < 0 ) { // int md = MODE_NUM+i; // drawString(mdChr[md], mdChrX[md], 133, 12, 0, 150, 150, 200); // drawLetter(mdIni[md]-'A'+10, sx, sy, sz, 0, 150, 150, 240); // } else if ( i < QUIT_STAGE_NUM ) { // makeStageStr(i); // drawString(stageStr, sx-sz, sy, sz, 0, 210, 210, 240); // drawString(stgChr, 330, 133, 12, 0, 210, 210, 240); // drawString(stageStr, 445, 133, 12, 0, 210, 210, 240); // drawNumCenter(hiScore.score[mode][i], 466, 168, 12, 210, 210, 240); // } else { // drawLetter('Q'-'A'+10, sx, sy, sz, 0, 210, 210, 240); // drawString(quitChr, 410, 133, 12, 0, 210, 210, 240); // } // } else { // drawBox(sx, sy, STG_BOX_SIZE/2, STG_BOX_SIZE/2, r*2/3, g*2/3, b*2/3); // } // } // drawString(mdChr[mode], mdChrX[mode], 455, 12, 0, 150, 150, 200); //} void drawTitle() { int i; int r, g, b; int sx, sy; char *stgChr = "STAGE"; char *quitChr = "QUIT"; char *mdChr[] = {"NORMAL MODE", "PSY MODE", "IKA MODE", "GW MODE"}; int mdChrX[] = {270, 330, 330, 350}; char mdIni[] = {'N', 'P', 'I', 'G'}; drawTitleBoard(); for ( i=-MODE_NUM ; i<STAGE_NUM+1 ; i++ ) { if ( i < 0 ) { if ( 4+i == mode ) { r = 100; g = 100; b = 240; } else { r = 150; g = 150; b = 200; } } else if ( i < QUIT_STAGE_NUM && hiScore.cleard[mode][i] ) { r = 240; g = 180; b = 180; } else { r = 210; g = 210; b = 240; } sx = stageX[i+MODE_NUM]; sy = stageY[i+MODE_NUM]; if ( i == slcStg ) { int sz = STG_BOX_SIZE*3/2; if ( titleCnt < 16 ) sz = sz*titleCnt/16; #ifdef FIXEDMATH drawBox(INT2FNUM(sx), INT2FNUM(sy), INT2FNUM(sz), INT2FNUM(sz), r, g, b); #else drawBox(sx, sy, sz, sz, r, g, b); #endif //FIXEDMATH sz = sz*3/5; if ( i < 0 ) { int md = MODE_NUM+i; drawString(mdChr[md], mdChrX[md], 133, 12, 0, 150, 150, 200); // letter at top N/P/G/I drawLetter(mdIni[md]-'A'+10, sx, sy, sz, 0, 150, 150, 240); } else if ( i < QUIT_STAGE_NUM ) { makeStageStr(i); // 2-char stage ID below (1a, 2a, etc) drawString(stageStr, sx-sz, sy, sz, 0, 210, 210, 240); drawString(stgChr, 330, 133, 12, 0, 210, 210, 240); drawString(stageStr, 445, 133, 12, 0, 210, 210, 240); drawNumCenter(hiScore.score[mode][i], 466, 168, 12, 210, 210, 240); } else { // "q" for quit drawLetter('Q'-'A'+10, sx, sy, sz, 0, 210, 210, 240); drawString(quitChr, 410, 133, 12, 0, 210, 210, 240); } } else { #ifdef FIXEDMATH drawBox(INT2FNUM(sx), INT2FNUM(sy), INT2FNUM(STG_BOX_SIZE)/2, INT2FNUM(STG_BOX_SIZE)/2, r*2/3, g*2/3, b*2/3); #else drawBox(sx, sy, STG_BOX_SIZE/2, STG_BOX_SIZE/2, r*2/3, g*2/3, b*2/3); #endif //FIXEDMATH } } drawString(mdChr[mode], mdChrX[mode], 455, 12, 0, 150, 150, 200); // senquack - visual indicator for added cheats (they disable saving of high-scores however) if (settings.extra_lives > 0 || settings.extra_bombs > 0) { char *cheat_str = "CHEAT"; drawString(cheat_str, 285, 230, 12, 0, 255, 100, 100); cheat_str = "MODE"; drawString(cheat_str, 295, 270, 12, 0, 255, 100, 100); } }
/** draws the field */ void drawField(MotionDetect* md, const Field* field, const Transform* t) { if (!md->fi.pFormat == PF_YUV) return; drawBox(md->currorig, md->fi.width, md->fi.height, 1, field->x, field->y, field->size, field->size, t->extra == -1 ? 100 : 40); }
void draw_car(CarDrawer* carDrawer) { //draw_axis(500.0); // Car glPushMatrix(); glTranslatef(carDrawer->car_pose.position.x,carDrawer->car_pose.position.y,carDrawer->car_pose.position.z+carDrawer->car_wheel_diameter/2); glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(0.0, 0.0, 1.0, 0.0); glColor3f(0.3,0.3,0.3); //glmDraw(carDrawer->carModel, GLM_SMOOTH | GLM_COLOR); glmDraw(carDrawer->carModel, GLM_SMOOTH | GLM_COLOR | GLM_TEXTURE); glPopMatrix(); // Sensor Board glPushMatrix(); glTranslatef(carDrawer->sensor_board_1_pose.position.x,carDrawer->sensor_board_1_pose.position.y,carDrawer->sensor_board_1_pose.position.z); glRotatef(carmen_radians_to_degrees(carDrawer->sensor_board_1_pose.orientation.yaw), 0.0f, 0.0f, 1.0f); glRotatef(carmen_radians_to_degrees(carDrawer->sensor_board_1_pose.orientation.pitch), 0.0f, 1.0f, 0.0f); glRotatef(carmen_radians_to_degrees(carDrawer->sensor_board_1_pose.orientation.roll), 1.0f, 0.0f, 0.0f); // Xsens glPushMatrix(); glTranslatef(carDrawer->xsens_pose.position.x,carDrawer->xsens_pose.position.y,carDrawer->xsens_pose.position.z); glRotatef(carmen_radians_to_degrees(carDrawer->xsens_pose.orientation.yaw), 0.0f, 0.0f, 1.0f); glRotatef(carmen_radians_to_degrees(carDrawer->xsens_pose.orientation.pitch), 0.0f, 1.0f, 0.0f); glRotatef(carmen_radians_to_degrees(carDrawer->xsens_pose.orientation.roll), 1.0f, 0.0f, 0.0f); glColor3f(1.0,0.6,0.0); drawBox(carDrawer->xsens_size.x, carDrawer->xsens_size.y, carDrawer->xsens_size.z); glPopMatrix(); // Laser glPushMatrix(); glTranslatef(carDrawer->laser_pose.position.x, carDrawer->laser_pose.position.y, carDrawer->laser_pose.position.z); glRotatef(carmen_radians_to_degrees(carDrawer->laser_pose.orientation.yaw), 0.0f, 0.0f, 1.0f); glRotatef(carmen_radians_to_degrees(carDrawer->laser_pose.orientation.pitch), 0.0f, 1.0f, 0.0f); glRotatef(carmen_radians_to_degrees(carDrawer->laser_pose.orientation.roll), 1.0f, 0.0f, 0.0f); glColor3f(0.0,0.0,1.0); drawBox(carDrawer->laser_size.x, carDrawer->laser_size.y, carDrawer->laser_size.z); glPopMatrix(); glPopMatrix(); /* glPushMatrix(); glPushMatrix(); glColor3f(0.3,0.3,0.3); draw_wheel_axis(carDrawer->car_wheel_diameter,carDrawer->car_size.y); glPushMatrix(); glTranslatef(carDrawer->car_axis_distance, 0.0, 0.0); draw_wheel_axis(carDrawer->car_wheel_diameter,carDrawer->car_size.y); glPopMatrix(); glColor3f(1.0,0.0,0.0); glPushMatrix(); glTranslatef(carDrawer->car_pose.position.x,carDrawer->car_pose.position.y,carDrawer->car_pose.position.z+carDrawer->car_wheel_diameter/2); glRotatef(carDrawer->car_pose.orientation.roll, 1.0f, 0.0f, 0.0f); glRotatef(carDrawer->car_pose.orientation.pitch, 0.0f, 1.0f, 0.0f); glRotatef(carDrawer->car_pose.orientation.yaw, 0.0f, 0.0f, 1.0f); drawBox(carDrawer->car_size.x, carDrawer->car_size.y, carDrawer->car_size.z-carDrawer->car_wheel_diameter); glPopMatrix(); glPopMatrix(); glPopMatrix(); */ }
void drawRPanel_rotated() { int y; int ml; // Show FPS if (settings.show_fps) { drawString(fpsStr, 167, 68, 6, 0, 200, 200, 200); drawNumHoriz(fps(), 200, 68, 6, 200, 200, 200); } if ( left >= 0 ) { //orig; had to be adjusted below to support screen-rotation: // drawString(lStr, 40+480, 280, 18, 1, 200, 200, 222); // drawLetter(left, 40+480, 420, 18, 1, 230, 180, 150); drawString(lStr, 168, 33, 6, 0, 200, 200, 222); drawLetter(left, 213, 33, 6, 0, 230, 180, 150); switch ( mode ) { case NORMAL_MODE: //orig; had to be adjusted below to support screen-rotation: // drawString(bStr, 90+480, 280, 18, 1, 200, 200, 222); // drawLetter(bomb, 90+480, 420, 18, 1, 230, 180, 150); drawString(bStr, 228, 33, 6, 0, 200, 200, 222); drawLetter(bomb, 273, 33, 6, 0, 230, 180, 150); break; case PSY_MODE: ml = ship.grzCnt/40; //orig; had to be adjusted below to support screen-rotation: // drawBox(550, 460, 50, 8, 120, 120, 120); // drawBox(500+ml, 460, ml, 8, 210, 210, 240); #ifdef FIXEDMATH drawBox(INT2FNUM(425), INT2FNUM(20), INT2FNUM(50), INT2FNUM(8), 120, 120, 120); drawBox(INT2FNUM(375+ml), INT2FNUM(20), INT2FNUM(ml), INT2FNUM(8), 210, 210, 240); #else drawBox(425, 20, 50, 8, 120, 120, 120); drawBox(375+ml, 20, ml, 8, 210, 210, 240); #endif //FIXEDMATH break; case GW_MODE: ml = (ship.rfMtr-ship.rfMtrDec)/40; //orig; had to be adjusted below to support screen-rotation: // drawBox(550, 460, 50, 8, 120, 120, 120); // drawBox(500+ml, 460, ml, 8, 210, 240, 210); #ifdef FIXEDMATH drawBox(INT2FNUM(425), INT2FNUM(20), INT2FNUM(50), INT2FNUM(8), 120, 120, 120); drawBox(INT2FNUM(375+ml), INT2FNUM(20), INT2FNUM(ml), INT2FNUM(8), 210, 240, 210); #else drawBox(425, 20, 50, 8, 120, 120, 120); drawBox(375+ml, 20, ml, 8, 210, 240, 210); #endif //FIXEDMATH if ( ml >= 50 ) { // drawString(okStr, 540, 460, 10, 0, 230, 240, 230); //orig; had to be adjusted below to support screen-rotation: drawString(okStr, 415, 20, 10, 0, 230, 240, 230); } break; } } //these are disabled under rotated mode: // y = 24; // drawString(stageStr, 124+480, y, 24, 1, 200, 200, 222); // y += 24*1.7f*2; // drawLetter(38, 124+480, y, 24, 1, 200, 200, 222); // y += 24*1.7f; // drawNumRight(scene+1, 124+480, y, 24, 200, 200, 222); if (status != TITLE) { if (mode == NORMAL_MODE) { drawString(stageStr, 288, 33, 6, 0, 200, 200, 222); drawLetter(38, 305, 33, 6, 0, 200, 200, 222); drawNumCenter(scene+1, 312, 33, 6, 200, 200, 222); } else { // Draw this farther to left since we're not displaying bomb amount in these modes drawString(stageStr, 228, 33, 6, 0, 200, 200, 222); drawLetter(38, 245, 33, 6, 0, 200, 200, 222); drawNumCenter(scene+1, 252, 33, 6, 200, 200, 222); } } }
void drawTitleMenu() { int i; char *stgChr = "STAGE"; char *endlessChr = "ENDLESS"; char *hardChr = "HARD"; char *extChr = "EXTREME"; char *insChr = "INSANE"; char *quitChr = "QUIT"; for ( i=0 ; i<STG_BOX_NUM ; i++ ) { if ( i == slcStg ) { int sz = STG_BOX_SIZE+6+sctbl[(titleCnt*16)&(DIV-1)]/24; drawBox(stageX[i], stageY[i], sz, sz, 16*2-14, 16*2-3, buf); if ( i < STAGE_NUM ) { drawStringBuf(stgChr, 180, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); drawNumCenter(i+1, 308, 80, 12, 16*1-14, 16*1-2); } else { switch ( i ) { case 10: drawStringBuf(endlessChr, 188, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); break; case 11: drawStringBuf(endlessChr, 93, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); drawStringBuf(hardChr, 248, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); break; case 12: drawStringBuf(endlessChr, 36, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); drawStringBuf(extChr, 190, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); break; case 13: drawStringBuf(endlessChr, 56, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); drawStringBuf(insChr, 210, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); break; case 14: drawStringBuf(quitChr, 230, 80, 12, 2, 16*1-14, 16*1-2, buf, 0); break; } } if ( i < STAGE_NUM+ENDLESS_STAGE_NUM ) { drawNumCenter(hiScore.stageScore[i], 308, 112, 12, 16*1-14, 16*1-2); } } drawBox(stageX[i], stageY[i], STG_BOX_SIZE, STG_BOX_SIZE, 16*1-14, 16*1-3, buf); if ( i < 9 ) { drawNumCenter(i+1, stageX[i], stageY[i], 12, 16*1-16, 16*1-1); } else { switch ( i ) { case 9: drawNumCenter(10, stageX[i]+8, stageY[i], 12, 16*1-16, 16*1-1); break; case 10: drawLetterBuf('E'-'A'+10, stageX[i], stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); break; case 11: drawLetterBuf('E'-'A'+10, stageX[i]-8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); drawLetterBuf('H'-'A'+10, stageX[i]+8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); break; case 12: drawLetterBuf('E'-'A'+10, stageX[i]-8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); drawLetterBuf('E'-'A'+10, stageX[i]+8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); break; case 13: drawLetterBuf('E'-'A'+10, stageX[i]-8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); drawLetterBuf('I'-'A'+10, stageX[i]+8, stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); break; case 14: drawLetterBuf('Q'-'A'+10, stageX[i], stageY[i], 12, 2, 16*1-16, 16*1-1, buf, 0); break; } } } }
// simulation loop static void simLoop (int pause) { const dReal *rot; dVector3 ax; dReal l=0; switch (joint->getType() ) { case dJointTypeSlider : ( (dSliderJoint *) joint)->getAxis (ax); l = ( (dSliderJoint *) joint)->getPosition(); break; case dJointTypePiston : ( (dPistonJoint *) joint)->getAxis (ax); l = ( (dPistonJoint *) joint)->getPosition(); break; default: {} // keep the compiler happy } if (!pause) { double simstep = 0.01; // 1ms simulation steps double dt = dsElapsedTime(); int nrofsteps = (int) ceilf (dt/simstep); if (!nrofsteps) nrofsteps = 1; for (int i=0; i<nrofsteps && !pause; i++) { dSpaceCollide (space,0,&nearCallback); dWorldStep (world, simstep); dJointGroupEmpty (contactgroup); } update(); dReal radius, length; dsSetTexture (DS_WOOD); drawBox (geom[BODY2], 1,1,0); drawBox (geom[RECT], 0,0,1); if ( geom[BODY1] ) { const dReal *pos = dGeomGetPosition (geom[BODY1]); rot = dGeomGetRotation (geom[BODY1]); dsSetColor (0,0,1); dGeomCapsuleGetParams (geom[BODY1], &radius, &length); dsDrawCapsule (pos, rot, length, radius); } drawBox (geom[OBS], 1,0,1); // Draw the prismatic axis if ( geom[BODY1] ) { const dReal *pos = dGeomGetPosition (geom[BODY1]); rot = dGeomGetRotation (geom[BODY2]); dVector3 p; p[X] = pos[X] - l*ax[X]; p[Y] = pos[Y] - l*ax[Y]; p[Z] = pos[Z] - l*ax[Z]; dsSetColor (1,0,0); dsDrawCylinder (p, rot, 3.75, 1.05*AXIS_RADIUS); } if (joint->getType() == dJointTypePiston ) { dVector3 anchor; dJointGetPistonAnchor(joint->id(), anchor); // Draw the rotoide axis rot = dGeomGetRotation (geom[BODY2]); dsSetColor (1,0.5,0); dsDrawCylinder (anchor, rot, 4, AXIS_RADIUS); dsSetColor (0,1,1); rot = dGeomGetRotation (geom[BODY1]); dsDrawSphere (anchor, rot, 1.5*RADIUS); } } }
/* CENTRY */ void APIENTRY glutWireCube(GLdouble size) { drawBox(size, GL_LINE_LOOP); }
// simulation loop static void simLoop (int pause) { static bool todo = false; if ( todo ) { // DEBUG static int cnt = 0; ++cnt; if (cnt == 5) command ( 'q' ); if (cnt == 10) dsStop(); } if (!pause) { double simstep = 0.01; // 10ms simulation steps double dt = dsElapsedTime(); int nrofsteps = (int) ceilf (dt/simstep); if (!nrofsteps) nrofsteps = 1; for (int i=0; i<nrofsteps && !pause; i++) { dSpaceCollide (space,0,&nearCallback); dWorldStep (world, simstep); dJointGroupEmpty (contactgroup); } update(); dReal radius, length; dsSetTexture (DS_WOOD); drawBox (geom[W], 1,1,0); drawBox (geom[EXT], 0,1,0); dVector3 anchorPos; dReal ang1 = 0; dReal ang2 = 0; dVector3 axisP, axisR1, axisR2; if ( dJointTypePU == type ) { dPUJoint *pu = dynamic_cast<dPUJoint *> (joint); ang1 = pu->getAngle1(); ang2 = pu->getAngle2(); pu->getAxis1 (axisR1); pu->getAxis2 (axisR2); pu->getAxisP (axisP); dJointGetPUAnchor (pu->id(), anchorPos); } else if ( dJointTypePR == type ) { dPRJoint *pr = dynamic_cast<dPRJoint *> (joint); pr->getAxis1 (axisP); pr->getAxis2 (axisR1); dJointGetPRAnchor (pr->id(), anchorPos); } // Draw the axisR if ( geom[INT] ) { dsSetColor (1,0,1); dVector3 l; dGeomBoxGetLengths (geom[INT], l); const dReal *rotBox = dGeomGetRotation (geom[W]); dVector3 pos; for (int i=0; i<3; ++i) pos[i] = anchorPos[i] - 0.5*extDim[Z]*axisP[i]; dsDrawBox (pos, rotBox, l); } dsSetTexture (DS_CHECKERED); if ( geom[AXIS1] ) { dQuaternion q, qAng; dQFromAxisAndAngle (qAng,axisR1[X], axisR1[Y], axisR1[Z], ang1); dGeomGetQuaternion (geom[AXIS1], q); dQuaternion qq; dQMultiply1 (qq, qAng, q); dMatrix3 R; dQtoR (qq,R); dGeomCylinderGetParams (dGeomTransformGetGeom (geom[AXIS1]), &radius, &length); dsSetColor (1,0,0); dsDrawCylinder (anchorPos, R, length, radius); } if ( dJointTypePU == type && geom[AXIS2] ) { //dPUJoint *pu = dynamic_cast<dPUJoint *> (joint); dQuaternion q, qAng, qq, qq1; dGeomGetQuaternion (geom[AXIS2], q); dQFromAxisAndAngle (qAng, 0, 1, 0, ang2); dQMultiply1 (qq, qAng, q); dQFromAxisAndAngle (qAng,axisR1[X], axisR1[Y], axisR1[Z], ang1); dQMultiply1 (qq1, qAng, qq); dMatrix3 R; dQtoR (qq1,R); dGeomCylinderGetParams (dGeomTransformGetGeom (geom[AXIS2]), &radius, &length); dsSetColor (0,0,1); dsDrawCylinder (anchorPos, R, length, radius); } dsSetTexture (DS_WOOD); // Draw the anchor if ( geom[ANCHOR] ) { dsSetColor (1,1,1); dVector3 l; dGeomBoxGetLengths (geom[ANCHOR], l); const dReal *rotBox = dGeomGetRotation (geom[D]); const dReal *posBox = dGeomGetPosition (geom[D]); dVector3 e; for (int i=0; i<3; ++i) e[i] = posBox[i] - anchorPos[i]; dNormalize3 (e); dVector3 pos; for (int i=0; i<3; ++i) pos[i] = anchorPos[i] + 0.5 * l[Z]*e[i]; dsDrawBox (pos, rotBox, l); } drawBox (geom[D], 1,1,0); } }
void BatchNavViewRender::result( const valc::TestResult* r, const paulst::Nullable<valc::RuleResults>& rr, const valc::WorklistEntry* associatedWorklistEntry ) { drawBox( associatedWorklistEntry->getID() ); }
void APIENTRY glutSolidCube(GLdouble size) { drawBox(size, GL_QUADS); }
void Ariou() { Mat4f temp = getModelViewMatrix(); ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_X, 3.1); //ModelerApplication::Instance()->Swing(LEFT_UPPER_ARM_ROTATE_Y, 2.5); ModelerApplication::Instance()->Swing(HEAD_ROTATE, 1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_X, 1.1); ModelerApplication::Instance()->Swing(RIGHT_UPPER_ARM_ROTATE_Y, 4.5); ModelerApplication::Instance()->Swing(LEFT_LEG_ROTATE_X, 6.1); ModelerApplication::Instance()->Swing(RIGHT_LEG_ROTATE_X, 6.1); glPushMatrix(); glTranslated(VAL(XPOS), VAL(YPOS), VAL(ZPOS)); glScaled(VAL(XSCALE), VAL(YSCALE), VAL(ZSCALE)); glRotated(VAL(ROTATE), 0, 1, 0); setDiffuseColor(COLOR_YELLOW); // Torus if (VAL(DETAIL_LEVEL) > 1) { glPushMatrix(); glTranslated(.0f, 6, .0f); drawTorus(VAL(TORUS_R), VAL(TORUS_r)); glPopMatrix(); } //head glPushMatrix(); glTranslated(0, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) + 0.05 + VAL(HEAD_SIZE), 0); glRotated(VAL(HEAD_ROTATE), 0.0, 1.0, 0.0); drawSphere(VAL(HEAD_SIZE)); if (VAL(DETAIL_LEVEL) > 2) { // Nose drawRoundCylinder(VAL(HEAD_SIZE) * 1.1, 0.2, 0.2); // Ear glPushMatrix(); glTranslated(0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(-20, 0, 0, 1); SpawnParticles(temp); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); glPushMatrix(); glTranslated(-0.9 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 1.1 / sqrt(0.9*0.9 + 1.1*1.1) * VAL(HEAD_SIZE), 0); glRotated(20, 0, 0, 1); SpawnParticles(temp); drawPyramid(VAL(EAR_SIZE)); glPopMatrix(); // Eyes glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated(-0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); glPushMatrix(); setDiffuseColor(COLOR_RED); glTranslated( 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, 0.5 / sqrt(0.5*0.5 * 2) * VAL(HEAD_SIZE) * 0.5, VAL(HEAD_SIZE) - 0.9); drawRoundCylinder( 0.9, 0.2, 0.2); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 1) { //body // a.k.a. torso/trunk glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(0, 0.05 + VAL(LEG_LENGTH), 0); glRotated(-90, 1.0, 0.0, 0.0); drawRoundCylinder(VAL(HEIGHT), 0.7, 0.6); glPushMatrix(); glTranslated(-0.8, 0, VAL(HEIGHT) - 0.4); glRotated(90, 0, 1, 0); // the shoulder if (VAL(DETAIL_LEVEL) > 2) { drawRoundCylinder(1.6, 0.2, 0.2); } glPopMatrix(); // the waist if (VAL(DETAIL_LEVEL) > 3) { glPushMatrix(); glTranslated(0, 0, 0.5); glRotated(90, 1, 0, 0); drawTorus(0.7, 0.08); glPopMatrix(); } glPopMatrix(); if (VAL(DETAIL_LEVEL) > 2) { //right arm glPushMatrix(); glTranslated(-0.7 - 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(0.15, 0, 0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(-0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); // lower arm glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPushMatrix(); glTranslated(0.03, -0.15, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(RIGHT_HAND_ANGLE), 0, 1, 0); drawCylinder(0.8, 0.15, 0.0001); glPopMatrix(); glPopMatrix(); //left arm glPushMatrix(); glTranslated(0.7 + 0.20, VAL(LEG_LENGTH) + 0.05 + VAL(HEIGHT) * 0.9f, 0); glTranslated(-0.15, 0, 0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_UPPER_ARM_ROTATE_Y), 0.0, 1.0, 0.0); glTranslated(0.15, 0, 0); drawRoundCylinder(VAL(UPPER_ARM_LENGTH), 0.22, 0.15); glTranslated(0, 0, VAL(UPPER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_LOWER_ARM_ROTATE) - 180, 1, 0, 0); drawRoundCylinder(VAL(LOWER_ARM_LENGTH), 0.15, 0.20); // hand glPushMatrix(); glTranslated(-0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); glPopMatrix(); glPushMatrix(); glTranslated(0.03, 0, VAL(LOWER_ARM_LENGTH) - 0.1); glRotated(-VAL(LEFT_HAND_ANGLE), 0, 1, 0); drawBox(0.03, 0.25, 0.5); if (VAL(DETAIL_LEVEL) > 3) { glRotated(90, 0, 0, 1); drawCylinder(5, 0.02, 0.02); if (VAL(DETAIL_LEVEL) > 4) { glTranslated(0, 0, 4); glPushMatrix(); setDiffuseColor(COLOR_GREEN); glTranslated(0, -0.5, 1); //SpawnParticles(temp); glPushMatrix(); glRotated(90, 1.0, 0.0, 0.0); glPopMatrix(); glPopMatrix(); } } glPopMatrix(); glPopMatrix(); } //right leg glPushMatrix(); setDiffuseColor(COLOR_YELLOW); glTranslated(-0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(RIGHT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(RIGHT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); //left leg glPushMatrix(); glTranslated(0.5, VAL(LEG_LENGTH), 0); glRotated(VAL(LEFT_LEG_ROTATE_X), 1.0, 0.0, 0.0); glRotated(VAL(LEFT_LEG_ROTATE_Y), 0.0, 1.0, 0.0); drawRoundCylinder(VAL(LEG_LENGTH) - 0.15, 0.3, 0.4); glTranslated(0, 0, VAL(LEG_LENGTH) * 0.85f); glRotated(70, 1, 0, 0); drawTorus(VAL(FEET_SIZE), VAL(FEET_SIZE) / 4); glPopMatrix(); } glPopMatrix(); }
void BatchNavViewRender::pending( const valc::WorklistEntry* w ) { drawBox( w->getID() ); }
void PhysicsDemo::display() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); float transform[16]; glTranslatef(0.0f, 0.0f, m_camZoom); glRotatef(m_camAng.x, 1.0f, 0.0f, 0.0f); glRotatef(m_camAng.y, 0.0f, 1.0f, 0.0f); glRotatef(m_camAng.z, 0.0f, 0.0f, 1.0f); //lt::Vec3 camPos = -m_box.getTransform().getPosition(); //glTranslatef(camPos.x, camPos.y, camPos.z); // Reference Axes glDisable(GL_LIGHTING); glBegin(GL_LINES); glColor3f(1.0f, 0.0f, 0.0f); glVertex3f( 1.0f, 0.0f, 0.0f); glVertex3f( 0.0f, 0.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glVertex3f( 0.0f, 0.0f, 0.0f); glColor3f(0.0f, 0.0f, 1.0f); glVertex3f( 0.0f, 0.0f, 1.0f); glVertex3f( 0.0f, 0.0f, 0.0f); glEnd(); // Draw Collision information. const std::vector<lt::ContactManifold> &contactManifolds = world.getContactManifolds(); for(unsigned int i = 0; i < contactManifolds.size(); i++) { int numContacts = contactManifolds[i].getNumContacts(); for(int j = 0; j < numContacts; j++) { glPointSize(8); glLineWidth(4); lt::ContactPoint curContact = contactManifolds[i].getContactPoint(j); lt::Vec3& pos = curContact.position; lt::Vec3& norm = curContact.normal; lt::Scalar& pen = curContact.penetration; lt::Vec3 start = pos + (norm * (pen*0.5f)); lt::Vec3 end = pos + (norm * (pen*-0.5f)); glBegin(GL_POINTS); glColor3f(1.f, 0.5f, 0.f); glVertex3f(pos.x, pos.y, pos.z); glEnd(); glBegin(GL_LINES); glColor3f(1.f, 1.f, 1.f); glVertex3f(start.x, start.y, start.z); glVertex3f(end.x, end.y, end.z); glEnd(); glPointSize(1); glLineWidth(1); glPushMatrix(); glTranslatef(pos.x, pos.y, pos.z); // Draw axes that are oriented by the collision normal lt::Mat3 basis = lt::constructOrthonormalBasis(norm); lt::Vec3 x = basis * lt::Vec3(1.f, 0.f, 0.f); lt::Vec3 y = basis * lt::Vec3(0.f, 1.f, 0.f); lt::Vec3 z = basis * lt::Vec3(0.f, 0.f, 1.f); lt::Scalar scale = 0.1f; glBegin(GL_LINES); glColor3f(1.0f, 0.0f, 0.0f); glVertex3f( norm.x * scale, norm.y * scale, norm.z * scale); glVertex3f( 0.0f, 0.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex3f( y.x * scale, y.y * scale, y.z * scale); glVertex3f( 0.0f, 0.0f, 0.0f); glColor3f(0.0f, 0.0f, 1.0f); glVertex3f( z.x * scale, z.y * scale, z.z * scale); glVertex3f( 0.0f, 0.0f, 0.0f); glEnd(); glPopMatrix(); } } glEnable(GL_LIGHTING); //glPolygonMode(GL_FRONT, GL_LINE); const std::vector<lt::RigidBody*> &rigidBodies = world.getRigidBodyList(); for (unsigned int i = 0; i < rigidBodies.size(); i++) { const lt::RigidBody &curBody = *rigidBodies[i]; const std::set<const lt::CollisionShape*>& colShapesA = curBody.getCollisionShapes(); std::set<const lt::CollisionShape*>::iterator shapeIter; for (shapeIter = colShapesA.begin(); shapeIter != colShapesA.end(); ++shapeIter) { const lt::CollisionShape &curShape = **shapeIter; glPushMatrix(); curBody.getTransform().getOpenGLMatrix(transform); glMultMatrixf(transform); curShape.getOffset().getOpenGLMatrix(transform); glMultMatrixf(transform); glColor3f( ((i+1)*1234567)%32 / 32.0f, ((i+2)*1234567)%32 / 32.0f, ((i+3)*1234567)%32 / 32.0f); switch (curShape.getShapeType()) { case lt::SHAPE_BOX: drawBox( ((lt::ShapeBox&)curShape).getHalfExtents() ); break; case lt::SHAPE_SPHERE: drawSphere( ((lt::ShapeSphere&)curShape).getRadius(), 10 ); break; case lt::SHAPE_HALFSPACE: glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.f, 1.f, 0.f); glVertex3f(-10000.f, 0, 10000.f); glVertex3f(-10000.f, 0, -10000.f); glVertex3f( 10000.f, 0, 10000.f); glVertex3f( 10000.f, 0, -10000.f); glEnd(); break; } glPopMatrix(); } } // Test Spring glDisable(GL_LIGHTING); glPushMatrix(); lt::Vec3 p1; lt::Vec3 p2 = m_controlledBody.getPosition(); glColor3f(1.0f, 0.5f, 0.0f); glBegin(GL_LINES); p1 = m_bodySmall.getPosition() + m_bodySmall.getPointInWorldSpace(m_boxSpringOffset); glVertex3f(p1.x, p1.y, p1.z); glVertex3f(p2.x, p2.y, p2.z); glEnd(); glPopMatrix(); glEnable(GL_LIGHTING); glFlush(); SDL_GL_SwapBuffers(); }
void ShapeEllipse::draw() { if (this->isSolid) { int x = 0, y = this->yrad; unsigned int width = 1; long a2 = (long)this->xrad * this->xrad, b2 = (long)this->yrad * this->yrad; long crit1 = -(a2 / 4 + this->xrad % 2 + b2); long crit2 = -(b2 / 4 + this->yrad % 2 + a2); long crit3 = -(b2 / 4 + this->yrad % 2); long t = -a2 * y; long dxt = 2 * b2 * x, dyt = -2 * a2 * y; long d2xt = 2 * b2, d2yt = 2 * a2; while (y >= 0 && x <= this->xrad) { if (t + b2*x <= crit1 || t + a2*y <= crit3) { incx(); width += 2; } else if (t - a2*y > crit2) { drawBox(this->x - x, this->y - y, width, 1, color, ctype); if (y != 0) drawBox(this->x - x, this->y + y, width, 1, color, ctype); incy(); } else { drawBox(this->x - x, this->y - y, width, 1, color, ctype); if (y != 0) drawBox(this->x - x, this->y + y, width, 1, color, ctype); incx(); incy(); width += 2; } } if (this->yrad == 0) drawBox(this->x - this->xrad, this->y, 2*this->xrad + 1, 1, color, ctype); } else { int x = this->xrad; int y = 0; int twoAsquare = 2 * this->xrad * this->xrad; int twoBsquare = 2 * this->yrad * this->yrad; int xchange = this->yrad * this->yrad * (1 - 2 * this->xrad); int ychange = this->xrad * this->xrad; int ellipseerror = 0; int stoppingX = twoBsquare * this->xrad; int stoppingY = 0; while (stoppingX >= stoppingY) { drawDot(this->x + x, this->y + y, color, ctype); drawDot(this->x - x, this->y + y, color, ctype); drawDot(this->x - x, this->y - y, color, ctype); drawDot(this->x + x, this->y - y, color, ctype); y++; stoppingY += twoAsquare; ellipseerror += ychange; ychange += twoAsquare; if ((2* ellipseerror + xchange) > 0) { x--; stoppingX -= twoBsquare; ellipseerror += xchange; xchange += twoBsquare; } } x = 0; y = this->yrad; xchange = this->yrad * this->yrad; ychange = this->xrad * this->xrad * (1 - 2 * this->yrad); ellipseerror = 0; stoppingX = 0; stoppingY = twoAsquare * this->yrad; while (stoppingX <= stoppingY) { drawDot(this->x + x, this->y + y, color, ctype); drawDot(this->x - x, this->y + y, color, ctype); drawDot(this->x - x, this->y - y, color, ctype); drawDot(this->x + x, this->y - y, color, ctype); x++; stoppingX += twoBsquare; ellipseerror += xchange; xchange += twoBsquare; if ((2* ellipseerror + ychange) > 0) { y--; stoppingY -= twoAsquare; ellipseerror += ychange; ychange += twoAsquare; } } } }
void Health::draw() const { drawBox(); Draw_AALine(screen, start[0], start[1], start[0] + currentLength, start[1], thick, color); }