List of usage examples for com.badlogic.gdx.utils ObjectMap get
public V get(K key)
From source file:com.ahsgaming.starbattle.json.Utils.java
License:Apache License
public static String toJsonProperty(String key, Object value) { String valueStr = value.toString(); if (value instanceof ObjectMap) { valueStr = "{"; ObjectMap<String, Object> om = (ObjectMap<String, Object>) value; for (String k : om.keys()) { valueStr += toJsonProperty(k, om.get(k)); }// ww w . j ava 2 s .c om valueStr += "}"; } else if (value instanceof Array) { valueStr = "["; Array<Object> oa = (Array<Object>) value; for (Object o : oa) { valueStr += toJsonProperty(null, o); } valueStr += "]"; } if (value instanceof String) return (key != null ? "\"" + key + "\":" : "") + "\"" + valueStr + "\","; return (key != null ? "\"" + key + "\":" : "") + valueStr + ","; }
From source file:com.ahsgaming.starbattle.json.Utils.java
License:Apache License
public static String getStringProperty(ObjectMap<String, Object> json, String id) { if (json.containsKey(id)) return json.get(id).toString(); return ""; }
From source file:com.ahsgaming.starbattle.json.Utils.java
License:Apache License
public static float getFloatProperty(ObjectMap<String, Object> json, String id) { if (json.containsKey(id)) return Float.parseFloat(json.get(id).toString()); return 0;/* www. j av a 2s.c o m*/ }
From source file:com.ahsgaming.superrummy.json.Utils.java
License:Apache License
public static String getStringProperty(ObjectMap<String, Object> json, String id, String defaultValue) { if (json.containsKey(id)) return json.get(id).toString(); return defaultValue; }
From source file:com.ahsgaming.superrummy.json.Utils.java
License:Apache License
public static float getFloatProperty(ObjectMap<String, Object> json, String id, float defaultValue) { if (json.containsKey(id)) return Float.parseFloat(json.get(id).toString()); return defaultValue; }
From source file:com.ahsgaming.superrummy.json.Utils.java
License:Apache License
public static int getIntProperty(ObjectMap<String, Object> json, String id, int defaultValue) { if (json.containsKey(id)) return (int) Float.parseFloat(json.get(id).toString()); return defaultValue; }
From source file:com.ahsgaming.valleyofbones.TextureManager.java
License:Apache License
public void loadTexturePackage(String name) { map.clear();//from w w w . jav a 2s .c o m JsonReader jsonReader = new JsonReader(); Object rObj = jsonReader.parse(Gdx.files.internal(name + "/package.json")); ObjectMap<String, Object> mapObjs = (ObjectMap<String, Object>) rObj; for (String key : mapObjs.keys()) { ObjectMap<String, Object> createObj = (ObjectMap<String, Object>) mapObjs.get(key); String file = ""; int x = 0, y = 0, w = 0, h = 0; if (createObj.containsKey("file")) { file = name + "/" + createObj.get("file").toString(); } if (createObj.containsKey("x")) { x = (int) Float.parseFloat(createObj.get("x").toString()); } if (createObj.containsKey("y")) { y = (int) Float.parseFloat(createObj.get("y").toString()); } if (createObj.containsKey("w")) { w = (int) Float.parseFloat(createObj.get("w").toString()); } if (createObj.containsKey("h")) { h = (int) Float.parseFloat(createObj.get("h").toString()); } Gdx.app.log(LOG, String.format("Loading %s from %s", key, file)); map.put(key, loadTextureRegion(file, x, y, w, h)); } }
From source file:com.badlogic.gdx.tests.g3d.shadows.system.realistic.MainShader.java
License:Apache License
public void bindDirectionalShadows(final Attributes attributes) { final DirectionalLightsAttribute dla = attributes.get(DirectionalLightsAttribute.class, DirectionalLightsAttribute.Type); final Array<DirectionalLight> dirs = dla == null ? null : dla.lights; if (dirLightsLoc >= 0) { for (int i = 0; i < directionalLights.length; i++) { if (dirs == null || dirs.size <= i) { continue; }//from w ww .ja va2 s. co m int idx = dirShadowsLoc + i * dirShadowsSize; // Shadow ObjectMap<DirectionalLight, LightProperties> dirCameras = shadowSystem.getDirectionalCameras(); DirectionalLight dl = dirs.get(i); if (shadowSystem.hasLight(dl)) { // UVTransform final TextureRegion tr = dirCameras.get(dl).region; Camera cam = dirCameras.get(dl).camera; if (cam != null) { program.setUniformf(idx + dirShadowsUvTransformOffset, tr.getU(), tr.getV(), tr.getU2() - tr.getU(), tr.getV2() - tr.getV()); // ProjViewTrans idx = dirShadowMapProjViewTransLoc + i * dirShadowMapProjViewTransSize; program.setUniformMatrix(idx, dirCameras.get(dl).camera.combined); } } if (dirLightsSize <= 0) break; } } }
From source file:com.badlogic.gdx.tests.g3d.shadows.system.realistic.MainShader.java
License:Apache License
public void bindSpotShadows(final Attributes attributes) { final SpotLightsAttribute sla = attributes.get(SpotLightsAttribute.class, SpotLightsAttribute.Type); final Array<SpotLight> spots = sla == null ? null : sla.lights; if (spotLightsLoc >= 0) { for (int i = 0; i < spotLights.length; i++) { if (spots == null || spots.size <= i) { continue; }//from w w w . j a v a2 s .c om int idx = spotShadowsLoc + i * spotShadowsSize; // Shadow ObjectMap<SpotLight, LightProperties> spotCameras = shadowSystem.getSpotCameras(); SpotLight sl = spots.get(i); if (shadowSystem.hasLight(sl)) { // UVTransform final TextureRegion tr = spotCameras.get(sl).region; Camera cam = spotCameras.get(sl).camera; if (cam != null) { program.setUniformf(idx + spotShadowsUvTransformOffset, tr.getU(), tr.getV(), tr.getU2() - tr.getU(), tr.getV2() - tr.getV()); // ProjViewTrans idx = spotShadowMapProjViewTransLoc + i * spotShadowMapProjViewTransSize; program.setUniformMatrix(idx, spotCameras.get(sl).camera.combined); } } if (spotLightsSize <= 0) break; } } }
From source file:com.blindtigergames.werescrewed.graphics.TextureAtlas.java
License:Apache License
private void load(TextureAtlasData data) { ObjectMap<TextureAtlasData.Page, Texture> pageToTexture = new ObjectMap<TextureAtlasData.Page, Texture>(); for (TextureAtlasData.Page page : data.pages) { this.collideOffsetX = page.collideOffsetX; this.collideOffsetY = page.collideOffsetY; Texture texture = null;/*w ww .ja va 2 s . c om*/ if (page.texture == null) { texture = new Texture(page.textureFile, page.format, page.useMipMaps); texture.setFilter(page.minFilter, page.magFilter); texture.setWrap(page.uWrap, page.vWrap); } else { texture = page.texture; texture.setFilter(page.minFilter, page.magFilter); texture.setWrap(page.uWrap, page.vWrap); } textures.add(texture); pageToTexture.put(page, texture); } for (TextureAtlasData.Region region : data.regions) { int width = region.width; int height = region.height; AtlasRegion atlasRegion = new AtlasRegion(pageToTexture.get(region.page), region.left, region.top, region.rotate ? height : width, region.rotate ? width : height); atlasRegion.index = region.index; atlasRegion.name = region.name; atlasRegion.offsetX = region.offsetX; atlasRegion.offsetY = region.offsetY; atlasRegion.originalHeight = region.originalHeight; atlasRegion.originalWidth = region.originalWidth; atlasRegion.rotate = region.rotate; atlasRegion.splits = region.splits; atlasRegion.pads = region.pads; if (region.flip) atlasRegion.flip(false, true); regions.add(atlasRegion); } }