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(); }
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 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)); } }