Browse Source

Updated Nugets package
Toolkit: added texture transform builder
code cleanup

Vicente Penades 6 years ago
parent
commit
59cb84a770
36 changed files with 204 additions and 91 deletions
  1. 2 2
      README.md
  2. 3 3
      build/SharpGLTF.CodeGen/SharpGLTF.CodeGen.csproj
  3. 2 2
      src/Shared/_Extensions.cs
  4. 4 4
      src/SharpGLTF.Core/Memory/ColorArray.cs
  5. 4 4
      src/SharpGLTF.Core/Memory/FloatingArrays.cs
  6. 4 4
      src/SharpGLTF.Core/Memory/IntegerArrays.cs
  7. 3 3
      src/SharpGLTF.Core/Memory/MemoryAccessor.cs
  8. 2 2
      src/SharpGLTF.Core/README.md
  9. 2 2
      src/SharpGLTF.Core/Schema2/gltf.Accessors.cs
  10. 2 2
      src/SharpGLTF.Core/Schema2/gltf.Animations.cs
  11. 2 2
      src/SharpGLTF.Core/Schema2/gltf.BufferView.cs
  12. 2 2
      src/SharpGLTF.Core/Schema2/gltf.ExtensionsFactory.cs
  13. 2 2
      src/SharpGLTF.Core/Schema2/gltf.ExtraProperties.cs
  14. 2 2
      src/SharpGLTF.Core/Schema2/gltf.Images.cs
  15. 2 2
      src/SharpGLTF.Core/Schema2/gltf.LogicalChildOfRoot.cs
  16. 2 2
      src/SharpGLTF.Core/Schema2/gltf.Mesh.cs
  17. 2 2
      src/SharpGLTF.Core/Schema2/gltf.MeshPrimitive.cs
  18. 2 2
      src/SharpGLTF.Core/Schema2/gltf.Root.cs
  19. 1 1
      src/SharpGLTF.Core/Schema2/gltf.Serialization.Read.cs
  20. 2 1
      src/SharpGLTF.Core/Schema2/gltf.Serialization.Write.cs
  21. 8 3
      src/SharpGLTF.Core/Schema2/khr.lights.cs
  22. 2 2
      src/SharpGLTF.Core/SharpGLTF.Core.csproj
  23. 2 2
      src/SharpGLTF.Core/Validation/ModelException.cs
  24. 2 2
      src/SharpGLTF.Core/Validation/ValidationContext.cs
  25. 3 3
      src/SharpGLTF.Toolkit/Geometry/MeshBuilder.cs
  26. 2 2
      src/SharpGLTF.Toolkit/Geometry/PackedMeshBuilder.cs
  27. 3 3
      src/SharpGLTF.Toolkit/Geometry/PrimitiveBuilder.cs
  28. 3 3
      src/SharpGLTF.Toolkit/Geometry/Vertex.cs
  29. 4 4
      src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexUtils.cs
  30. 2 2
      src/SharpGLTF.Toolkit/IO/WavefrontWriter.cs
  31. 2 2
      src/SharpGLTF.Toolkit/Materials/MaterialBuilder.cs
  32. 68 6
      src/SharpGLTF.Toolkit/Materials/TextureBuilder.cs
  33. 12 6
      src/SharpGLTF.Toolkit/Schema2/MaterialExtensions.cs
  34. 2 2
      src/SharpGLTF.Toolkit/Schema2/MeshExtensions.cs
  35. 2 2
      src/SharpGLTF.Toolkit/SharpGLTF.Toolkit.csproj
  36. 40 1
      tests/SharpGLTF.Tests/Schema2/Authoring/ExtensionsCreationTests.cs

+ 2 - 2
README.md

