Java Code Examples for com.badlogic.gdx.utils.Array#toArray()

The following examples show how to use com.badlogic.gdx.utils.Array#toArray() . 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: DirectoryBar.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
public Bar[] getChildren(Mode mode, boolean containsSameFolder) {
	Array<Bar> l = new Array<Bar>();
	for (Bar b : getChildren()) {
		if (!(mode != null && b instanceof SongBar && ((SongBar) b).getSongData().getMode() != 0
				&& ((SongBar) b).getSongData().getMode() != mode.id)) {
			boolean addBar = true;
			if (!containsSameFolder) {
				for (Bar bar : l) {
					if (b instanceof SongBar && bar instanceof SongBar
							&& ((SongBar) b).getSongData().getFolder() != null && ((SongBar) b).getSongData()
									.getFolder().equals(((SongBar) bar).getSongData().getFolder())) {
						addBar = false;
						break;
					}
				}
			}
			if (addBar) {
				l.add(b);
			}
		}
	}
	return l.toArray(Bar.class);
}
 
Example 2
Source File: MainState.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
public Path[] getSoundPaths(String filename, SoundType type) {
	Path p = null;
	switch (type) {
	case BGM:
		p = main.getSoundManager().getBGMPath();
		break;
	case SOUND:
		p = main.getSoundManager().getSoundPath();
		break;
	}
	
	Array<Path> paths = new Array();
	if(p != null) {
		paths.addAll(AudioDriver.getPaths(p.resolve(filename).toString()));			
	}
	paths.addAll(AudioDriver.getPaths("defaultsound/" + filename.substring(filename.contains("/") || filename.contains("\\") ? Math.max(filename.lastIndexOf('/'),filename.lastIndexOf('\\')) + 1 : 0)));
	return paths.toArray(Path.class);
}
 
Example 3
Source File: KeySoundProcessor.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
public AutoplayThread(BMSModel model, long starttime) {
	this.starttime = starttime;
	Array<TimeLine> tls = new Array<TimeLine>();
	for(TimeLine tl : model.getAllTimeLines()) {
		if(tl.getBackGroundNotes().length > 0) {
			tls.add(tl);
		}
	}
	timelines = tls.toArray(TimeLine.class);
}
 
Example 4
Source File: MG3dModelLoader.java    From Mundus with Apache License 2.0 5 votes vote down vote up
private VertexAttribute[] parseAttributes(JsonValue attributes) {
    Array<VertexAttribute> vertexAttributes = new Array<VertexAttribute>();
    int unit = 0;
    int blendWeightCount = 0;
    for (JsonValue value = attributes.child; value != null; value = value.next) {
        String attribute = value.asString();
        String attr = (String) attribute;
        if (attr.equals("POSITION")) {
            vertexAttributes.add(VertexAttribute.Position());
        } else if (attr.equals("NORMAL")) {
            vertexAttributes.add(VertexAttribute.Normal());
        } else if (attr.equals("COLOR")) {
            vertexAttributes.add(VertexAttribute.ColorUnpacked());
        } else if (attr.equals("COLORPACKED")) {
            vertexAttributes.add(VertexAttribute.ColorPacked());
        } else if (attr.equals("TANGENT")) {
            vertexAttributes.add(VertexAttribute.Tangent());
        } else if (attr.equals("BINORMAL")) {
            vertexAttributes.add(VertexAttribute.Binormal());
        } else if (attr.startsWith("TEXCOORD")) {
            vertexAttributes.add(VertexAttribute.TexCoords(unit++));
        } else if (attr.startsWith("BLENDWEIGHT")) {
            vertexAttributes.add(VertexAttribute.BoneWeight(blendWeightCount++));
        } else {
            throw new GdxRuntimeException("Unknown vertex attribute '" + attr
                    + "', should be one of position, normal, uv, tangent or binormal");
        }
    }
    return vertexAttributes.toArray(VertexAttribute.class);
}
 
