public void SetCustomVector(b2dJsonImage item, String propertyName, cpVect val) { m_imagesWithCustomProperties.Add(item); GetCustomPropertiesForItem(item, true).m_customPropertyMap_cpVect.Add(propertyName, val); }
public void SetImageName(b2dJsonImage image, String name) { m_imageToNameMap.Add(image, name); }
public void SetCustomFloat(b2dJsonImage item, String propertyName, float val) { m_imagesWithCustomProperties.Add(item); GetCustomPropertiesForItem(item, true).m_customPropertyMap_float.Add(propertyName, (float)val); }
public void SetCustomString(b2dJsonImage item, String propertyName, String val) { m_imagesWithCustomProperties.Add(item); GetCustomPropertiesForItem(item, true).m_customPropertyMap_string.Add(propertyName, val); }
public bool RenderOrderAscending(b2dJsonImage a, b2dJsonImage b) { return a.RenderOrder < b.RenderOrder; }
public String GetImageName(b2dJsonImage image) { if (m_imageToNameMap.ContainsKey(image)) return m_imageToNameMap[image]; return null; }
b2dJsonImage j2b2dJsonImage(JObject imageValue) { b2dJsonImage img = new b2dJsonImage(); int bodyIndex = imageValue["body"] == null ? -1 : (int)imageValue["body"]; if (-1 != bodyIndex) img.Body = lookupBodyFromIndex(bodyIndex); String imageName = imageValue["name"] == null ? "" : imageValue["name"].ToString(); if (imageName != "") { img.Name = imageName; SetImageName(img, imageName); } String fileName = imageValue["file"] == null ? "" : imageValue["file"].ToString(); //TODO: Renombramos el fichero a una ruta relativa if (fileName != "") img.File = Path.GetFileName(fileName); img.Center = jsonToVec("center", imageValue); img.Angle = jsonToFloat("angle", imageValue); img.Scale = jsonToFloat("scale", imageValue); img.Opacity = jsonToFloat("opacity", imageValue); img.RenderOrder = jsonToFloat("renderOrder", imageValue); JArray colorTintArray = (JArray)imageValue["colorTint"]; if (null != colorTintArray) { for (int i = 0; i < 4; i++) { img.ColorTint[i] = (int)colorTintArray[i]; } } img.Flip = imageValue["flip"] == null ? false : (bool)imageValue["flip"]; img.Filter = imageValue["filter"] == null ? (_b2dJsonImagefilterType) 1 : (_b2dJsonImagefilterType)(int)imageValue["filter"]; img.m_corners = new cpVect[4]; for (int i = 0; i < 4; i++) img.m_corners[i] = jsonToVec("corners", imageValue, i); JArray vertexPointerArray = (JArray)imageValue["glVertexPointer"]; JArray texCoordArray = (JArray)imageValue["glVertexPointer"]; if (null != vertexPointerArray && null != texCoordArray && vertexPointerArray.Count == texCoordArray.Count) { int numFloats = vertexPointerArray.Count; img.NumPoints = numFloats / 2; img.Points = new float[numFloats]; img.UvCoords = new float[numFloats]; for (int i = 0; i < numFloats; i++) { img.Points[i] = jsonToFloat("glVertexPointer", imageValue, i); img.UvCoords[i] = jsonToFloat("glTexCoordPointer", imageValue, i); } } JArray drawElementsArray = (JArray)imageValue["glDrawElements"]; if (null != drawElementsArray) { img.NumIndices = drawElementsArray.Count; img.Indices = new short[img.NumIndices]; for (int i = 0; i < img.NumIndices; i++) img.Indices[i] = (short)drawElementsArray[i]; } return img; }
protected void readCustomPropertiesFromJson(b2dJsonImage item, JObject value) { if (null == item) return; if (value["customProperties"] != null) return; int i = 0; JArray propValues = (JArray)value["customProperties"]; if (null != propValues) { int numPropValues = propValues.Count; for (i = 0; i < numPropValues; i++) { JObject propValue = (JObject)propValues[i]; string propertyName = propValue["name"].ToString(); if (propValue["int"] != null) SetCustomInt(item, propertyName, (int)propValue["int"]); if (propValue["float"] != null) SetCustomFloat(item, propertyName, (float)propValue["float"]); if (propValue["string"] != null) SetCustomString(item, propertyName, propValue["string"].ToString()); if (propValue["vec2"] != null) SetCustomVector(item, propertyName, this.jsonToVec("vec2", propValue)); if (propValue["bool"] != null) SetCustomBool(item, propertyName, (bool)propValue["bool"]); } } }
public void AddImage(b2dJsonImage image) { SetImageName(image, image.Name); }