void GroundEyeshot::drawTileLine() { int nViewTopX = m_Eyeshot.getViewTopX(); int nViewTopY = m_Eyeshot.getViewTopY(); xs::Point ktl(nViewTopX / 64,nViewTopY / 32); int col = m_Eyeshot.getViewWidth() / 64 + 2; int row = m_Eyeshot.getViewHeight() / 32 + 2; int w = col * 64; int h = col * 32; IRenderEngine *pRenderEngine = getRenderEngine(); IRenderSystem *pRenderSystem = pRenderEngine->getRenderSystem(); ColorValue color = pRenderSystem->getColor(); pRenderSystem->beginPrimitive(PT_LINES); // 绿色 pRenderSystem->setColor(ColorValue(0,0.48f,0)); int x = -(nViewTopX - ktl.x * 64); int y = -(nViewTopY - ktl.y * 32) - h + 16; for(int i = 0; i < col; i++) { xs::Point ptFrom (x,y); xs::Point ptTo (x + w, y + h); pRenderSystem->sendVertex(Vector3(ptFrom.x,ptFrom.y,-0.998)); pRenderSystem->sendVertex(Vector3(ptTo.x,ptTo.y,-0.998)); y += 32; } for(int i = 0; i < row; i++) { xs::Point ptFrom (x,y); xs::Point ptTo (x + w, y + h); pRenderSystem->sendVertex(Vector3(ptFrom.x,ptFrom.y,-0.998)); pRenderSystem->sendVertex(Vector3(ptTo.x,ptTo.y,-0.998)); ptFrom.x = x; ptFrom.y = y; ptTo.x = x + w; ptTo.y = y - h; pRenderSystem->sendVertex(Vector3(ptFrom.x,ptFrom.y,-0.998)); pRenderSystem->sendVertex(Vector3(ptTo.x,ptTo.y,-0.998)); y += 32; } for(int i = 0; i < col; i++) { xs::Point ptFrom (x,y); xs::Point ptTo (x + w, y - h); pRenderSystem->sendVertex(Vector3(ptFrom.x,ptFrom.y,-0.998)); pRenderSystem->sendVertex(Vector3(ptTo.x,ptTo.y,-0.998)); y += 32; } pRenderSystem->endPrimitive(); pRenderSystem->setColor(color); }
void CGA::Draw(const CChromosome& chr) { const GeneGroup& genes = chr.GetGenes(); int nSize = genes.size(); ArcNode arcs[ MAX_VERTEX * ( MAX_VERTEX - 1) ]; // 获取所有弧的弧尾 弧头的坐标 for ( int i = 0; i < g_graph.graph.numEdges; ++ i ) { int nTail = g_graph.edgeNodes[i].tail; int nHead = g_graph.edgeNodes[i].adjvex; CPoint ptFrom(genes[ nTail ].nX, genes[ nTail ].nY); CPoint ptTo(genes[ nHead ].nX, genes[ nHead ].nY); arcs[ i ].ptFrom = ptFrom; arcs[ i ].ptTo = ptTo; } // for CPoint *pts = new CPoint[ nSize ](); for ( int j = 0; j < nSize; ++ j ) { pts[ j ].x = genes[ j ].nX; pts[ j ].y = genes[ j ].nY; } if ( m_pUI ) { m_pUI->Draw(pts, nSize, arcs, g_graph.graph.numEdges); } delete[] pts; pts = NULL; }
ARCVector3 OnboardSeatInSim::GetRandomPoint()const { ARCVector3 seatPos; GetPosition(seatPos); Point ptTo(m_pSeat->GetLength() * 0.25,0,0); seatPos += ptTo; double xProb, yProb; double nRadius = min(m_pSeat->GetLength()/2,m_pSeat->GetWidth())/2; ARCVector3 randomPt; do { // get 3 random numbers between 0 and 1 xProb = (double)rand() / RAND_MAX; yProb = (double)rand() / RAND_MAX; // create random point randomPt.n[VX] = seatPos.n[VX] + (xProb * nRadius); randomPt.n[VY] = seatPos.n[VY] + (yProb * nRadius); randomPt.n[VZ] = seatPos.n[VZ]; // if new point is not within polygon area, repeat } while (seatPos.DistanceTo(randomPt) > nRadius); return randomPt; }
BOOL OnboardSeatInSim::GetFrontPosition( ARCVector3& entryPos ) const { ARCVector3 seatPos; GetPosition(seatPos); Point ptTo(m_pSeat->GetLength() * 0.75,0,0); seatPos += ptTo; entryPos = seatPos; return TRUE; }
void PlasmaEffects::effects_slide(Resource *resource, wl_resource *outputResource, wl_resource *surfaceResource, uint32_t from, int32_t x, int32_t y) { Q_UNUSED(resource); QWaylandOutput *output = QWaylandOutput::fromResource(outputResource); if (!output) { qCWarning(PLASMA_EFFECTS_PROTOCOL) << "Couldn't get output from resource"; return; } QWaylandSurface *surface = QWaylandSurface::fromResource(surfaceResource); if (!surface) { qCWarning(PLASMA_EFFECTS_PROTOCOL) << "Couldn't get surface from resource"; return; } QPointF ptFrom; QPointF ptTo(x, y); switch (from) { case location_none: ptFrom.setX(output->geometry().width() / 2); ptFrom.setY(output->geometry().height() / 2); break; case location_left: ptFrom = QPointF(-surface->size().width(), 0); break; case location_top: ptFrom = QPointF(0, -surface->size().height()); break; case location_right: ptFrom = QPointF(output->geometry().width() + surface->size().width(), 0); break; case location_bottom: ptFrom = QPointF(0, output->geometry().height() + surface->size().height()); break; } for (const PlasmaSurface *plasmaSurface: m_shell->surfaces()) { if (plasmaSurface->surface() == surface) Q_EMIT plasmaSurface->window()->moveRequested(ptFrom, ptTo); } }