Ejemplo n.º 1
0
// Set triangle normal direction using the vertex coordinate
//   Note: assumes face direction follows right hand rule
//         with curl direction defined by Vx[0]->Vx[1]->Vx[2]
void cisstTriangle::SetNormalFromVertices()
{
  assert( Vx[0]>=0 && Vx[1]>=0 && Vx[2]>=0 );
	vct3 a = VertexCoord(0);
	vct3 b = VertexCoord(1);
	vct3 c = VertexCoord(2);
	vct3 n;
  n.CrossProductOf((b-a),(c-a));
  norm.Assign(n.Normalized());
}
Ejemplo n.º 2
0
Archivo: Util.cpp Proyecto: sjfyc/fdk
	VertexCoord locationToVertexCoord(const Location& location)
	{
		return VertexCoord(
			static_cast<CellCoord::ValueType>( (location.x-HALF_CELL_SIZE_X+1)/HALF_CELL_SIZE_X ), 
			static_cast<CellCoord::ValueType>( (location.y-HALF_CELL_SIZE_Y+1)/HALF_CELL_SIZE_Y )
			);
	}
Ejemplo n.º 3
0
void MapManager::draw()
{
	const fdkgame::navi::VertexMap& vertexMap = getVertexMap(
		fdkgame::navi::VertexMapType(g_Option.getMoveCapability(), g_Option.getUnitSize())
		);

	if (g_Option.isOn(Option::Toggle_ShowVertex))
	{		
		for (int y = 0; y < vertexMap.getSizeY(); ++y)
		{
			for (int x = 0; x < vertexMap.getSizeX(); ++x)
			{
				util::drawVertex(VertexCoord(x, y), 
					(vertexMap.getBlockValue(VertexCoord(x, y)) > 0) ? ARGB(255, 226, 98, 29) : ARGB(255, 131, 164, 108)
					);
			}
		}
	}	

	if (g_Option.isOn(Option::Toggle_ShowVertexCoordInMouse))
	{
		Location mouseLocation;
		g_HGE->Input_GetMousePos(&mouseLocation.x, &mouseLocation.y);

		VertexCoord vertexCoord = util::locationToNearestVertexCoord(mouseLocation);

		g_Font.printf(mouseLocation.x-20.0f,mouseLocation.y-20.0f,HGETEXT_LEFT,"%d,%d", vertexCoord.x, vertexCoord.y);
	}	
	if (g_Option.isOn(Option::Toggle_ShowVertexIDInMouse))
	{
		Location mouseLocation;
		g_HGE->Input_GetMousePos(&mouseLocation.x, &mouseLocation.y);

		VertexCoord vertexCoord = util::locationToNearestVertexCoord(mouseLocation);

		if (vertexMap.isValidNodeCoord(vertexCoord))
		{
			g_Font.printf(mouseLocation.x-20.0f,mouseLocation.y-20.0f,HGETEXT_LEFT,"%d", vertexMap.toNodeID(vertexCoord) );
		}		
	}
}
Ejemplo n.º 4
0
Archivo: Util.cpp Proyecto: sjfyc/fdk
	VertexCoord locationToNearestVertexCoord(const Location& location)
	{
		return VertexCoord(
			(location.x-QUATER_CELL_SIZE_X)/HALF_CELL_SIZE_X,
			(location.y-QUATER_CELL_SIZE_Y)/HALF_CELL_SIZE_Y
			);
		//VertexCoord topLeftVertexCoord = locationToVertexCoord(location);
		//Location topLeftLocation = vertexCoordToLocation(topLeftVertexCoord);
		//Location offset = location - topLeftLocation;
		//return VertexCoord(topLeftVertexCoord.x + (offset.x > QUATER_CELL_SIZE_X ? 1 : 0),
		//	topLeftVertexCoord.y + (offset.y > QUATER_CELL_SIZE_Y ? 1 : 0) ); 
	}