private void ReadMeshVertexColors(XFileTokenReader tokenReader) { if (tokenReader.FileReader.GetNextToken() == XToken.Name) { tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); int vertexCount = tokenReader.ReadIntegerFromList(); for (int i = 0; i < vertexCount; i++) { int index = tokenReader.ReadIntegerFromList(); XColorRgba color = new XColorRgba { Red = tokenReader.ReadFloatFromList(), Green = tokenReader.ReadFloatFromList(), Blue = tokenReader.ReadFloatFromList(), Alpha = tokenReader.ReadFloatFromList(), }; tokenReader.ReadSeparator(); this.VertexColors.Add(Tuple.Create(index, color)); } tokenReader.ReadSeparator(); tokenReader.ReadAssert(XToken.ClosedBrace); }
private void ReadMeshNormals(XFileTokenReader tokenReader) { if (tokenReader.FileReader.GetNextToken() == XToken.Name) { tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); int nNormals = tokenReader.ReadIntegerFromList(); this.Normals.Capacity = nNormals; for (int i = 0; i < nNormals; i++) { var vector = new XVector { X = tokenReader.ReadFloatFromList(), Y = tokenReader.ReadFloatFromList(), Z = tokenReader.ReadFloatFromList() }; this.Normals.Add(vector); } tokenReader.ReadSeparator(); int nFacesNormals = tokenReader.ReadIntegerFromList(); this.FacesNormalsIndices.Capacity = nFacesNormals; for (int faceIndex = 0; faceIndex < nFacesNormals; faceIndex++) { int indicesCount = tokenReader.ReadIntegerFromList(); var vertices = new List <int>(indicesCount); for (int i = 0; i < indicesCount; i++) { int v = tokenReader.ReadIntegerFromList(); vertices.Add(v); } this.FacesNormalsIndices.Add(vertices); } tokenReader.ReadSeparator(); tokenReader.ReadAssert(XToken.ClosedBrace); }
internal static XAnimationKey Read(XFileTokenReader tokenReader) { var key = new XAnimationKey(); if (tokenReader.FileReader.GetNextToken() == XToken.Name) { key.Name = tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); key.KeyType = (XAnimationKeyType)tokenReader.ReadIntegerFromList(); int keysCount = tokenReader.ReadIntegerFromList(); key.Keys.Capacity = keysCount; for (int i = 0; i < keysCount; i++) { int time = tokenReader.ReadIntegerFromList(); int valuesCount = tokenReader.ReadIntegerFromList(); float[] values = tokenReader.ReadFloatArrayFromList(valuesCount); tokenReader.ReadSeparator(); key.Keys.Add(Tuple.Create(time, values)); } tokenReader.ReadAssert(XToken.ClosedBrace); return(key); }
private void ReadVertexElements(XFileTokenReader tokenReader) { if (tokenReader.FileReader.GetNextToken() == XToken.Name) { tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); int nElements = tokenReader.ReadIntegerFromList(); this.VertexElements.Capacity = nElements; for (int i = 0; i < nElements; i++) { var element = new XVertexElement { DataType = (XVertexElementDataType)tokenReader.ReadIntegerFromList(), Method = (XVertexElementMethod)tokenReader.ReadIntegerFromList(), Usage = (XVertexElementUsage)tokenReader.ReadIntegerFromList(), UsageIndex = tokenReader.ReadIntegerFromList(), }; this.VertexElements.Add(element); } int nDWords = tokenReader.ReadIntegerFromList(); this.VertexElementsData = tokenReader.ReadUnsignedIntegerArrayFromList(nDWords); tokenReader.ReadSeparator(); tokenReader.ReadAssert(XToken.ClosedBrace); }
internal static XSkinWeights Read(XFileTokenReader tokenReader) { var skin = new XSkinWeights(); if (tokenReader.FileReader.GetNextToken() == XToken.Name) { skin.Name = tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); skin.TransformNodeName = tokenReader.ReadString(); int nWeights = tokenReader.ReadIntegerFromList(); skin.VertexIndices.Capacity = nWeights; skin.Weights.Capacity = nWeights; for (int i = 0; i < nWeights; i++) { skin.VertexIndices.Add(tokenReader.ReadIntegerFromList()); } tokenReader.ReadSeparator(); for (int i = 0; i < nWeights; i++) { skin.Weights.Add(tokenReader.ReadFloatFromList()); } tokenReader.ReadSeparator(); skin.MatrixOffset = new XMatrix4x4 { Matrix = tokenReader.ReadFloatArrayFromList(16) }; tokenReader.ReadAssert(XToken.ClosedBrace); return(skin); }
private void ReadEffectParamDWord(XFileTokenReader tokenReader) { tokenReader.ReadAssert(XToken.OpenedBrace); string paramName = tokenReader.ReadString(); int value = tokenReader.ReadIntegerFromList(); tokenReader.ReadSeparator(); this.IntegerParameters.Add(Tuple.Create(paramName, value)); tokenReader.ReadAssert(XToken.ClosedBrace); }
private void ReadEffectParamFloats(XFileTokenReader tokenReader) { tokenReader.ReadAssert(XToken.OpenedBrace); string paramName = tokenReader.ReadString(); int valuesCount = tokenReader.ReadIntegerFromList(); float[] values = tokenReader.ReadFloatArrayFromList(valuesCount); tokenReader.ReadSeparator(); this.FloatParameters.Add(Tuple.Create(paramName, values)); tokenReader.ReadAssert(XToken.ClosedBrace); }
private void ReadFVFData(XFileTokenReader tokenReader) { if (tokenReader.FileReader.GetNextToken() == XToken.Name) { tokenReader.ReadName(); } tokenReader.ReadAssert(XToken.OpenedBrace); this.FVF = tokenReader.ReadUnsignedIntegerFromList(); int count = tokenReader.ReadIntegerFromList(); for (int i = 0; i < count; i++) { this.FVFData.Add(tokenReader.ReadUnsignedIntegerFromList()); } tokenReader.ReadSeparator(); tokenReader.ReadAssert(XToken.ClosedBrace); }