Пример #1
0
 /// <summary>
 /// Uses the accessor to parse the buffer into attributes needed to construct the mesh primitive
 /// </summary>
 /// <param name="attributes">A dictionary that contains a mapping of attribute name to data needed to parse</param>
 public static void BuildMeshAttributes(ref Dictionary <string, AttributeAccessor> attributes)
 {
     if (attributes.ContainsKey(SemanticProperties.POSITION))
     {
         var          attributeAccessor = attributes[SemanticProperties.POSITION];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsVertexArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.INDICES))
     {
         var          attributeAccessor = attributes[SemanticProperties.INDICES];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsTriangles(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.NORMAL))
     {
         var          attributeAccessor = attributes[SemanticProperties.NORMAL];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsNormalArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(0)))
     {
         var          attributeAccessor = attributes[SemanticProperties.TexCoord(0)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsTexcoordArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(1)))
     {
         var          attributeAccessor = attributes[SemanticProperties.TexCoord(1)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsTexcoordArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(2)))
     {
         var          attributeAccessor = attributes[SemanticProperties.TexCoord(2)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsTexcoordArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(3)))
     {
         var          attributeAccessor = attributes[SemanticProperties.TexCoord(3)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsTexcoordArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.Color(0)))
     {
         var          attributeAccessor = attributes[SemanticProperties.Color(0)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsColorArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TANGENT))
     {
         var          attributeAccessor = attributes[SemanticProperties.TANGENT];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsTangentArray(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.Weight(0)))
     {
         var          attributeAccessor = attributes[SemanticProperties.Weight(0)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsVector4Array(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.Joint(0)))
     {
         var          attributeAccessor = attributes[SemanticProperties.Joint(0)];
         NumericArray resultArray       = attributeAccessor.AccessorContent;
         byte[]       bufferViewCache;
         int          offset = (int)LoadBufferView(attributeAccessor, out bufferViewCache);
         attributeAccessor.AccessorId.Value.AsVector4Array(ref resultArray, bufferViewCache, offset);
         attributeAccessor.AccessorContent = resultArray;
     }
 }
Пример #2
0
 /// <summary>
 /// Uses the accessor to parse the buffer into attributes needed to construct the mesh primitive
 /// </summary>
 /// <param name="attributes">A dictionary that contains a mapping of attribute name to data needed to parse</param>
 public static void BuildMeshAttributes(ref Dictionary <string, AttributeAccessor> attributes)
 {
     if (attributes.ContainsKey(SemanticProperties.POSITION))
     {
         var          attributeBuilder = attributes[SemanticProperties.POSITION];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsVertexArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.INDICES))
     {
         var          attributeBuilder = attributes[SemanticProperties.INDICES];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsTriangles(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.NORMAL))
     {
         var          attributeBuilder = attributes[SemanticProperties.NORMAL];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsNormalArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(0)))
     {
         var          attributeBuilder = attributes[SemanticProperties.TexCoord(0)];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsTexcoordArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(1)))
     {
         var          attributeBuilder = attributes[SemanticProperties.TexCoord(1)];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsTexcoordArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(2)))
     {
         var          attributeBuilder = attributes[SemanticProperties.TexCoord(2)];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsTexcoordArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TexCoord(3)))
     {
         var          attributeBuilder = attributes[SemanticProperties.TexCoord(3)];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsTexcoordArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.Color(0)))
     {
         var          attributeBuilder = attributes[SemanticProperties.Color(0)];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsColorArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
     if (attributes.ContainsKey(SemanticProperties.TANGENT))
     {
         var          attributeBuilder = attributes[SemanticProperties.TANGENT];
         NumericArray resultArray      = attributeBuilder.AccessorContent;
         attributeBuilder.AccessorId.Value.AsTangentArray(ref resultArray, attributeBuilder.Buffer);
         attributeBuilder.AccessorContent = resultArray;
     }
 }