Ejemplo n.º 1
0
        private static void ReadVertices(KeyFloatArrayPair kfap, VertexAttachment attachment, int verticesLength, Single scale)
        {
            attachment.WorldVerticesLength = verticesLength;
            float[] vertices = kfap.FloatArrayValue.ToArray();            // GetFloatArray(map, "vertices", 1);
            if (verticesLength == vertices.Length)
            {
                if (scale != 1)
                {
                    for (int i = 0; i < vertices.Length; i++)
                    {
                        vertices[i] *= scale;
                    }
                }
                attachment.vertices = vertices;
                return;
            }
            ExposedList <float> weights = new ExposedList <float>(verticesLength * 3 * 3);
            ExposedList <int>   bones   = new ExposedList <int>(verticesLength * 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; i += 4)
                {
                    bones.Add((int)vertices[i]);
                    weights.Add(vertices[i + 1] * scale);
                    weights.Add(vertices[i + 2] * scale);
                    weights.Add(vertices[i + 3]);
                }
            }
            attachment.bones    = bones.ToArray();
            attachment.vertices = weights.ToArray();
        }
Ejemplo n.º 2
0
 public Material[] GetUpdatedShaderdMaterialsArray()
 {
     if (submeshMaterials.Count == sharedMaterials.Length)
     {
         submeshMaterials.CopyTo(sharedMaterials);
     }
     else
     {
         sharedMaterials = submeshMaterials.ToArray();
     }
     return(sharedMaterials);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取attachment的Vertices
        /// </summary>
        /// <param name="map">Map.</param>
        /// <param name="attachment">Attachment.</param>
        /// <param name="verticesLength">Vertices length.</param>
        public void ReadVertices(Dictionary <String, Object> map, VertexAttachment attachment, int verticesLength)
        {
            attachment.WorldVerticesLength = verticesLength;
            float[] vertices = GetFloatArray(map, "vertices", 1);
            float   scale    = SpineConstValue.scale;

            if (verticesLength == vertices.Length)
            {
                if (scale != 1)
                {
                    for (int i = 0; i < vertices.Length; i++)
                    {
                        vertices[i] *= scale;
                    }
                }
                attachment.vertices = vertices;
                return;
            }
            ExposedList <float> weights = new ExposedList <float> (verticesLength * 3 * 3);
            ExposedList <int>   bones   = new ExposedList <int> (verticesLength * 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; i += 4)
                {
                    bones.Add((int)vertices[i]);
                    weights.Add(vertices[i + 1] * scale);
                    weights.Add(vertices[i + 2] * scale);
                    weights.Add(vertices[i + 3]);
                }
            }
            attachment.bones    = bones.ToArray();
            attachment.vertices = weights.ToArray();
        }
		private void ReadVertices (Dictionary<String, Object> map, VertexAttachment attachment, int verticesLength) {
			attachment.WorldVerticesLength = verticesLength;
			float[] vertices = GetFloatArray(map, "vertices", 1);
			float scale = Scale;
			if (verticesLength == vertices.Length) {
				if (scale != 1) {
					for (int i = 0; i < vertices.Length; i++) {
						vertices[i] *= scale;
					}
				}
				attachment.vertices = vertices;
				return;
			}
			ExposedList<float> weights = new ExposedList<float>(verticesLength * 3 * 3);
			ExposedList<int> bones = new ExposedList<int>(verticesLength * 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; i += 4) {
					bones.Add((int)vertices[i]);
					weights.Add(vertices[i + 1] * this.Scale);
					weights.Add(vertices[i + 2] * this.Scale);
					weights.Add(vertices[i + 3]);
				}
			}
			attachment.bones = bones.ToArray();
			attachment.vertices = weights.ToArray();
		}
		private Vertices ReadVertices (Stream input, int vertexCount) {
			float scale = Scale;
			int verticesLength = vertexCount << 1;
			Vertices vertices = new Vertices();
			if(!ReadBoolean(input)) {
				vertices.vertices = ReadFloatArray(input, verticesLength, scale);
				return vertices;
			}
			var weights = new ExposedList<float>(verticesLength * 3 * 3);
			var bonesArray = new ExposedList<int>(verticesLength * 3);
			for (int i = 0; i < vertexCount; i++) {
				int boneCount = ReadVarint(input, true);
				bonesArray.Add(boneCount);
				for (int ii = 0; ii < boneCount; ii++) {
					bonesArray.Add(ReadVarint(input, true));
					weights.Add(ReadFloat(input) * scale);
					weights.Add(ReadFloat(input) * scale);
					weights.Add(ReadFloat(input));
				}
			}

			vertices.vertices = weights.ToArray();
			vertices.bones = bonesArray.ToArray();
			return vertices;
		}