List of usage examples for com.badlogic.gdx.utils IntArray IntArray
public IntArray(int[] array)
From source file:com.company.minery.utils.spine.SkeletonBinary.java
License:Open Source License
private Attachment readAttachment(DataInput input, Skin skin, String attachmentName, boolean nonessential) throws IOException { float scale = this.scale; String name = input.readString(); if (name == null) name = attachmentName;//w ww . jav a 2s . c om switch (AttachmentType.values()[input.readByte()]) { case region: { String path = input.readString(); if (path == null) path = name; RegionAttachment region = attachmentLoader.newRegionAttachment(skin, name, path); if (region == null) return null; region.setPath(path); region.setX(input.readFloat() * scale); region.setY(input.readFloat() * scale); region.setScaleX(input.readFloat()); region.setScaleY(input.readFloat()); region.setRotation(input.readFloat()); region.setWidth(input.readFloat() * scale); region.setHeight(input.readFloat() * scale); Color.rgba8888ToColor(region.getColor(), input.readInt()); region.updateOffset(); return region; } case boundingbox: { BoundingBoxAttachment box = attachmentLoader.newBoundingBoxAttachment(skin, name); if (box == null) return null; box.setVertices(readFloatArray(input, scale)); return box; } case mesh: { String path = input.readString(); if (path == null) path = name; MeshAttachment mesh = attachmentLoader.newMeshAttachment(skin, name, path); if (mesh == null) return null; mesh.setPath(path); float[] uvs = readFloatArray(input, 1); short[] triangles = readShortArray(input); float[] vertices = readFloatArray(input, scale); mesh.setVertices(vertices); mesh.setTriangles(triangles); mesh.setRegionUVs(uvs); mesh.updateUVs(); Color.rgba8888ToColor(mesh.getColor(), input.readInt()); mesh.setHullLength(input.readInt(true) * 2); if (nonessential) { mesh.setEdges(readIntArray(input)); mesh.setWidth(input.readFloat() * scale); mesh.setHeight(input.readFloat() * scale); } return mesh; } case skinnedmesh: { String path = input.readString(); if (path == null) path = name; SkinnedMeshAttachment mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, path); if (mesh == null) return null; mesh.setPath(path); float[] uvs = readFloatArray(input, 1); short[] triangles = readShortArray(input); int vertexCount = input.readInt(true); FloatArray weights = new FloatArray(uvs.length * 3 * 3); IntArray bones = new IntArray(uvs.length * 3); for (int i = 0; i < vertexCount; i++) { int boneCount = (int) input.readFloat(); bones.add(boneCount); for (int nn = i + boneCount * 4; i < nn; i += 4) { bones.add((int) input.readFloat()); weights.add(input.readFloat() * scale); weights.add(input.readFloat() * scale); weights.add(input.readFloat()); } } mesh.setBones(bones.toArray()); mesh.setWeights(weights.toArray()); mesh.setTriangles(triangles); mesh.setRegionUVs(uvs); mesh.updateUVs(); Color.rgba8888ToColor(mesh.getColor(), input.readInt()); mesh.setHullLength(input.readInt(true) * 2); if (nonessential) { mesh.setEdges(readIntArray(input)); mesh.setWidth(input.readFloat() * scale); mesh.setHeight(input.readFloat() * scale); } return mesh; } } return null; }
From source file:com.company.minery.utils.spine.SkeletonJson.java
License:Open Source License
private Attachment readAttachment(Skin skin, String name, JsonValue map) { float scale = this.scale; name = map.getString("name", name); String path = map.getString("path", name); switch (AttachmentType.valueOf(map.getString("type", AttachmentType.region.name()))) { case region: { RegionAttachment region = attachmentLoader.newRegionAttachment(skin, name, path); if (region == null) return null; region.setPath(path);/*from w ww.j a v a 2 s. c o m*/ region.setX(map.getFloat("x", 0) * scale); region.setY(map.getFloat("y", 0) * scale); region.setScaleX(map.getFloat("scaleX", 1)); region.setScaleY(map.getFloat("scaleY", 1)); region.setRotation(map.getFloat("rotation", 0)); region.setWidth(map.getFloat("width") * scale); region.setHeight(map.getFloat("height") * scale); String color = map.getString("color", null); if (color != null) region.getColor().set(Color.valueOf(color)); region.updateOffset(); return region; } case boundingbox: { BoundingBoxAttachment box = attachmentLoader.newBoundingBoxAttachment(skin, name); if (box == null) return null; float[] vertices = map.require("vertices").asFloatArray(); if (scale != 1) { for (int i = 0, n = vertices.length; i < n; i++) vertices[i] *= scale; } box.setVertices(vertices); return box; } case mesh: { MeshAttachment mesh = attachmentLoader.newMeshAttachment(skin, name, path); if (mesh == null) return null; mesh.setPath(path); float[] vertices = map.require("vertices").asFloatArray(); if (scale != 1) { for (int i = 0, n = vertices.length; i < n; i++) vertices[i] *= scale; } mesh.setVertices(vertices); mesh.setTriangles(map.require("triangles").asShortArray()); mesh.setRegionUVs(map.require("uvs").asFloatArray()); mesh.updateUVs(); String color = map.getString("color", null); if (color != null) mesh.getColor().set(Color.valueOf(color)); if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2); if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray()); mesh.setWidth(map.getFloat("width", 0) * scale); mesh.setHeight(map.getFloat("height", 0) * scale); return mesh; } case skinnedmesh: { SkinnedMeshAttachment mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, path); if (mesh == null) return null; mesh.setPath(path); float[] uvs = map.require("uvs").asFloatArray(); float[] vertices = map.require("vertices").asFloatArray(); FloatArray weights = new FloatArray(uvs.length * 3 * 3); IntArray bones = new IntArray(uvs.length * 3); for (int i = 0, n = vertices.length; i < n;) { int boneCount = (int) vertices[i++]; bones.add(boneCount); for (int nn = i + boneCount * 4; i < nn;) { bones.add((int) vertices[i]); weights.add(vertices[i + 1] * scale); weights.add(vertices[i + 2] * scale); weights.add(vertices[i + 3]); i += 4; } } mesh.setBones(bones.toArray()); mesh.setWeights(weights.toArray()); mesh.setTriangles(map.require("triangles").asShortArray()); mesh.setRegionUVs(uvs); mesh.updateUVs(); String color = map.getString("color", null); if (color != null) mesh.getColor().set(Color.valueOf(color)); if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2); if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray()); mesh.setWidth(map.getFloat("width", 0) * scale); mesh.setHeight(map.getFloat("height", 0) * scale); return mesh; } } // RegionSequenceAttachment regionSequenceAttachment = (RegionSequenceAttachment)attachment; // // float fps = map.getFloat("fps"); // regionSequenceAttachment.setFrameTime(fps); // // String modeString = map.getString("mode"); // regionSequenceAttachment.setMode(modeString == null ? Mode.forward : Mode.valueOf(modeString)); return null; }
From source file:com.kotcrab.vis.editor.proxy.EntityProxy.java
License:Apache License
public IntArray getGroupsIds() { return new IntArray(getGroupComponent().groupIds); }
From source file:com.kotcrab.vis.editor.serializer.cloner.IntArrayCloner.java
License:Apache License
@Override protected IntArray cloneObject(IntArray original, IDeepCloner cloner, Map<Object, Object> clones) { IntArray array = new IntArray(original.size); for (int i = 0; i < original.size; i++) array.add(original.get(i));/*w w w . java2 s . c om*/ return array; }
From source file:com.kotcrab.vis.editor.serializer.json.IntArrayJsonSerializer.java
License:Apache License
@Override public IntArray deserialize(JsonElement j, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonArray json = j.getAsJsonArray(); IntArray intArray = new IntArray(json.size()); for (int i = 0; i < json.size(); i++) { intArray.add(json.get(i).getAsInt()); }//from w w w . j av a 2s . c om return intArray; }
From source file:com.kotcrab.vis.ui.building.TableBuilder.java
License:Apache License
/** @param defaultWidgetPadding will be applied to all added widgets if no specific padding is given. */ public TableBuilder(final int estimatedWidgetsAmount, final int estimatedRowsAmount, final Padding defaultWidgetPadding) { widgets = new Array<CellWidget<? extends Actor>>(estimatedWidgetsAmount); rowSizes = new IntArray(estimatedRowsAmount); widgetPadding = defaultWidgetPadding; }
From source file:com.weimingtom.iteye.simplerpg.tiled.TiledMapPacker.java
License:Apache License
/** Typically, you should run the {@link TiledMapPacker#main(String[])} method instead of this method. Packs a directory of * Tiled Maps, adding properties to improve the speed of the {@link TileMapRenderer}. Also runs the texture packer on the tile * sets for use with a {@link TileAtlas} * @param inputDir the input directory containing the tmx files (and tile sets, relative to the path listed in the tmx file) * @param outputDir The output directory for the tmx files, should be empty before running. WARNING: Use caution if you have a * "../" in the path of your tile sets! The output for these tile sets will be relative to the output directory. For * example, if your output directory is "C:\mydir\maps" and you have a tileset with the path "../tileset.png", the * tileset will be output to "C:\mydir\" and the maps will be in "C:\mydir\maps". * @param settings the settings used in the TexturePacker */ public void processMap(File inputDir, File outputDir, Settings settings) throws IOException { FileHandle inputDirHandle = new FileHandle(inputDir.getAbsolutePath()); File[] files = inputDir.listFiles(new TmxFilter()); for (File file : files) { map = TiledLoader.createMap(new FileHandle(file.getAbsolutePath())); IntArray usedIds = null;//from ww w. j a va2s . c o m if (this.settings.stripUnusedTiles) { usedIds = new IntArray(map.layers.size() * map.height * map.width); for (TiledLayer layer : map.layers) { for (int y = 0; y < layer.tiles.length; ++y) { for (int x = 0; x < layer.tiles[y].length; ++x) { usedIds.add(layer.tiles[y][x] & ~0xE0000000); } } } } for (TileSet set : map.tileSets) { if (!processedTileSets.contains(set.imageName)) { processedTileSets.add(set.imageName); packTileSet(set, usedIds, inputDirHandle, outputDir, settings); } } writeUpdatedTMX(outputDir, map.tmxFile); } }
From source file:com.weimingtom.iteye.simplerpg.tiled.TileMapRenderer.java
License:Apache License
public TileMapRenderer(TiledMap map, TileAtlas atlas, int tilesPerBlockX, int tilesPerBlockY, float unitsPerTileX, float unitsPerTileY, ShaderProgram shader) { int[][][] tileMap = new int[map.layers.size()][][]; for (int i = 0; i < map.layers.size(); i++) { tileMap[i] = map.layers.get(i).tiles; }/*from w ww. j a va2 s.c o m*/ for (int i = 0; i < map.tileSets.size(); i++) { if (map.tileSets.get(i).tileHeight - map.tileHeight > overdrawY * unitsPerTileY) overdrawY = (map.tileSets.get(i).tileHeight - map.tileHeight) / unitsPerTileY; if (map.tileSets.get(i).tileWidth - map.tileWidth > overdrawX * unitsPerTileX) overdrawX = (map.tileSets.get(i).tileWidth - map.tileWidth) / unitsPerTileX; } String blendedTiles = map.properties.get("blended tiles"); IntArray blendedTilesArray; if (blendedTiles != null) { blendedTilesArray = createFromCSV(blendedTiles); } else { blendedTilesArray = new IntArray(0); } init(tileMap, atlas, map.tileWidth, map.tileHeight, unitsPerTileX, unitsPerTileY, blendedTilesArray, tilesPerBlockX, tilesPerBlockY, shader); this.map = map; }
From source file:de.bitowl.advent.game2.MyTiledMapPacker.java
License:Apache License
/** Returns the usedIds bucket for the given tileset name. If it doesn't exist one will be created with the specified size if * its > 0, else null will be returned. * //from w ww . j a v a2s .c om * @param size The size to use to create a new bucket if it doesn't exist, else specify 0 or lower to return null instead * @return a bucket */ private IntArray getUsedIdsBucket(String tilesetName, int size) { if (tilesetUsedIds.containsKey(tilesetName)) { return tilesetUsedIds.get(tilesetName); } if (size <= 0) { return null; } IntArray bucket = new IntArray(size); tilesetUsedIds.put(tilesetName, bucket); return bucket; }
From source file:se.toxbee.sleepfighter.challenge.sort.PermutatingListGenerator.java
License:Open Source License
@Override public int[] generateList(Random rng, int size) { IntArray arr = new IntArray(size); // Put an initial number in the list arr.add(this.generateNumber(rng)); while (arr.size < size) { /*//www. j a v a 2 s. c o m * Randomly choose a number from the list, manipulate it, and put * the result back if it is not already present. */ int number = this.manipulateNumber(arr.get(rng.nextInt(arr.size)), rng); if (!arr.contains(number)) { arr.add(number); } } PrimitiveArrays.shuffle(arr.items, rng); return arr.items; }