void VideoViewer::paintEvent(QPaintEvent *event) { QLabel::paintEvent(event); if (!enabledDrawPreviewRegion) { return; } if (isPressed && (currentPoint != QPoint(-1, -1))) { QPainter painter(this); painter.setPen(NOMAL_REGION_COLOR); QPoint leftTop(pressedPoint.x() > currentPoint.x() ? currentPoint.x() : pressedPoint.x(), pressedPoint.y() > currentPoint.y() ? currentPoint.y() : pressedPoint.y()); QPoint rightBottom(pressedPoint.x() > currentPoint.x() ? pressedPoint.x() : currentPoint.x(), pressedPoint.y() > currentPoint.y() ? pressedPoint.y() : currentPoint.y()); QPoint center((leftTop.x() + rightBottom.x()) / 2, (leftTop.y() + rightBottom.y()) / 2); int width = rightBottom.x() - leftTop.x(); int height = rightBottom.y() - leftTop.y(); int radius = 0; switch (shape) { case Shapes::Circle: radius = (int)(sqrt(SQUARE(width) + SQUARE(height)) / 2); painter.drawEllipse(center, radius, radius); break; case Shapes::Ellipse: painter.drawEllipse(center, width / 2, height / 2); break; case Shapes::Rectangle: painter.drawRect(leftTop.x(), leftTop.y(), width, height); break; default: break; } } }
void UBMagnifier::grabPoint(const QPoint &pGrab) { QMatrix transM = UBApplication::boardController->controlView()->matrix(); updPointGrab = pGrab; QPointF itemPos = gView->mapFromGlobal(pGrab); qreal zWidth = width() / (params.zoom * transM.m11()); qreal zWidthHalf = zWidth / 2; qreal zHeight = height() / (params.zoom * transM.m22()); qreal zHeightHalf = zHeight / 2; QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y()))); float x = pfScLtF.x() - zWidthHalf; float y = pfScLtF.y() - zHeightHalf; QPointF leftTop(x,y); QPointF rightBottom(x + zWidth, y + zHeight); QRectF srcRect(leftTop, rightBottom); QPixmap newPixMap(QSize(width(), height())); QPainter painter(&newPixMap); UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect); painter.end(); // pMap.fill(Qt::transparent); pMap = newPixMap; pMap.setMask(bmpMask); update(); }
bool NRectangle::draw(NGenericPixelMatrix *matrix, NPixelBox geometry, DrawOpt op) { if(!pixelBoxInLcd(geometry)) return false; NPoint rightTop(geometry.base().x() + geometry.width(), geometry.base().y()); NPoint rightBottom(geometry.base().x() + geometry.width(), geometry.base().y() + geometry.height()); NPoint leftBottom(geometry.base().x(), geometry.base().y() + geometry.height()); NLine::draw(matrix, geometry.base(), rightTop, op); NLine::draw(matrix, rightTop.setY(rightTop.y() + 1), rightBottom, op); NLine::draw(matrix, rightBottom.setX(rightBottom.x() - 1), leftBottom, op); NLine::draw(matrix, leftBottom.setY(leftBottom.y()-1), geometry.base().setY(geometry.base().y()+1), op); return true; }
void VideoViewer::mouseReleaseEvent(QMouseEvent *event) { if (currentPoint == QPoint(-1, -1)) { emit clicked(event->pos()); } else { QPoint leftTop(pressedPoint.x() > currentPoint.x() ? currentPoint.x() : pressedPoint.x(), pressedPoint.y() > currentPoint.y() ? currentPoint.y() : pressedPoint.y()); QPoint rightBottom(pressedPoint.x() > currentPoint.x() ? pressedPoint.x() : currentPoint.x(), pressedPoint.y() > currentPoint.y() ? pressedPoint.y() : currentPoint.y()); emit drawNewRegion(leftTop, rightBottom); } setCurrentPoint(-1, -1); setPressedPoint(-1, -1); isPressed = false; }
void Draw::DrawBox(const fRect &rect, float rotation, const cColorRGBA &color, Texture *texture, Shader *shader) { VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(6); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); fRect rectInProj = rect / screenSize; fPoint rightTop(rect.width, 0.0f); fPoint rightBottom(rect.width, rect.height); fPoint leftBottom(0.0f, rect.height); fMatrix4x4 rotmat = fMatrix4x4::RotationZ(rotation); rightBottom = rotmat * rightBottom / screenSize; rightBottom += rectInProj.xy(); rightTop = rotmat * rightTop / screenSize; rightTop += rectInProj.xy(); leftBottom = rotmat * leftBottom / screenSize; leftBottom += rectInProj.xy(); buffer[0].SetPosition(fVector3(rectInProj.xy(), 0.0f)); buffer[0].SetColor(color); buffer[0].SetTexcoord(fVector2(0.0f, 0.0f)); buffer[1].SetPosition(fVector3(leftBottom, 0.0f)); buffer[1].SetColor(color); buffer[1].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[2].SetPosition(fVector3(rightTop, 0.0f)); buffer[2].SetColor(color); buffer[2].SetTexcoord(fVector2(1.0f, 0.0f)); buffer[3].SetPosition(fVector3(leftBottom, 0.0f)); buffer[3].SetColor(color); buffer[3].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[4].SetPosition(fVector3(rightBottom, 0.0f)); buffer[4].SetColor(color); buffer[4].SetTexcoord(fVector2(1.0f, 1.0f)); buffer[5].SetPosition(fVector3(rightTop, 0.0f)); buffer[5].SetColor(color); buffer[5].SetTexcoord(fVector2(1.0f, 0.0f)); if(shader == NULL) { if(texture) { DrawCommand::BindTexture(0, texture); } else { DrawCommand::BindTexture(0, RenderContext::GetSingleton().GetDefaultTexture(RenderContext::DefaultTextureTypeWhite)); } } LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_TRIANGLELIST, shader); }
void UiEditorPanel::drawFrame() { CCSize size = CCSize(1000, 800); CCPoint leftBottom(0, 0); CCPoint leftTop(0, size.height); CCPoint rightBottom(size.width, 0); CCPoint rightTop(size.width, size.height); CCDrawNode *drawNode = CCDrawNode::create(); addChild(drawNode); drawNode->drawSegment(leftBottom, rightBottom, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1)); drawNode->drawSegment(rightBottom, rightTop, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1)); drawNode->drawSegment(rightTop, leftTop, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1)); drawNode->drawSegment(leftTop, leftBottom, 0.5f, ccc4f(0.5f, 0.5f, 0.5f, 1)); auto winSize = CCDirector::sharedDirector()->getWinSize(); auto offset = ccp((winSize.width - size.width) * 0.5f, (winSize.height - size.height) * 0.5f); drawNode->setPosition(offset); }
void Sprite::Draw(const iRect &frame, const iRect &rect, float rotation) { if (_texture) DrawCommand::BindTexture(0, _texture); fSize texSize(_texture->GetSize()); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(6); fRect frameInProj = frame / texSize; fRect rectInProj = rect / screenSize; fPoint rightTop(float(rect.width), 0.0f); fPoint rightBottom(float(rect.width), float(rect.height)); fPoint leftBottom(0.0f, float(rect.height)); fMatrix4x4 rotmat = fMatrix4x4::RotationZ(rotation); rightBottom = rotmat * rightBottom / screenSize; rightBottom += rectInProj.xy(); rightTop = rotmat * rightTop / screenSize; rightTop += rectInProj.xy(); leftBottom = rotmat * leftBottom / screenSize; leftBottom += rectInProj.xy(); buffer[0].SetPosition(rectInProj.xy()); buffer[0].SetColor(0xffffffff); buffer[0].SetTexcoord(fVector2(frameInProj.x, frameInProj.y)); buffer[1].SetPosition(leftBottom); buffer[1].SetColor(0xffffffff); buffer[1].SetTexcoord(fVector2(frameInProj.x, frameInProj.y+frameInProj.height)); buffer[2].SetPosition(rightTop); buffer[2].SetColor(0xffffffff); buffer[2].SetTexcoord(fVector2(frameInProj.x + frameInProj.width, frameInProj.y)); buffer[3].SetPosition(leftBottom); buffer[3].SetColor(0xffffffff); buffer[3].SetTexcoord(fVector2(frameInProj.x, frameInProj.y + frameInProj.height)); buffer[4].SetPosition(rightBottom); buffer[4].SetColor(0xffffffff); buffer[4].SetTexcoord(fVector2(frameInProj.x + frameInProj.width, frameInProj.y + frameInProj.height)); buffer[5].SetPosition(rightTop); buffer[5].SetColor(0xffffffff); buffer[5].SetTexcoord(fVector2(frameInProj.x + frameInProj.width, frameInProj.y)); LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_TRIANGLELIST); }
void Draw::DrawBox(const fRect &rect, float rotation, const cColorRGBA &leftTopColor, const cColorRGBA &rightTopColor, const cColorRGBA &leftBottomColor, const cColorRGBA &rightBottomColor) { VertexDraw2D *buffer = LE_DrawManager.GetVertexBuffer2D(6); fSize screenSize(LE_DrawManager.GetVirtualScreenSize()); fRect rectInProj = rect / screenSize; fPoint rightTop(rect.width, 0.0f); fPoint rightBottom(rect.width, rect.height); fPoint leftBottom(0.0f, rect.height); fMatrix4x4 rotmat = fMatrix4x4::RotationZ(rotation); rightBottom = rotmat * rightBottom / screenSize; rightBottom += rectInProj.xy(); rightTop = rotmat * rightTop / screenSize; rightTop += rectInProj.xy(); leftBottom = rotmat * leftBottom / screenSize; leftBottom += rectInProj.xy(); buffer[0].SetPosition(fVector3(rectInProj.xy(), 0.0f)); buffer[0].SetColor(leftTopColor); buffer[0].SetTexcoord(fVector2(0.0f, 0.0f)); buffer[1].SetPosition(fVector3(leftBottom, 0.0f)); buffer[1].SetColor(leftBottomColor); buffer[1].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[2].SetPosition(fVector3(rightTop, 0.0f)); buffer[2].SetColor(rightTopColor); buffer[2].SetTexcoord(fVector2(1.0f, 0.0f)); buffer[3].SetPosition(fVector3(leftBottom, 0.0f)); buffer[3].SetColor(leftBottomColor); buffer[3].SetTexcoord(fVector2(0.0f, 1.0f)); buffer[4].SetPosition(fVector3(rightBottom, 0.0f)); buffer[4].SetColor(rightBottomColor); buffer[4].SetTexcoord(fVector2(1.0f, 1.0f)); buffer[5].SetPosition(fVector3(rightTop, 0.0f)); buffer[5].SetColor(rightTopColor); buffer[5].SetTexcoord(fVector2(1.0f, 0.0f)); DrawCommand::BindTexture(0, 0); LE_DrawManager.Draw2DFlush(GraphicsFlag::PT_TRIANGLELIST); }
void LivingRoom::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { //画线,用于测试像素坐标和格子坐标的转换 Vec2 point = Vec2(GRIDMAP_ORIGIN_VERTEX_X, GRIDMAP_ORIGIN_VERTEX_Y); float slopeRightTop = 1.0 / std::sqrt(3.0); float slopeLeftTop = -1.0 / std::sqrt(3.0); int unitX = GRID_WIDTH_X / 2; int unitY = GRID_WIDTH_Y / 2; glLineWidth(1.0f); for (int i = 0; i < 19; ++i) { Vec2 leftBottom(0, (0 - point.x) * slopeRightTop + point.y); Vec2 rightTop(1080, (1080 - point.x) * slopeRightTop + point.y); DrawPrimitives::drawLine(leftBottom, rightTop); Vec2 leftTop(0, (0 - point.x) * slopeLeftTop + point.y); Vec2 rightBottom(1080, (1080 - point.x) * slopeLeftTop + point.y); DrawPrimitives::drawLine(leftTop, rightBottom); point.y -= unitY * 2; } }
Point3D BodyRegion::getPosition(Region region) { Point3D ret = m_center; switch (region) { case LeftTop: ret = leftTop(); break; case Top: ret = top(); break; case RightTop: ret = rightTop(); break; case Left: ret = left(); break; case Center: ret = center(); break; case Right: ret = right(); break; case LeftBottom: ret = leftBottom(); break; case Bottom: ret = bottom(); break; case RightBottom: ret = rightBottom(); break; default: break; } return ret; }
void GraphicsButton::setup() { QRectF r = this->boundingRect(); int mx = m_marginLeft; /// TODO get from keyboard definition int boxWidth = r.width() - m_marginLeft - m_marginRight; int boxHeight = r.height() - m_marginTop - m_marginBottom; /** * if group count = 2, then we have two columns,one aligned left, the other right * if group count = 1, and level count = 2,we have one column, centrally aligned * if group count = 1, and level count = 3,we have two column, left,aligned and right aligned * * Within each column, if one item, align central * if two items, align higher level top, lower level bottom * 1. one cell 2. two cells split vertically, left cell group1, right cell group 2 3. two cells split horizontally, bottom cell level1, top cell level2 (from group1) 4 three cells, split vertically, left cell split horizontally left lower, group 1 level1 left top , group 1 level2 right group2 whatever level 5 four cells , both split horizontally and vertically left low, group 1,level 1 left top, group 1,level 2 right low, group 2, level 1 right top, group 2, level 2 */ // KeyDef * key = m_keydef; switch(m_keydef->decorationCount()) { case 1 : { QRectF rect(mx,m_marginTop,boxWidth,boxHeight); decorateKey(rect,1,1); break; } case 2 : { if (m_keydef->groupCount() == 1) { // split horizontally qreal y = boxHeight/2; QRectF top(mx,m_marginTop,boxWidth,y); QRectF bottom(mx,m_marginTop + y, boxWidth,y); decorateKey(bottom,1,1); decorateKey(top,1,2); } else { qreal x = boxWidth/2; QRectF left(mx,m_marginTop,x,boxHeight); QRectF right(x,m_marginTop,x,boxHeight); decorateKey(left,1,1); decorateKey(right,2,1); } break; } case 3 : { qreal y = boxHeight/2; qreal x = boxWidth/2; QRectF leftTop(mx,m_marginTop,x,y); QRectF leftBottom(mx,m_marginTop+y,x,y); decorateKey(leftBottom,1,1); decorateKey(leftTop,1,2); /// if one group, but third level in the bottom right if (m_keydef->groupCount() == 1) { QRectF right(mx+x,m_marginTop+y,x,y); decorateKey(right,1,3); } else { // otherwise put it in the middle QRectF right(mx+x,m_marginTop,x,boxHeight); decorateKey(right,2,1); } break; } case 4: { qreal y = boxHeight/2; qreal x = boxWidth/2; QRectF leftTop(mx,m_marginTop,x,y); QRectF leftBottom(mx,m_marginTop+y,x,y); QRectF rightTop(mx+x,m_marginTop,x,y); QRectF rightBottom(mx+x,m_marginTop+y,x,y); decorateKey(leftBottom,1,1); decorateKey(leftTop,1,2); decorateKey(rightBottom,2,1); decorateKey(rightTop,2,2); break; } } setPen(QPen(m_keyboardColor)); }
void DataSetView::viewportChanged() { if(_viewportX != _viewportX || _viewportY != _viewportY || _viewportW != _viewportW || _viewportH != _viewportH ) //only possible if they are NaN return; #ifdef DEBUG_VIEWPORT std::cout << "viewportChanged!\n" <<std::flush; #endif QVector2D leftTop(_viewportX, _viewportY); QVector2D viewSize(_viewportW, _viewportH); QVector2D rightBottom(leftTop + viewSize); int currentViewportColMin = -1, currentViewportColMax = -1, currentViewportRowMin = -1, currentViewportRowMax = -1; float cumulative = 0; for(int col=0; col<_model->columnCount() && currentViewportColMax == -1; col++) { if(currentViewportColMax == -1 && cumulative > rightBottom.x()) currentViewportColMax = col; cumulative += _dataColsMaxWidth[col]; if(currentViewportColMin == -1 && cumulative > leftTop.x()) currentViewportColMin = col; } if(currentViewportColMax == -1) currentViewportColMax = _model->columnCount(); currentViewportColMin = std::max(0, currentViewportColMin - _viewportMargin); currentViewportColMax = std::min(_model->columnCount(), currentViewportColMax + _viewportMargin); currentViewportRowMin = std::max(qRound(leftTop.y() / _dataRowsMaxHeight) - 1, 0); currentViewportRowMax = std::min(qRound(rightBottom.y() / _dataRowsMaxHeight) + 1, _model->rowCount()); // remove superflouous textItems if they exist (aka store them in stack) if(_previousViewportRowMin != -1 && _previousViewportRowMax != -1 && _previousViewportColMin != -1 && _previousViewportColMax != -1) { for(int col=_previousViewportColMin; col<_previousViewportColMax; col++) { for(int row=_previousViewportRowMin; row < currentViewportRowMin; row++) storeTextItem(row, col); for(int row=currentViewportRowMax; row < _previousViewportRowMax; row++) storeTextItem(row, col); } for(int row=_previousViewportRowMin; row<_previousViewportRowMax; row++) { for(int col=_previousViewportColMin; col < currentViewportColMin; col++) storeTextItem(row, col); for(int col=currentViewportColMax; col < _previousViewportColMax; col++) storeTextItem(row, col); } for(int row=_previousViewportRowMin; row < currentViewportRowMin; row++) storeRowNumber(row); for(int row=currentViewportRowMax; row < _previousViewportRowMax; row++) storeRowNumber(row); } _lines.clear(); //and now we should create some new ones! for(int col=currentViewportColMin; col<currentViewportColMax; col++) for(int row=currentViewportRowMin; row<currentViewportRowMax; row++) { QVector2D pos0(_colXPositions[col], _dataRowsMaxHeight + row * _dataRowsMaxHeight); QVector2D pos1(pos0.x() + _dataColsMaxWidth[col], pos0.y()+ _dataRowsMaxHeight); int lineFlags = _model->data(_model->index(row, col), _roleNameToRole["lines"]).toInt(); bool left = (lineFlags & 1 > 0) && pos0.x() > _rowNumberMaxWidth + _viewportX, right = (lineFlags & 2 > 0) && pos1.x() > _rowNumberMaxWidth + _viewportX, up = lineFlags & 4 > 0 && pos0.y() > _dataRowsMaxHeight + _viewportY, down = lineFlags & 8 > 0 && pos1.y() > _dataRowsMaxHeight + _viewportY; createTextItem(row, col); if(left) _lines.push_back(std::make_pair(QVector2D(pos0.x(), pos1.y()), pos0)); if(up) _lines.push_back(std::make_pair(QVector2D(pos1.x(), pos0.y()), pos0)); if(right) _lines.push_back(std::make_pair(QVector2D(pos1.x(), pos0.y()), pos1)); if(down) _lines.push_back(std::make_pair(QVector2D(pos0.x(), pos1.y()), pos1)); } _lines.push_back(std::make_pair(QVector2D(_viewportX, _viewportY), QVector2D(_viewportX, _viewportY + _viewportH))); _lines.push_back(std::make_pair(QVector2D(_viewportX + _rowNumberMaxWidth, _viewportY), QVector2D(_viewportX + _rowNumberMaxWidth, _viewportY + _viewportH))); _lines.push_back(std::make_pair(QVector2D(_viewportX, _viewportY), QVector2D(_viewportX + _viewportW, _viewportY))); _lines.push_back(std::make_pair(QVector2D(_viewportX, _viewportY + _dataRowsMaxHeight), QVector2D(_viewportX + _viewportW, _viewportY + _dataRowsMaxHeight))); for(int row=currentViewportRowMin; row<currentViewportRowMax; row++) { createRowNumber(row); QVector2D pos0(_viewportX, (1 + row) * _dataRowsMaxHeight); QVector2D pos1(_viewportX + _rowNumberMaxWidth, (2 + row) * _dataRowsMaxHeight); if(pos0.y() > _dataRowsMaxHeight + _viewportY) _lines.push_back(std::make_pair(QVector2D(pos0.x(), pos0.y()), QVector2D(pos1.x(), pos0.y()))); if(row == _model->rowCount() - 1 && pos1.y() > _dataRowsMaxHeight + _viewportY) _lines.push_back(std::make_pair(QVector2D(pos0.x(), pos1.y()), QVector2D(pos1.x(), pos1.y()))); } for(int col=currentViewportColMin; col<currentViewportColMax; col++) { createColumnHeader(col); QVector2D pos0(_colXPositions[col], _viewportY); QVector2D pos1(pos0.x() + _dataColsMaxWidth[col], pos0.y() + _dataRowsMaxHeight); if(pos0.x() > _rowNumberMaxWidth + _viewportX) _lines.push_back(std::make_pair(QVector2D(pos0.x(), pos0.y()), QVector2D(pos0.x(), pos1.y()))); if(col == _model->columnCount() - 1 && pos1.x() > _rowNumberMaxWidth + _viewportX) _lines.push_back(std::make_pair(QVector2D(pos1.x(), pos0.y()), QVector2D(pos1.x(), pos1.y()))); } createleftTopCorner(); update(); #ifdef DEBUG_VIEWPORT std::cout << "viewport X: " << _viewportX << " Y: " << _viewportY << " W: " << _viewportW << " H: " << _viewportH << std::endl << std::flush; std::cout << "_previousViewport ColMin: "<<_previousViewportColMin<<" ColMax: "<<_previousViewportColMax<<" RowMin: "<<_previousViewportRowMin<<" RowMax: "<<_previousViewportRowMax<<"\n"; std::cout << "currentViewport ColMin: "<<currentViewportColMin<<" ColMax: "<<currentViewportColMax<<" RowMin: "<<currentViewportRowMin<<" RowMax: "<<currentViewportRowMax<<"\n"<<std::flush; #endif _previousViewportColMin = currentViewportColMin; _previousViewportColMax = currentViewportColMax; _previousViewportRowMin = currentViewportRowMin; _previousViewportRowMax = currentViewportRowMax; }
SpriteFrame::SpriteFrame(const Rectangle& pRectangle, const graphics::TexturePtr& pTexture, bool rotated, const Size2& sourceSize, const Vector2& sourceOffset, const Vector2& pivot) { texture = pTexture; std::vector<uint16_t> indices = {0, 1, 2, 1, 3, 2}; Vector2 textCoords[4]; Vector2 finalOffset(-sourceSize.width * pivot.x + sourceOffset.x, -sourceSize.height * pivot.y + (sourceSize.height - pRectangle.height - sourceOffset.y)); const Size2& textureSize = texture->getSize(); if (!rotated) { Vector2 leftTop(pRectangle.x / textureSize.width, pRectangle.y / textureSize.height); Vector2 rightBottom((pRectangle.x + pRectangle.width) / textureSize.width, (pRectangle.y + pRectangle.height) / textureSize.height); if (texture->isFlipped()) { leftTop.y = 1.0f - leftTop.y; rightBottom.y = 1.0f - rightBottom.y; } textCoords[0] = Vector2(leftTop.x, rightBottom.y); textCoords[1] = Vector2(rightBottom.x, rightBottom.y); textCoords[2] = Vector2(leftTop.x, leftTop.y); textCoords[3] = Vector2(rightBottom.x, leftTop.y); } else { Vector2 leftTop = Vector2(pRectangle.x / textureSize.width, pRectangle.y / textureSize.height); Vector2 rightBottom = Vector2((pRectangle.x + pRectangle.height) / textureSize.width, (pRectangle.y + pRectangle.width) / textureSize.height); if (texture->isFlipped()) { leftTop.y = 1.0f - leftTop.y; rightBottom.y = 1.0f - rightBottom.y; } textCoords[0] = Vector2(leftTop.x, leftTop.y); textCoords[1] = Vector2(leftTop.x, rightBottom.y); textCoords[2] = Vector2(rightBottom.x, leftTop.y); textCoords[3] = Vector2(rightBottom.x, rightBottom.y); } rectangle = Rectangle(finalOffset.x, finalOffset.y, pRectangle.width, pRectangle.height); std::vector<graphics::VertexPCT> vertices = { graphics::VertexPCT(Vector3(finalOffset.x, rectangle.y, 0.0f), graphics::Color(255, 255, 255, 255), textCoords[0]), graphics::VertexPCT(Vector3(finalOffset.x + rectangle.width, rectangle.y, 0.0f), graphics::Color(255, 255, 255, 255), textCoords[1]), graphics::VertexPCT(Vector3(finalOffset.x, rectangle.y + rectangle.height, 0.0f), graphics::Color(255, 255, 255, 255), textCoords[2]), graphics::VertexPCT(Vector3(finalOffset.x + rectangle.width, rectangle.y + rectangle.height, 0.0f), graphics::Color(255, 255, 255, 255), textCoords[3]) }; meshBuffer = sharedEngine->getRenderer()->createMeshBuffer(); meshBuffer->initFromBuffer(indices.data(), sizeof(uint16_t), static_cast<uint32_t>(indices.size()), false, vertices.data(), graphics::VertexPCT::ATTRIBUTES, static_cast<uint32_t>(vertices.size()), true); }
void NaoHeadControl::ScanAwayFromBall() { float neckYaw, headPitch; if ( headPathPlanner.isLastPathFinished()) { if (lastScanWasLeft) { Vector3f centerTop(0.0,45.0,headPathPlanner.lastNeckYaw), rightTop(0.0,45.0,-120.0), rightBottom(0.0,-45.0,-120.0); Vector3f points[4]={centerTop,rightTop, rightBottom, headDown}; headPathPlanner.oldInit(points, sizeof(points)/sizeof(Vector3f), 600); } else { Vector3f centerTop(0.0,45.0,headPathPlanner.lastNeckYaw), leftTop(0.0,45.0,120.0), leftBottom(0.0,-45.0,120.0); Vector3f points[4]={centerTop,leftTop, leftBottom, headDown}; headPathPlanner.oldInit(points, sizeof(points)/sizeof(Vector3f), 600); } lastScanWasLeft = !lastScanWasLeft; } headPathPlanner.getAngles(neckYaw, headPitch); setJointsDirect(neckYaw, headPitch); }