Example 5
Source File: HeadlessG3dModelLoader.java    From gdx-proto with Apache License 2.0 5 votes vote down vote up
private VertexAttribute[] parseAttributes (JsonValue attributes) {
	Array<VertexAttribute> vertexAttributes = new Array<VertexAttribute>();
	int unit = 0;
	int blendWeightCount = 0;
	for (JsonValue value = attributes.child; value != null; value = value.next) {
		String attribute = value.asString();
		String attr = (String)attribute;
		if (attr.equals("POSITION")) {
			vertexAttributes.add(VertexAttribute.Position());
		} else if (attr.equals("NORMAL")) {
			vertexAttributes.add(VertexAttribute.Normal());
		} else if (attr.equals("COLOR")) {
			vertexAttributes.add(VertexAttribute.ColorUnpacked());
		} else if (attr.equals("COLORPACKED")) {
			vertexAttributes.add(VertexAttribute.Color());
		} else if (attr.equals("TANGENT")) {
			vertexAttributes.add(VertexAttribute.Tangent());
		} else if (attr.equals("BINORMAL")) {
			vertexAttributes.add(VertexAttribute.Binormal());
		} else if (attr.startsWith("TEXCOORD")) {
			vertexAttributes.add(VertexAttribute.TexCoords(unit++));
		} else if (attr.startsWith("BLENDWEIGHT")) {
			vertexAttributes.add(VertexAttribute.BoneWeight(blendWeightCount++));
		} else {
			throw new GdxRuntimeException("Unknown vertex attribute '" + attr
					+ "', should be one of position, normal, uv, tangent or binormal");
		}
	}
	return vertexAttributes.toArray(VertexAttribute.class);
}
 
Example 6
Source File: MG3dModelLoader.java    From Mundus with Apache License 2.0 4 votes vote down vote up
private void parseMeshes(ModelData model, JsonValue json) {
    JsonValue meshes = json.get("meshes");
    if (meshes != null) {

        model.meshes.ensureCapacity(meshes.size);
        for (JsonValue mesh = meshes.child; mesh != null; mesh = mesh.next) {
            ModelMesh jsonMesh = new ModelMesh();

            String id = mesh.getString("id", "");
            jsonMesh.id = id;

            JsonValue attributes = mesh.require("attributes");
            jsonMesh.attributes = parseAttributes(attributes);
            jsonMesh.vertices = mesh.require("vertices").asFloatArray();

            JsonValue meshParts = mesh.require("parts");
            Array<ModelMeshPart> parts = new Array<ModelMeshPart>();
            for (JsonValue meshPart = meshParts.child; meshPart != null; meshPart = meshPart.next) {
                ModelMeshPart jsonPart = new ModelMeshPart();
                String partId = meshPart.getString("id", null);
                if (partId == null) {
                    throw new GdxRuntimeException("Not id given for mesh part");
                }
                for (ModelMeshPart other : parts) {
                    if (other.id.equals(partId)) {
                        throw new GdxRuntimeException("Mesh part with id '" + partId + "' already in defined");
                    }
                }
                jsonPart.id = partId;

                String type = meshPart.getString("type", null);
                if (type == null) {
                    throw new GdxRuntimeException("No primitive type given for mesh part '" + partId + "'");
                }
                jsonPart.primitiveType = parseType(type);

                jsonPart.indices = meshPart.require("indices").asShortArray();
                parts.add(jsonPart);
            }
            jsonMesh.parts = parts.toArray(ModelMeshPart.class);
            model.meshes.add(jsonMesh);
        }
    }
}
 
Example 7
Source File: HeadlessG3dModelLoader.java    From gdx-proto with Apache License 2.0 4 votes vote down vote up
private void parseMeshes (ModelData model, JsonValue json) {
	JsonValue meshes = json.require("meshes");

	model.meshes.ensureCapacity(meshes.size);
	for (JsonValue mesh = meshes.child; mesh != null; mesh = mesh.next) {
		ModelMesh jsonMesh = new ModelMesh();

		String id = mesh.getString("id", "");
		jsonMesh.id = id;

		JsonValue attributes = mesh.require("attributes");
		jsonMesh.attributes = parseAttributes(attributes);
		jsonMesh.vertices = mesh.require("vertices").asFloatArray();

		JsonValue meshParts = mesh.require("parts");
		Array<ModelMeshPart> parts = new Array<ModelMeshPart>();
		for (JsonValue meshPart = meshParts.child; meshPart != null; meshPart = meshPart.next) {
			ModelMeshPart jsonPart = new ModelMeshPart();
			String partId = meshPart.getString("id", null);
			if (id == null) {
				throw new GdxRuntimeException("Not id given for mesh part");
			}
			for (ModelMeshPart other : parts) {
				if (other.id.equals(partId)) {
					throw new GdxRuntimeException("Mesh part with id '" + partId + "' already in defined");
				}
			}
			jsonPart.id = partId;

			String type = meshPart.getString("type", null);
			if (type == null) {
				throw new GdxRuntimeException("No primitive type given for mesh part '" + partId + "'");
			}
			jsonPart.primitiveType = parseType(type);

			jsonPart.indices = meshPart.require("indices").asShortArray();
			parts.add(jsonPart);
		}
		jsonMesh.parts = parts.toArray(ModelMeshPart.class);
		model.meshes.add(jsonMesh);
	}
}