Java Code Examples for com.badlogic.gdx.utils.ArrayMap#put()

The following examples show how to use com.badlogic.gdx.utils.ArrayMap#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavMeshGraph.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a map over each triangle and its Edge connections to other triangles. Each edge must follow the
 * vertex winding order of the triangle associated with it. Since all triangles are assumed to have the same
 * winding order, this means if two triangles connect, each must have its own edge connection data, where the
 * edge follows the same winding order as the triangle which owns the edge data.
 *
 * @param indexConnections
 * @param triangles
 * @param vertexVectors
 * @return
 */
private static ArrayMap<Triangle, Array<Edge>> createSharedEdgesMap(
		Array<IndexConnection> indexConnections, Array<Triangle> triangles, Vector3[] vertexVectors) {

	ArrayMap<Triangle, Array<Edge>> connectionMap = new ArrayMap<Triangle, Array<Edge>>();
	connectionMap.ordered = true;

	for (Triangle tri : triangles) {
		connectionMap.put(tri, new Array<Edge>());
	}

	for (IndexConnection i : indexConnections) {
		Triangle fromNode = triangles.get(i.fromTriIndex);
		Triangle toNode = triangles.get(i.toTriIndex);
		Vector3 edgeVertexA = vertexVectors[i.edgeVertexIndex1];
		Vector3 edgeVertexB = vertexVectors[i.edgeVertexIndex2];

		Edge edge = new Edge(fromNode, toNode, edgeVertexA, edgeVertexB);
		connectionMap.get(fromNode).add(edge);
		fromNode.connections.add(edge);
	}
	return connectionMap;
}
 
Example 2
Source File: Utils.java    From gdx-facebook with Apache License 2.0 5 votes vote down vote up
public static ArrayMap<String, String> parseQuery(String query) throws UnsupportedEncodingException {
    ArrayMap<String, String> params = new ArrayMap<String, String>();
    for (String param : query.split("&")) {
        String[] pair = param.split("=");
        String key = URLDecoder.decode(pair[0], "UTF-8");
        String value = URLDecoder.decode(pair[1], "UTF-8");
        params.put(key, value);
    }


    return params;
}
 
Example 3
Source File: NavMeshGraph.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
/**
 * Map the isolated edges for each triangle which does not have all three edges connected to other triangles.
 *
 * @param connectionMap
 * @return
 */
private static ArrayMap<Triangle, Array<Edge>> createIsolatedEdgesMap(ArrayMap<Triangle, Array<Edge>> connectionMap) {

	ArrayMap<Triangle, Array<Edge>> disconnectionMap = new ArrayMap<Triangle, Array<Edge>>();

	for (int i = 0; i < connectionMap.size; i++) {
		Triangle tri = connectionMap.getKeyAt(i);
		Array<Edge> connectedEdges = connectionMap.getValueAt(i);

		Array<Edge> disconnectedEdges = new Array<Edge>();
		disconnectionMap.put(tri, disconnectedEdges);

		if (connectedEdges.size < 3) {
			// This triangle does not have all edges connected to other triangles
			boolean ab = true;
			boolean bc = true;
			boolean ca = true;
			for (Edge edge : connectedEdges) {
				if (edge.rightVertex == tri.a && edge.leftVertex == tri.b) ab = false;
				else if (edge.rightVertex == tri.b && edge.leftVertex == tri.c) bc = false;
				else if (edge.rightVertex == tri.c && edge.leftVertex == tri.a) ca = false;
			}
			if (ab) disconnectedEdges.add(new Edge(tri, null, tri.a, tri.b));
			if (bc) disconnectedEdges.add(new Edge(tri, null, tri.b, tri.c));
			if (ca) disconnectedEdges.add(new Edge(tri, null, tri.c, tri.a));
		}
		int totalEdges = (connectedEdges.size + disconnectedEdges.size);
		if (totalEdges != 3) {
			Gdx.app.debug(TAG, "Wrong number of edges (" + totalEdges + ") in triangle " + tri.getIndex());
		}
	}
	return disconnectionMap;
}
 
Example 4
Source File: StepDetector.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override public ArrayMap<Object, SubView> createSubViews(Player viewer, PlayerColors colors) {
    ArrayMap<Object, SubView> result = new ArrayMap<Object, SubView>();
    result.put(this, new StepDetectorSubView(this));
    return result;
}
 
Example 5
Source File: Obstacle.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override public ArrayMap<Object, SubView> createSubViews(Player viewer, PlayerColors colors) {
    ArrayMap<Object, SubView> result = new ArrayMap<Object, SubView>();
    result.put(this, new ImageSubView("obstacle/" + worldObjectName));
    return result;
}
 
Example 6
Source File: WorldObject.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
public ArrayMap<Object, SubView> createSubViews(Player viewer, PlayerColors colors) {
    ArrayMap<Object, SubView> result = new ArrayMap<Object, SubView>();
    result.put(this, new ImageSubView(worldObjectName));
    return result;
}