xColor xColor::operator * (int x) { int r = min (red * x, xColorMax); int g = min (green * x, xColorMax); int b = min (blue * x, xColorMax); return xColor (r, g, b); }
void MannequinMoveManipulator::draw(M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) { static MGLFunctionTable *gGLFT = 0; if (0 == gGLFT) { gGLFT = MHardwareRenderer::theRenderer()->glFunctionTable(); } recalcMetrics(); float size = _manipScale * MFnManip3D::globalSize(); float handleSize = MFnManip3D::handleSize() / 100.0f; // Probably on [0, 100]. float handleHeight = size * handleSize * 0.5f; float handleOfs = size - handleHeight; float handleRadius = handleHeight * 0.25f; float origin[4]; _origin.get(origin); float x[4], y[4], z[4]; (_origin + (_x * size)).get(x); (_origin + (_y * size)).get(y); (_origin + (_z * size)).get(z); view.beginGL(); GLUquadricObj* quadric = gluNewQuadric(); gluQuadricNormals(quadric, GLU_SMOOTH); gluQuadricTexture(quadric, true); gluQuadricDrawStyle(quadric, GLU_FILL); colorAndName(view, _glPickableItem + 0, true, xColor()); gGLFT->glBegin(MGL_LINES); gGLFT->glVertex3fv(origin); gGLFT->glVertex3fv(x); gGLFT->glEnd(); glDrawCone(quadric, _origin + (_x * handleOfs), _x, handleHeight, handleRadius); colorAndName(view, _glPickableItem + 1, true, yColor()); gGLFT->glBegin(MGL_LINES); gGLFT->glVertex3fv(origin); gGLFT->glVertex3fv(y); gGLFT->glEnd(); glDrawCone(quadric, _origin + (_y * handleOfs), _y, handleHeight, handleRadius); colorAndName(view, _glPickableItem + 2, true, zColor()); gGLFT->glBegin(MGL_LINES); gGLFT->glVertex3fv(origin); gGLFT->glVertex3fv(z); gGLFT->glEnd(); glDrawCone(quadric, _origin + (_z * handleOfs), _z, handleHeight, handleRadius); gluDeleteQuadric(quadric); view.endGL(); }
xColor xColor::operator - (xColor c) { int r = max (red - c.red, 0); int g = max (green - c.green, 0); int b = max (blue - c.blue, 0); return xColor (r, g, b); }
xColor xColor::operator - (int x) { int r = max (red - x, 0); int g = max (green - x, 0); int b = max (blue - x, 0); return xColor (r, g, b); }
xColor xColor::operator + (xColor c) { int r = min (red + c.red, xColorMax); int g = min (green + c.green, xColorMax); int b = min (blue + c.blue, xColorMax); return xColor (r, g, b); }
xColor xColor::operator + (int x) { int r = min (red + x, xColorMax); int g = min (green + x, xColorMax); int b = min (blue + x, xColorMax); return xColor (r, g, b); }
xColor xColor::operator / (int x) { int r = max (red / x, 0); int g = max (green / x, 0); int b = max (blue / x, 0); return xColor (r, g, b); }
xColor xColor::operator * (double x) { int r = (int) (red * x); int g = (int) (green * x); int b = (int) (blue * x); r = max (0, min (xColorMax, r)); g = max (0, min (xColorMax, g)); b = max (0, min (xColorMax, b)); return xColor (r, g, b); }
void MannequinMoveManipulator::preDrawUI(const M3dView &view) { recalcMetrics(); _xColor = xColor(); _yColor = yColor(); _zColor = zColor(); _selColor = selectedColor(); _selected[0] = shouldDrawHandleAsSelected(0); _selected[1] = shouldDrawHandleAsSelected(1); _selected[2] = shouldDrawHandleAsSelected(2); }
void Widget::predictFutureColisions(Mat &outputFrame,vector<vector<Point> > &future){ /*para todas as posições futuras dos pontos, procura por colisões medimos a distância entre todas as partículas procurando por colisões */ for(unsigned int i = 0; i < future.size(); i++) {//para todos os objetos for(unsigned int j = i+1; j < future.size(); j++) //para todos os outros objetos { for(unsigned int n = 0; n < future[i].size(); n++){ //para todos os pontos de futuro float distance = pow(future[i][n].x - future[j][n].x, 2) + pow(future[i][n].y - future[j][n].y, 2); distance = sqrt(distance); float sumRadius = 2*Raio; if(distance < sumRadius) { float xColision = (future[i][n].x + future[j][n].x)*0.5; float yColision = (future[i][n].y + future[j][n].y)*0.5; Point colisionPoint(xColision, yColision); Scalar xColor(0, 0, 0); int xSize = 10; Draw::Cross(outputFrame, colisionPoint, xColor, xSize); if(CONTROL_RECORDING){ float x = iteration_recording; float y = colisionPoint.x; float z = colisionPoint.y; QVector3D tripla(x,y,z); toRecord_colisionsPoints.push_back(tripla); } break; //se já achou uma colisão, passa para o próximo possível alvo } } } } }
void SGTransformManip::draw(int manipIndex, bool hideMode ) { double manipSize = SGMatrix::getManipSizeFromWorldPoint( intersector.center, SGMatrix::getCamMatrix() ); double centerSize = intersector.centerSize / manipSize; GLushort linePattern = 0x5555; MColor xColor(1, 0, 0); MColor yColor(0, 1, 0); MColor zColor(0, 0, 1); MColor cColor(100/255.0f, 220/255.0f, 255/255.0f); if (intersectType == SGTransformManipIntersector::kCenter) cColor = MColor(1, 1, 0); else if (intersectType == SGTransformManipIntersector::kX) xColor = MColor(1, 1, 0); else if (intersectType == SGTransformManipIntersector::kY) yColor = MColor(1, 1, 0); else if (intersectType == SGTransformManipIntersector::kZ) zColor = MColor(1, 1, 0); MVector camX = SGMatrix::getCamVector(0).normal() * centerSize; MVector camY = SGMatrix::getCamVector(1).normal() * centerSize; MPointArray centerManipPoints; centerManipPoints.setLength(5); centerManipPoints[0] = camX + camY + intersector.center; centerManipPoints[1] = -camX + camY + intersector.center; centerManipPoints[2] = -camX - camY + intersector.center; centerManipPoints[3] = camX - camY + intersector.center; centerManipPoints[4] = centerManipPoints[0]; MPointArray xLine, yLine, zLine; xLine.setLength(2);yLine.setLength(2);zLine.setLength(2); xLine[0] = intersector.center; xLine[1] = intersector.axisX + xLine[0]; yLine[0] = intersector.center; yLine[1] = intersector.axisY + yLine[0]; zLine[0] = intersector.center; zLine[1] = intersector.axisZ + zLine[0]; manip->pushLine(manipIndex, xLine, xColor, 1, &linePattern); manip->pushLine(manipIndex, yLine, yColor, 1, &linePattern); manip->pushLine(manipIndex, zLine, zColor, 1, &linePattern); if (!hideMode) { manip->pushShape(manipIndex, cone.shape, intersector.coneXMatrix, xColor); manip->pushShape(manipIndex, cone.shape, intersector.coneYMatrix, yColor); manip->pushShape(manipIndex, cone.shape, intersector.coneZMatrix, zColor); manip->pushLine(manipIndex, centerManipPoints, cColor, 1, &linePattern); } }
void rotationWidget::paintEvent(QPaintEvent *){ int side = qMin(width(), height()); double_point3 vec(0,0,90);//centro sfera double_point3 front(0,0,80); double_point3 back(0,0,-80); double_point3 left(-80,0,0); double_point3 right(80,0,0); double_point3 top(0,80,0); double_point3 bottom(0,-80,0); rot.applyTransform(vec); rot.applyTransform(front); rot.applyTransform(back); rot.applyTransform(left); rot.applyTransform(right); rot.applyTransform(top); rot.applyTransform(bottom); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); //coordinate tra -100 e 100 painter.translate(width() / 2, height() / 2); painter.scale(side / 200.0, side / 200.0); QColor ellipseColor(0, 0, 127, 128); QColor pointColor(255, 0, 0); QColor xColor(255, 0, 0); QColor yColor(0, 255, 0); QColor zColor(0, 0, 255); if ( !isEnabled() ){ ellipseColor=ellipseColor.darker(300); pointColor=pointColor.darker(300); xColor=xColor.darker(300); yColor=yColor.darker(300); zColor=zColor.darker(300); } if (vec.z()<0){ //sul retro painter.setBrush(pointColor); painter.setPen(Qt::SolidLine); painter.drawEllipse(QRectF(vec.x()-10,vec.y()-10,20,20)); } painter.setPen(Qt::NoPen); painter.setBrush(ellipseColor); painter.drawEllipse(QRectF(-80,-80,160,160)); painter.setPen(Qt::SolidLine); painter.setPen(zColor); painter.drawLine(QLine((int)front.x(),(int)front.y(),(int)back.x(),(int)back.y())); painter.setPen(xColor); painter.drawLine(QLine((int)left.x(),(int)left.y(),(int)right.x(),(int)right.y())); painter.setPen(yColor); painter.drawLine(QLine((int)top.x(),(int)top.y(),(int)bottom.x(),(int)bottom.y())); if (vec.z()>=0){ //sul fronte painter.setBrush(pointColor); painter.setPen(Qt::SolidLine); painter.drawEllipse(QRectF(vec.x()-10,vec.y()-10,20,20)); } }