void VectorDebugComponent::Update(double) { float x = (float)this->composition->getX(); float y = (float)this->composition->getY(); float height = (float)this->composition->getHeight(); float width = (float)this->composition->getWidth(); float centerX = x + width / 2; float centerY = y + height / 2; if (!GameTools::debugManager::getInstance().isActivateGraphic()) return; // top glColor3f(1.0, 0.0, 0.0); glLineWidth(1); if (typeDraw == "circle") { drawHollowCircle(centerX, centerY, height / 2); } else if (typeDraw == "square") { drawSquare(x, y, width, height); } //velocity glLineWidth(3); glBegin(GL_LINES); glVertex2f(centerX, centerY); glVertex2f(centerX + velocity.x, centerY + velocity.y); glEnd(); glColor3f(1.0, 1.0, 1.0); }
void drawAnglePresets(GLshort percUnitW, GLshort percUnitH) { int i,j; GLshort gapW = ((percUnitW*20)-30)/4; GLshort gapH = ((percUnitH*20)-30)/4; //set angle area box uiS.anglesBL[0] = percUnitW*55; uiS.anglesBL[1] = percUnitH*60; uiS.anglesTR[0] = percUnitW*75; uiS.anglesTR[1] = percUnitH*75; //draw angle area box glBegin(GL_LINE_LOOP); glVertex2sv(uiS.anglesBL); glVertex2s(uiS.anglesTR[0], uiS.anglesBL[1]); glVertex2sv(uiS.anglesTR); glVertex2s(uiS.anglesBL[0], uiS.anglesTR[1]); glEnd(); for (i=0; i<3;i++){ for (j=0;j<3;j++){ //set angle preset location uiS.anglesPS[0][i*3+j] = percUnitW*60+i*gapW; // x uiS.anglesPS[1][i*3+j] = percUnitH*63+j*gapH; // y // draw radio button for angle preset drawHollowCircle(uiS.anglesPS[0][i*3+j], uiS.anglesPS[1][i*3+j], 10); if(!tmpState.angleRand){ if(tmpState.angle == (i*3)+j+1){ drawFilledCircle(uiS.anglesPS[0][i*3+j], uiS.anglesPS[1][i*3+j], 8); } } else{ //if random angle selected draw cross drawCheck(uiS.randAng[0], uiS.randAng[1]); //also need to draw a cross through the circles box to indicate out of use glBegin(GL_LINES); glVertex2sv(uiS.anglesBL); glVertex2sv(uiS.anglesTR); glEnd(); glBegin(GL_LINES); glVertex2s(uiS.anglesTR[0], uiS.anglesBL[1]); glVertex2s(uiS.anglesBL[0], uiS.anglesTR[1]); glEnd(); } // end if }// end for }// end for }// end drawPresetAngles
void OpenglManager::writeWMBallToDisplay(float x, float y, float radius, GLDisplay::display displayId) { // If there is an old list stored, delete it first. if(displayStored[displayId]) { glDeleteLists(displays[displayId],1); } displays[displayId] = glGenLists(1); glNewList(displays[displayId],GL_COMPILE); // START OF LIST glDisable(GL_TEXTURE_2D); drawHollowCircle(x, y, radius, 50); glEnable(GL_TEXTURE_2D); glEndList(); // END OF LIST displayStored[displayId] = true; emit updatedDisplay(displayId, displays[displayId], width, height); return; }
void OpenglManager::writePointsToDisplay(std::vector< Vector2<int> > newpoints, GLDisplay::display displayId) { // If there is an old list stored, delete it first. if(displayStored[displayId]) { glDeleteLists(displays[displayId],1); } displays[displayId] = glGenLists(1); glNewList(displays[displayId],GL_COMPILE); // START OF LIST glDisable(GL_TEXTURE_2D); for (int pointNum = 0; pointNum < (int)newpoints.size(); pointNum++) { drawHollowCircle(newpoints[pointNum].x+0.5, newpoints[pointNum].y+0.5, 0.5, 50); } glEnable(GL_TEXTURE_2D); glEndList(); // END OF LIST displayStored[displayId] = true; emit updatedDisplay(displayId, displays[displayId], width, height); return; }
// -------------------------------------------------------- void TouchDisplayWidgetRenderer::paint( GLResourceContainer * container, int pass, TouchWidgetRenderer * to_texture_renderer ) const { Q_UNUSED(to_texture_renderer); if(pass==0) { // draw line if(_twm->currentBallTarget() != NULL) { const RigidWidgetController * ball = _twm->currentBallTarget()->first; const RigidWidgetController * target = _twm->currentBallTarget()->second; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glLineWidth(2); //glColor4f(240.0/255,198.0/255,0,1); glColor4f(1,1,1,1); glBegin(GL_LINE_STRIP); glVertex2f(ball->pos().x(), ball->pos().y()); glVertex2f(target->pos().x(), target->pos().y()); glEnd(); } foreach(const SceneTouchPoint * stp, _tpm->touches()) { // draw bubble //const QList<RigidWidgetController *> & closest_widgets = stp->closestRigidWidgets(); //if(closest_widgets.size()>=2) //{ // // labeled as in the bubble cursor 2005 paper // //float con_d_i = QLineF(closest_widgets[0]->pos(), stp->transformedPoint()->pos()).length() + closest_widgets[0]->radius(); // //float int_d_j = QLineF(closest_widgets[1]->pos(), stp->transformedPoint()->pos()).length() - closest_widgets[1]->radius(); // float con_d_i = closest_widgets[0]->containmentDistance(stp->transformedPoint()->pos()); // float int_d_j = closest_widgets[1]->intersectingDistance(stp->transformedPoint()->pos()); // float radius = qMin(con_d_i, int_d_j); // drawTexturedQuad(container->texture("halo"), stp->transformedPoint()->pos(), QSizeF(radius, radius)*2, 0, 0.5f); //} QRectF bubble_rect = stp->bubbleRect(); if(!bubble_rect.isEmpty()) { Q_ASSERT(QLineF(stp->pos(), bubble_rect.center()).length() < 0.001f); drawTexturedQuad(container->texture("halo"), stp->pos(), bubble_rect.size(), 0, 0.3f); } // we don't want to show all the gory details in magnifying glasses if(to_texture_renderer!=NULL) { //qDebug() << stp->visibilityInMagnification(); if(stp->visibilityInMagnification() == SceneTouchPoint::NeverVisible) continue; if(stp->visibilityInMagnification() == SceneTouchPoint::VisibleOnlyWithAreaCursor) { if(!stp->isFree() || _twm->selectionMode()!=DirectAreaSelection) //if(_twm->selectionMode()!=DirectAreaSelection) continue; } } else { if(!stp->visibleInScene()) continue; } if(_tool_setting_container.boolProperty("simplified_mg") && to_texture_renderer!=NULL) continue; // determine texture name QString texture_name("touch_bright/touch"); if(stp->state() == Qt::TouchPointPressed) { texture_name += "_new"; } else { texture_name += (stp->numPressedWidgets() == 0) ? "_free" : "_bound"; // TODO: SETTING "SHOW YOUNG CURSORS" //if(stp->isYoung()) //{ // texture_name += "_young"; //} } // geometry const QRectF & rect = stp->rect(); if(_tool_setting_container.boolProperty("pointy_cursor")) { drawTexturedQuad(container->texture(texture_name), rect.center(), rect.size(), 0, 0.25f); drawHollowCircle(container, rect.center(), rect.size().width()/2*1.2f, 0.5f, Qt::white, 0.0004f, 300); drawCross(container, rect.center(), rect.size()*1.2f); } else { drawTexturedQuad(container->texture(texture_name), rect.center(), rect.size(), 0, 0.25f); drawHollowCircle(container, rect.center(), rect.size().width()/2*1.2f, 1.0f, Qt::white, 0.0005f, 300); } } } }
void CGraphics::drawSSLGround(float SSL_FIELD_RAD,float SSL_FIELD_LENGTH,float SSL_FIELD_WIDTH,float SSL_FIELD_PENALTY,float SSL_FIELD_LINE_LENGTH,float SSL_FIELD_PENALTY_POINT,float epsilon) { if (graphicDisabled) return; float angle,x,y,z; float radx = (SSL_FIELD_PENALTY) / ( SSL_FIELD_LENGTH / 2.0); float radz = (SSL_FIELD_PENALTY) / ( SSL_FIELD_WIDTH / 2.0); float penaltyx = SSL_FIELD_PENALTY_POINT / (SSL_FIELD_LENGTH / 2.0); glPushMatrix(); glScaled(SSL_FIELD_LENGTH / 2.0 , SSL_FIELD_WIDTH / 2.0,1); GLfloat sizes[2]; // Store supported line width range GLfloat step; // Store supported line width increments // Get supported line width range and step size glGetFloatv(GL_LINE_WIDTH_RANGE,sizes); glGetFloatv(GL_LINE_WIDTH_GRANULARITY,&step); float fCurrSize = sizes[0]; glLineWidth(fCurrSize * 5); glBegin(GL_LINE_LOOP); glColor3f(1.0f, 1.0f, 1.0f); //glNormal3f(0, 1, 0); glVertex3f(1, 1, epsilon); glVertex3f(1, -1 , epsilon); glVertex3f(-1, -1 , epsilon); glVertex3f(-1, 1 , epsilon); glEnd(); glBegin(GL_LINES); glColor3f(1.0f, 1.0f, 1.0f); glVertex3f(0.0, 1.0 , epsilon); glVertex3f(0.0, -1.0, epsilon ); glEnd(); glDisable (GL_LIGHTING); for(int i = 0; i < debugger.NUM_FRAMES; i++) { for(int j = 0; j < debugger.lineList[i].size(); ++j) { glBegin(GL_LINES); unsigned int col = debugger.lineList[i][j].color; glColor3f(((col>>16)&0xFF)/255.0,((col>>8)&0xFF)/255.0,(col&0xFF)/255.0); glVertex3f(debugger.lineList[i][j].x1/3025.0, debugger.lineList[i][j].y1/2025.0, epsilon); glVertex3f(debugger.lineList[i][j].x2/3025.0, debugger.lineList[i][j].y2/2025.0, epsilon ); glEnd(); } for(int j = 0; j < debugger.circleList[i].size(); ++j) { unsigned int col = debugger.circleList[i][j].color; glColor3f(((col>>16)&0xFF)/255.0,((col>>8)&0xFF)/255.0,(col&0xFF)/255.0); drawHollowCircle(debugger.circleList[i][j].x/3025.0, debugger.circleList[i][j].y/2025.0, debugger.circleList[i][j].radius/3025.0, debugger.circleList[i][j].radius/2025.0, epsilon); } } glEnable(GL_LIGHTING); drawHollowCircle(x, y, radx, radz, epsilon); float h = SSL_FIELD_LINE_LENGTH / SSL_FIELD_WIDTH; glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINE_LOOP); z = epsilon; for(angle = 0.0f; angle <= M_PI*0.5; angle += (M_PI/20.0f)) { x = -1.0 + (radx * sin(angle)); y = radz * cos(angle) + h*0.5f; glVertex3f(x, y, z); } for(angle = M_PI*0.5; angle >= 0.0f; angle -= (M_PI/20.0f)) { x = -1.0 + (radx * sin(angle)); y = -radz * cos(angle) - h*0.5f; glVertex3f(x, y, z); } glVertex3f(-1.0f,-h-radz,z); glEnd(); glBegin(GL_LINE_LOOP); z = epsilon; for(angle = 0.0f; angle <= M_PI*0.5; angle += (M_PI/20.0f)) { x = 1.0 - (radx * sin(angle)); y = radz * cos(angle) + h*0.5f; glVertex3f(x, y, z); } for(angle = M_PI*0.5; angle >= 0.0 ; angle -= (M_PI/20.0f)) { x = 1.0 - (radx * sin(angle)); y = -radz * cos(angle) - h*0.5f; glVertex3f(x, y, z); } glVertex3f(1.0f,-h-radz,z); glEnd(); drawCircle(-1+penaltyx,0,epsilon,0.005); drawCircle(+1-penaltyx,0,epsilon,0.005); glLineWidth(fCurrSize); glPopMatrix(); }