@@ -21,8 +21,6 @@ The current status of the library is preview alpha, but, for some use cases it i
 - [SharpGLTF.Core](https://www.nuget.org/packages/SharpGLTF.Core)
 - [SharpGLTF.Core](https://www.nuget.org/packages/SharpGLTF.Core)
 - [SharpGLTF.Toolkit](https://www.nuget.org/packages/SharpGLTF.Toolkit)
 - [SharpGLTF.Toolkit](https://www.nuget.org/packages/SharpGLTF.Toolkit)
 
 
-Notice that SharpGLTF.1.0.0-Alpha4 has been deprecated.
-
 #### Quickstart
 #### Quickstart
 
 
 A simple example of loading a glTF file and saving it as GLB:
 A simple example of loading a glTF file and saving it as GLB:
@@ -32,6 +30,8 @@ var model = Schema2.ModelRoot.Load("model.gltf");
 model.SaveGLB("model.glb");
 model.SaveGLB("model.glb");
 ```
 ```
 
 
+More examples can be found [here](examples) and in the Test project.
+
 #### Design
 #### Design
 
 
 The framework is divided in two packages:
 The framework is divided in two packages:

+ 3 - 3
build/SharpGLTF.CodeGen/SharpGLTF.CodeGen.csproj

@@ -2,14 +2,14 @@
 
 
   <PropertyGroup>
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <OutputType>Exe</OutputType>
-    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
     <RootNamespace>glTF2Sharp</RootNamespace>
     <RootNamespace>glTF2Sharp</RootNamespace>
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
     <PackageReference Include="LibGit2Sharp" Version="0.26.0" />
     <PackageReference Include="LibGit2Sharp" Version="0.26.0" />
-    <PackageReference Include="NJsonSchema.CodeGeneration" Version="9.13.34" />
-    <PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="9.13.34" />
+    <PackageReference Include="NJsonSchema.CodeGeneration" Version="9.13.36" />
+    <PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="9.13.36" />
   </ItemGroup>
   </ItemGroup>
 
 
 </Project>
 </Project>

+ 2 - 2
src/Shared/_Extensions.cs

@@ -4,10 +4,10 @@ using System.Text;
 using System.Numerics;
 using System.Numerics;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Schema2;
+
 namespace SharpGLTF
 namespace SharpGLTF
 {
 {
-    using Schema2;
-
     /// <summary>
     /// <summary>
     /// Extensions used internally.
     /// Extensions used internally.
     /// </summary>
     /// </summary>

+ 4 - 4
src/SharpGLTF.Core/Memory/ColorArray.cs

@@ -4,12 +4,12 @@ using System.Numerics;
 using System.Collections;
 using System.Collections;
 using System.Linq;
 using System.Linq;
 
 
-namespace SharpGLTF.Memory
-{
-    using BYTES = ArraySegment<Byte>;
+using BYTES = System.ArraySegment<byte>;
 
 
-    using ENCODING = Schema2.EncodingType;
+using ENCODING = SharpGLTF.Schema2.EncodingType;
 
 
+namespace SharpGLTF.Memory
+{
     /// <summary>
     /// <summary>
     /// Wraps an encoded <see cref="BYTES"/> and exposes it as an array of <see cref="Vector4"/> values.
     /// Wraps an encoded <see cref="BYTES"/> and exposes it as an array of <see cref="Vector4"/> values.
     /// </summary>
     /// </summary>

+ 4 - 4
src/SharpGLTF.Core/Memory/FloatingArrays.cs

@@ -4,12 +4,12 @@ using System.Numerics;
 using System.Collections;
 using System.Collections;
 using System.Linq;
 using System.Linq;
 
 
-namespace SharpGLTF.Memory
-{
-    using BYTES = ArraySegment<Byte>;
+using BYTES = System.ArraySegment<byte>;
 
 
-    using ENCODING = Schema2.EncodingType;
+using ENCODING = SharpGLTF.Schema2.EncodingType;
 
 
+namespace SharpGLTF.Memory
+{
     /// <summary>
     /// <summary>
     /// Wraps an encoded <see cref="BYTES"/> and exposes it as an array of strided <see cref="Single"/> values.
     /// Wraps an encoded <see cref="BYTES"/> and exposes it as an array of strided <see cref="Single"/> values.
     /// </summary>
     /// </summary>

+ 4 - 4
src/SharpGLTF.Core/Memory/IntegerArrays.cs

@@ -3,12 +3,12 @@ using System.Collections.Generic;
 using System.Collections;
 using System.Collections;
 using System.Linq;
 using System.Linq;
 
 
-namespace SharpGLTF.Memory
-{
-    using BYTES = ArraySegment<Byte>;
+using BYTES = System.ArraySegment<byte>;
 
 
-    using ENCODING = Schema2.IndexEncodingType;
+using ENCODING = SharpGLTF.Schema2.IndexEncodingType;
 
 
+namespace SharpGLTF.Memory
+{
     /// <summary>
     /// <summary>
     /// Wraps an encoded <see cref="BYTES"/> and exposes it as an array of <see cref="UInt32"/> values
     /// Wraps an encoded <see cref="BYTES"/> and exposes it as an array of <see cref="UInt32"/> values
     /// </summary>
     /// </summary>

+ 3 - 3
src/SharpGLTF.Core/Memory/MemoryAccessor.cs

@@ -3,11 +3,11 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Numerics;
 using System.Numerics;
 
 
+using DIMENSIONS = SharpGLTF.Schema2.DimensionType;
+using ENCODING = SharpGLTF.Schema2.EncodingType;
+
 namespace SharpGLTF.Memory
 namespace SharpGLTF.Memory
 {
 {
-    using DIMENSIONS = Schema2.DimensionType;
-    using ENCODING = Schema2.EncodingType;
-
     /// <summary>
     /// <summary>
     /// Defines the pattern in which a <see cref="ArraySegment{Byte}"/> is accessed and decoded to meaningful values.
     /// Defines the pattern in which a <see cref="ArraySegment{Byte}"/> is accessed and decoded to meaningful values.
     /// </summary>
     /// </summary>

+ 2 - 2
src/SharpGLTF.Core/README.md

@@ -33,7 +33,7 @@ glTF2 stores array structures as encoded byte buffers that are not easy to handl
 
 
 - [ ] [KHR_techniques_webgl](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_techniques_webgl)
 - [ ] [KHR_techniques_webgl](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_techniques_webgl)
 
 
-- [ ] [MSFT_texture_dds](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds)
+- [x] [MSFT_texture_dds](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds)
 - [ ] [MSFT_lod](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
 - [ ] [MSFT_lod](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
   - When this extension is used, the model's visual tree needs to be abstracted, which requires an extensive API rework, or a full API layer.
   - When this extension is used, the model's visual tree needs to be abstracted, which requires an extensive API rework, or a full API layer.
 - [ ] [MSFT_packing_normalRoughnessMetallic](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_packing_normalRoughnessMetallic)
 - [ ] [MSFT_packing_normalRoughnessMetallic](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_packing_normalRoughnessMetallic)
@@ -41,7 +41,7 @@ glTF2 stores array structures as encoded byte buffers that are not easy to handl
 - [ ] [AGI_articulations](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/AGI_articulations)
 - [ ] [AGI_articulations](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/AGI_articulations)
 - [ ] [AGI_stk_metadata](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/AGI_stk_metadata)
 - [ ] [AGI_stk_metadata](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/AGI_stk_metadata)
 - [ ] [EXT_lights_image_based](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_lights_image_based)
 - [ ] [EXT_lights_image_based](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_lights_image_based)
-- [ ] [EXT_texture_webp](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp)
+- [x] [EXT_texture_webp](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp)
 - [ ] [ADOBE_materials_thin_transparency](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/ADOBE_materials_thin_transparency)
 - [ ] [ADOBE_materials_thin_transparency](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/ADOBE_materials_thin_transparency)
 
 
 
 

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Accessors.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Numerics;
 using System.Numerics;
 
 
+using SharpGLTF.Memory;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Memory;
-
     // https://github.com/KhronosGroup/glTF/issues/827#issuecomment-277537204
     // https://github.com/KhronosGroup/glTF/issues/827#issuecomment-277537204
 
 
     [System.Diagnostics.DebuggerDisplay("Accessor[{LogicalIndex}] BufferView[{SourceBufferView.LogicalIndex}][{ByteOffset}...] => 0 => {Dimensions}x{Encoding}x{Normalized} => [{Count}]")]
     [System.Diagnostics.DebuggerDisplay("Accessor[{LogicalIndex}] BufferView[{SourceBufferView.LogicalIndex}][{ByteOffset}...] => 0 => {Dimensions}x{Encoding}x{Normalized} => [{Count}]")]

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Animations.cs

@@ -4,10 +4,10 @@ using System.Text;
 using System.Linq;
 using System.Linq;
 using System.Numerics;
 using System.Numerics;
 
 
+using SharpGLTF.Collections;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Collections;
-
     [System.Diagnostics.DebuggerDisplay("Animation[{LogicalIndex}] {Name}")]
     [System.Diagnostics.DebuggerDisplay("Animation[{LogicalIndex}] {Name}")]
     public sealed partial class Animation
     public sealed partial class Animation
     {
     {

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.BufferView.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
+using BYTES = System.ArraySegment<byte>;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using BYTES = ArraySegment<Byte>;
-
     [System.Diagnostics.DebuggerTypeProxy(typeof(Debug._BufferDebugProxy))]
     [System.Diagnostics.DebuggerTypeProxy(typeof(Debug._BufferDebugProxy))]
     public sealed partial class BufferView
     public sealed partial class BufferView
     {
     {

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.ExtensionsFactory.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 using System.Text;
 using System.Text;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.IO;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using IO;
-
     static class ExtensionsFactory
     static class ExtensionsFactory
     {
     {
         // extensions design inconsistencies:
         // extensions design inconsistencies:

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.ExtraProperties.cs

@@ -4,10 +4,10 @@ using System.Linq;
 
 
 using Newtonsoft.Json;
 using Newtonsoft.Json;
 
 
+using SharpGLTF.IO;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using IO;
-
     public abstract class ExtraProperties : JsonSerializable
     public abstract class ExtraProperties : JsonSerializable
     {
     {
         #region data
         #region data

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Images.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 
 
+using BYTES = System.ArraySegment<byte>;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using BYTES = ArraySegment<Byte>;
-
     [System.Diagnostics.DebuggerDisplay("Image[{LogicalIndex}] {Name}")]
     [System.Diagnostics.DebuggerDisplay("Image[{LogicalIndex}] {Name}")]
     public sealed partial class Image
     public sealed partial class Image
     {
     {

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.LogicalChildOfRoot.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Collections;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Collections;
-
     /// <summary>
     /// <summary>
     /// All gltf elements stored in ModelRoot must inherit from this class.
     /// All gltf elements stored in ModelRoot must inherit from this class.
     /// </summary>
     /// </summary>

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Mesh.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Collections;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Collections;
-
     [System.Diagnostics.DebuggerDisplay("Mesh[{LogicalIndex}] {Name}")]
     [System.Diagnostics.DebuggerDisplay("Mesh[{LogicalIndex}] {Name}")]
     public sealed partial class Mesh
     public sealed partial class Mesh
     {
     {

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.MeshPrimitive.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Collections;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Collections;
-
     [System.Diagnostics.DebuggerDisplay("MeshPrimitive[{LogicalIndex}] {_mode} {_DebuggerDisplay_TryIdentifyContent()}")]
     [System.Diagnostics.DebuggerDisplay("MeshPrimitive[{LogicalIndex}] {_mode} {_DebuggerDisplay_TryIdentifyContent()}")]
     public sealed partial class MeshPrimitive : IChildOf<Mesh>
     public sealed partial class MeshPrimitive : IChildOf<Mesh>
     {
     {

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Root.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Collections;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Collections;
-
     [System.Diagnostics.DebuggerDisplay("Model Root")]
     [System.Diagnostics.DebuggerDisplay("Model Root")]
     public sealed partial class ModelRoot
     public sealed partial class ModelRoot
     {
     {

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.Serialization.Read.cs

@@ -5,10 +5,10 @@ using System.Linq;
 using System.Text;
 using System.Text;
 
 
 using Newtonsoft.Json;
 using Newtonsoft.Json;
+using BYTES = System.ArraySegment<byte>;
 
 
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using BYTES = ArraySegment<Byte>;
     using MODEL = ModelRoot;
     using MODEL = ModelRoot;
 
 
     /// <summary>
     /// <summary>

+ 2 - 1
src/SharpGLTF.Core/Schema2/gltf.Serialization.Write.cs

@@ -6,9 +6,10 @@ using System.Text;
 
 
 using Newtonsoft.Json;
 using Newtonsoft.Json;
 
 
+using BYTES = System.ArraySegment<byte>;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using BYTES = ArraySegment<Byte>;
     using MODEL = ModelRoot;
     using MODEL = ModelRoot;
 
 
     /// <summary>
     /// <summary>

+ 8 - 3
src/SharpGLTF.Core/Schema2/khr.lights.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 using System.Numerics;
 using System.Numerics;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Collections;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Collections;
-
     partial class KHR_lights_punctualglTFextension
     partial class KHR_lights_punctualglTFextension
     {
     {
         internal KHR_lights_punctualglTFextension(ModelRoot root)
         internal KHR_lights_punctualglTFextension(ModelRoot root)
@@ -36,7 +36,12 @@ namespace SharpGLTF.Schema2
     /// <summary>
     /// <summary>
     /// Defines all the types of <see cref="PunctualLight"/> types.
     /// Defines all the types of <see cref="PunctualLight"/> types.
     /// </summary>
     /// </summary>
-    public enum PunctualLightType { Directional, Point, Spot }
+    public enum PunctualLightType
+    {
+        Directional,
+        Point,
+        Spot
+    }
 
 
     /// <remarks>
     /// <remarks>
     /// This is part of <see href="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual"/> extension.
     /// This is part of <see href="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual"/> extension.

+ 2 - 2
src/SharpGLTF.Core/SharpGLTF.Core.csproj

@@ -40,10 +40,10 @@
   </PropertyGroup>
   </PropertyGroup>
   
   
   <ItemGroup>    
   <ItemGroup>    
-    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />    
+    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />    
     <PackageReference Include="System.Memory" Version="4.5.2" />
     <PackageReference Include="System.Memory" Version="4.5.2" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
-    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
+    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
       <PrivateAssets>all</PrivateAssets>
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
     </PackageReference>
     </PackageReference>

+ 2 - 2
src/SharpGLTF.Core/Validation/ModelException.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 using System.Reflection;
 using System.Reflection;
 using System.Text;
 using System.Text;
 
 
+using TARGET = SharpGLTF.IO.JsonSerializable;
+
 namespace SharpGLTF.Validation
 namespace SharpGLTF.Validation
 {
 {
-    using TARGET = IO.JsonSerializable;
-
     /// <summary>
     /// <summary>
     /// Represents an exception produced by the serialization or validation of a gltf model.
     /// Represents an exception produced by the serialization or validation of a gltf model.
     /// </summary>
     /// </summary>

+ 2 - 2
src/SharpGLTF.Core/Validation/ValidationContext.cs

@@ -2,10 +2,10 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
+using TARGET = SharpGLTF.IO.JsonSerializable;
+
 namespace SharpGLTF.Validation
 namespace SharpGLTF.Validation
 {
 {
-    using TARGET = IO.JsonSerializable;
-
     /// <summary>
     /// <summary>
     /// Utility class used in the process of model validation.
     /// Utility class used in the process of model validation.
     /// </summary>
     /// </summary>

+ 3 - 3
src/SharpGLTF.Toolkit/Geometry/MeshBuilder.cs

@@ -4,11 +4,11 @@ using System.Text;
 using System.Linq;
 using System.Linq;
 using System.Numerics;
 using System.Numerics;
 
 
+using SharpGLTF.Collections;
+using SharpGLTF.Geometry.VertexTypes;
+
 namespace SharpGLTF.Geometry
 namespace SharpGLTF.Geometry
 {
 {
-    using Collections;
-    using VertexTypes;
-
     public interface IMeshBuilder<TMaterial>
     public interface IMeshBuilder<TMaterial>
     {
     {
         string Name { get; set; }
         string Name { get; set; }

+ 2 - 2
src/SharpGLTF.Toolkit/Geometry/PackedMeshBuilder.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 using System.Text;
 using System.Text;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Schema2;
+
 namespace SharpGLTF.Geometry
 namespace SharpGLTF.Geometry
 {
 {
-    using Schema2;
-
     /// <summary>
     /// <summary>
     /// Used internally to convert a <see cref="MeshBuilder{TMaterial, TvP, TvM, TvS}"/>
     /// Used internally to convert a <see cref="MeshBuilder{TMaterial, TvP, TvM, TvS}"/>
     /// to <see cref="Schema2.Mesh"/>.
     /// to <see cref="Schema2.Mesh"/>.

+ 3 - 3
src/SharpGLTF.Toolkit/Geometry/PrimitiveBuilder.cs

@@ -4,11 +4,11 @@ using System.Text;
 using System.Linq;
 using System.Linq;
 using System.Numerics;
 using System.Numerics;
 
 
+using SharpGLTF.Collections;
+using SharpGLTF.Geometry.VertexTypes;
+
 namespace SharpGLTF.Geometry
 namespace SharpGLTF.Geometry
 {
 {
-    using Collections;
-    using VertexTypes;
-
     public interface IPrimitive<TMaterial>
     public interface IPrimitive<TMaterial>
     {
     {
         TMaterial Material { get; }
         TMaterial Material { get; }

+ 3 - 3
src/SharpGLTF.Toolkit/Geometry/Vertex.cs

@@ -1,12 +1,12 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
+using System.Numerics;
+
+using SharpGLTF.Geometry.VertexTypes;
 
 
 namespace SharpGLTF.Geometry
 namespace SharpGLTF.Geometry
 {
 {
-    using System.Numerics;
-    using VertexTypes;
-
     /// <summary>
     /// <summary>
     /// Represents an individual vertex object.
     /// Represents an individual vertex object.
     /// </summary>
     /// </summary>

+ 4 - 4
src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexUtils.cs

@@ -3,12 +3,12 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Numerics;
 using System.Numerics;
 
 
-namespace SharpGLTF.Geometry.VertexTypes
-{
-    using Memory;
+using SharpGLTF.Memory;
 
 
-    using JOINTWEIGHT = KeyValuePair<int, float>;
+using JOINTWEIGHT = System.Collections.Generic.KeyValuePair<int, float>;
 
 
+namespace SharpGLTF.Geometry.VertexTypes
+{
     static class VertexUtils
     static class VertexUtils
     {
     {
         public static IEnumerable<MemoryAccessor[]> CreateVertexMemoryAccessors<TvP, TvM, TvS>(this IEnumerable<IReadOnlyList<Vertex<TvP, TvM, TvS>>> vertexBlocks)
         public static IEnumerable<MemoryAccessor[]> CreateVertexMemoryAccessors<TvP, TvM, TvS>(this IEnumerable<IReadOnlyList<Vertex<TvP, TvM, TvS>>> vertexBlocks)

+ 2 - 2
src/SharpGLTF.Toolkit/IO/WavefrontWriter.cs

@@ -7,10 +7,10 @@ using System.Text;
 
 
 using static System.FormattableString;
 using static System.FormattableString;
 
 
+using SharpGLTF.Schema2;
+
 namespace SharpGLTF.IO
 namespace SharpGLTF.IO
 {
 {
-    using Schema2;
-
     using BYTES = ArraySegment<Byte>;
     using BYTES = ArraySegment<Byte>;
 
 
     using VERTEX = ValueTuple<Geometry.VertexTypes.VertexPositionNormal, Geometry.VertexTypes.VertexTexture1, Geometry.VertexTypes.VertexEmpty>;
     using VERTEX = ValueTuple<Geometry.VertexTypes.VertexPositionNormal, Geometry.VertexTypes.VertexTexture1, Geometry.VertexTypes.VertexEmpty>;

+ 2 - 2
src/SharpGLTF.Toolkit/Materials/MaterialBuilder.cs

@@ -4,10 +4,10 @@ using System.Linq;
 using System.Numerics;
 using System.Numerics;
 using System.Text;
 using System.Text;
 
 
+using ALPHA = SharpGLTF.Schema2.AlphaMode;
+
 namespace SharpGLTF.Materials
 namespace SharpGLTF.Materials
 {
 {
-    using ALPHA = Schema2.AlphaMode;
-
     [System.Diagnostics.DebuggerDisplay("{Name} {ShaderStyle}")]
     [System.Diagnostics.DebuggerDisplay("{Name} {ShaderStyle}")]
     public class MaterialBuilder
     public class MaterialBuilder
     {
     {

+ 68 - 6
src/SharpGLTF.Toolkit/Materials/TextureBuilder.cs

@@ -3,14 +3,14 @@ using System.Collections.Generic;
 using System.Numerics;
 using System.Numerics;
 using System.Text;
 using System.Text;
 
 
-namespace SharpGLTF.Materials
-{
-    using BYTES = ArraySegment<Byte>;
+using BYTES = System.ArraySegment<byte>;
 
 
-    using TEXLERP = Schema2.TextureInterpolationFilter;
-    using TEXMIPMAP = Schema2.TextureMipMapFilter;
-    using TEXWRAP = Schema2.TextureWrapMode;
+using TEXLERP = SharpGLTF.Schema2.TextureInterpolationFilter;
+using TEXMIPMAP = SharpGLTF.Schema2.TextureMipMapFilter;
+using TEXWRAP = SharpGLTF.Schema2.TextureWrapMode;
 
 
+namespace SharpGLTF.Materials
+{
     [System.Diagnostics.DebuggerDisplay("Texture {CoordinateSet} {MinFilter} {MagFilter} {WrapS} {WrapT} {Rotation} {Offset} {Scale}")]
     [System.Diagnostics.DebuggerDisplay("Texture {CoordinateSet} {MinFilter} {MagFilter} {WrapS} {WrapT} {Rotation} {Offset} {Scale}")]
     public class TextureBuilder
     public class TextureBuilder
     {
     {
@@ -32,18 +32,28 @@ namespace SharpGLTF.Materials
         private BYTES _PrimaryImageContent;
         private BYTES _PrimaryImageContent;
         private BYTES _FallbackImageContent;
         private BYTES _FallbackImageContent;
 
 
+        private TextureTransformBuilder _Transform;
+
         #endregion
         #endregion
 
 
         #region properties
         #region properties
 
 
         public int CoordinateSet { get; set; } = 0;
         public int CoordinateSet { get; set; } = 0;
 
 
+        /// <summary>
+        /// Gets or sets the default image bytes to use by this <see cref="TextureBuilder"/>,
+        /// Supported formats are: PNG, JPG, DDS and WEBP
+        /// </summary>
         public BYTES PrimaryImageContent
         public BYTES PrimaryImageContent
         {
         {
             get => _PrimaryImageContent;
             get => _PrimaryImageContent;
             set => WithImage(value);
             set => WithImage(value);
         }
         }
 
 
+        /// <summary>
+        /// Gets or sets the fallback image bytes to use by this <see cref="TextureBuilder"/>,
+        /// Supported formats are: PNG, JPG.
+        /// </summary>
         public BYTES FallbackImageContent
         public BYTES FallbackImageContent
         {
         {
             get => _FallbackImageContent;
             get => _FallbackImageContent;
@@ -58,6 +68,8 @@ namespace SharpGLTF.Materials
 
 
         public TEXWRAP WrapT { get; set; } = TEXWRAP.REPEAT;
         public TEXWRAP WrapT { get; set; } = TEXWRAP.REPEAT;
 
 
+        public TextureTransformBuilder Transform => _Transform;
+
         #endregion
         #endregion
 
 
         #region API
         #region API
@@ -123,6 +135,56 @@ namespace SharpGLTF.Materials
             return this;
             return this;
         }
         }
 
 
+        public TextureBuilder WithTransform(Single offsetX, Single offsetY, Single scaleX = 1, Single scaleY = 1, Single rotation = 0, int? coordSetOverride = null)
+        {
+            return WithTransform(new Vector2(offsetX, offsetY), new Vector2(scaleX, scaleY), rotation, coordSetOverride);
+        }
+
+        public TextureBuilder WithTransform(Vector2 offset, Vector2 scale, Single rotation = 0, int? coordSetOverride = null)
+        {
+            var xform = new TextureTransformBuilder(offset, scale, rotation, coordSetOverride);
+
+            _Transform = xform.IsDefault ? null : xform;
+
+            return this;
+        }
+
         #endregion
         #endregion
     }
     }
+
+    public class TextureTransformBuilder
+    {
+        internal TextureTransformBuilder(Vector2 offset, Vector2 scale, float rotation = 0, int? coordSetOverride = null)
+        {
+            this.Offset = offset;
+            this.Scale = scale;
+            this.Rotation = rotation;
+            this.CoordinateSetOverride = coordSetOverride;
+        }
+
+        public Vector2 Offset { get; set; }
+
+        public Vector2 Scale { get; set; } = Vector2.One;
+
+        public Single Rotation { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Texture Coordinate Set that will override <see cref="TextureBuilder.CoordinateSet"/>
+        /// If <see cref="Schema2.TextureTransform"/> is supported by the client.
+        /// </summary>
+        public int? CoordinateSetOverride { get; set; }
+
+        internal bool IsDefault
+        {
+            get
+            {
+                if (Offset != Vector2.Zero) return false;
+                if (Scale != Vector2.One) return false;
+                if (Rotation != 0) return false;
+                if (CoordinateSetOverride.HasValue) return false;
+                return false;
+            }
+        }
+
+    }
 }
 }

+ 12 - 6
src/SharpGLTF.Toolkit/Schema2/MaterialExtensions.cs

@@ -232,11 +232,12 @@ namespace SharpGLTF.Schema2
             dstChannel.Texture.WrapS = srcChannel.TextureSampler.WrapS;
             dstChannel.Texture.WrapS = srcChannel.TextureSampler.WrapS;
             dstChannel.Texture.WrapT = srcChannel.TextureSampler.WrapT;
             dstChannel.Texture.WrapT = srcChannel.TextureSampler.WrapT;
 
 
-            /*
-            dstChannel.Texture.Rotation = srcChannel.Transform?.Rotation ?? 0;
-            dstChannel.Texture.Offset = srcChannel.Transform?.Offset ?? Vector2.Zero;
-            dstChannel.Texture.Scale = srcChannel.Transform?.Scale ?? Vector2.One;
-            */
+            var srcXform = srcChannel.TextureTransform;
+
+            if (srcXform != null)
+            {
+                dstChannel.Texture.WithTransform(srcXform.Offset, srcXform.Scale, srcXform.Rotation, srcXform.TextureCoordinateOverride);
+            }
 
 
             dstChannel.Texture.PrimaryImageContent = srcChannel.Texture.PrimaryImage.GetImageContent();
             dstChannel.Texture.PrimaryImageContent = srcChannel.Texture.PrimaryImage.GetImageContent();
 
 
@@ -332,7 +333,12 @@ namespace SharpGLTF.Schema2
 
 
             dstChannel.SetTexture(srcTex.CoordinateSet, primary, fallback, srcTex.WrapS, srcTex.WrapT, srcTex.MinFilter, srcTex.MagFilter);
             dstChannel.SetTexture(srcTex.CoordinateSet, primary, fallback, srcTex.WrapS, srcTex.WrapT, srcTex.MinFilter, srcTex.MagFilter);
 
 
-            // dstChannel.SetTransform(srcTex.CoordinateSet, srcTex.Offset, srcTex.Scale, srcTex.Rotation);
+            var srcXform = srcTex.Transform;
+
+            if (srcXform != null)
+            {
+                dstChannel.SetTransform(srcXform.Offset, srcXform.Scale, srcXform.Rotation, srcXform.CoordinateSetOverride);
+            }
         }
         }
 
 
         #endregion
         #endregion

+ 2 - 2
src/SharpGLTF.Toolkit/Schema2/MeshExtensions.cs

@@ -4,10 +4,10 @@ using System.Numerics;
 using System.Text;
 using System.Text;
 using System.Linq;
 using System.Linq;
 
 
+using SharpGLTF.Memory;
+
 namespace SharpGLTF.Schema2
 namespace SharpGLTF.Schema2
 {
 {
-    using Memory;
-
     public static partial class Schema2Toolkit
     public static partial class Schema2Toolkit
     {
     {
         #region meshes
         #region meshes

+ 2 - 2
src/SharpGLTF.Toolkit/SharpGLTF.Toolkit.csproj

@@ -34,10 +34,10 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>    
   <ItemGroup>    
-    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
+    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
     <PackageReference Include="System.Memory" Version="4.5.2" />
     <PackageReference Include="System.Memory" Version="4.5.2" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
     <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
-    <PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
+    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
       <PrivateAssets>all</PrivateAssets>
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
     </PackageReference>
     </PackageReference>

+ 40 - 1
tests/SharpGLTF.Tests/Schema2/Authoring/ExtensionsCreationTests.cs

@@ -78,7 +78,7 @@ namespace SharpGLTF.Schema2.Authoring
 
 
         [TestCase("shannon-dxt5.dds")]
         [TestCase("shannon-dxt5.dds")]
         [TestCase("shannon.webp")]
         [TestCase("shannon.webp")]
-        public void CreateSceneWithTextureExtension(string textureFileName)
+        public void CreateSceneWithTextureImageExtension(string textureFileName)
         {
         {
             TestContext.CurrentContext.AttachShowDirLink();
             TestContext.CurrentContext.AttachShowDirLink();
             TestContext.CurrentContext.AttachGltfValidatorLink();
             TestContext.CurrentContext.AttachGltfValidatorLink();
@@ -118,5 +118,44 @@ namespace SharpGLTF.Schema2.Authoring
             model.AttachToCurrentTest("result_glb.glb");
             model.AttachToCurrentTest("result_glb.glb");
             model.AttachToCurrentTest("result_gltf.gltf");            
             model.AttachToCurrentTest("result_gltf.gltf");            
         }        
         }        
+
+        [Test]
+        public void CrateSceneWithTextureTransformExtension()
+        {
+            TestContext.CurrentContext.AttachShowDirLink();
+            TestContext.CurrentContext.AttachGltfValidatorLink();
+
+            var basePath = System.IO.Path.Combine(TestContext.CurrentContext.WorkDirectory, "Assets");
+
+            // first, create a default material
+            var material = new Materials.MaterialBuilder("material1")
+                .WithDoubleSide(true)
+                .WithMetallicRoughnessShader()
+                .WithChannelImage(Materials.KnownChannels.BaseColor, System.IO.Path.Combine(basePath, "shannon.jpg"));
+
+            material.GetChannel(Materials.KnownChannels.BaseColor).UseTexture().WithTransform(0.40f,0.25f, 0.5f,0.5f);
+
+            var mesh = new Geometry.MeshBuilder<VPOS, VTEX>("mesh1");
+
+            mesh
+                .UsePrimitive(material)
+                .AddPolygon
+                ((new Vector3(-10, 10, 0), new Vector2(1, 0))
+                , (new Vector3(10, 10, 0), new Vector2(0, 0))
+                , (new Vector3(10, -10, 0), new Vector2(0, 1))
+                , (new Vector3(-10, -10, 0), new Vector2(1, 1))
+                );
+
+            var model = ModelRoot.CreateModel();
+
+            model.CreateMeshes(mesh);
+
+            model.UseScene("Default")
+                .CreateNode("RootNode")
+                .WithMesh(model.LogicalMeshes[0]);
+            
+            model.AttachToCurrentTest("result_glb.glb");
+            model.AttachToCurrentTest("result_gltf.gltf");
+        }
     }
     }
 }
 }