Esempio n. 1
0
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);
}
Esempio n. 2
0
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;	  
	 
}