Skip to content

Commit

Permalink
Finish support for EXT_texture_transform
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenvergenz committed Nov 9, 2017
1 parent 7cdf0c8 commit 737135d
Show file tree
Hide file tree
Showing 20 changed files with 1,179 additions and 9 deletions.
15 changes: 14 additions & 1 deletion GLTFSerialization/GLTFSerialization.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.13
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTFSerialization", "GLTFSerialization\GLTFSerialization.csproj", "{72AC331F-9810-4DE2-8EA3-84559A787218}"
EndProject
Expand All @@ -13,6 +13,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTFSerializationTests", "T
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTFSerializationUWPTests", "Tests\GLTFSerializationUWPTests\GLTFSerializationUWPTests.csproj", "{EAD1EF7E-A898-4741-9DF5-269A33E6F875}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLTFSerializationCLI", "GLTFSerializationCLI\GLTFSerializationCLI.csproj", "{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}"
ProjectSection(ProjectDependencies) = postProject
{72AC331F-9810-4DE2-8EA3-84559A787218} = {72AC331F-9810-4DE2-8EA3-84559A787218}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -52,6 +57,14 @@ Global
{EAD1EF7E-A898-4741-9DF5-269A33E6F875}.Release|x86.ActiveCfg = Release|x86
{EAD1EF7E-A898-4741-9DF5-269A33E6F875}.Release|x86.Build.0 = Release|x86
{EAD1EF7E-A898-4741-9DF5-269A33E6F875}.Release|x86.Deploy.0 = Release|x86
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Debug|x86.ActiveCfg = Debug|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Debug|x86.Build.0 = Debug|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Release|Any CPU.Build.0 = Release|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Release|x86.ActiveCfg = Release|Any CPU
{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace GLTF.Schema
{
class ExtTextureTransformExtension : Extension
public class ExtTextureTransformExtension : Extension
{
/// <summary>
/// The offset of the UV coordinate origin as a percentage of the texture dimensions.
Expand All @@ -28,7 +28,9 @@ class ExtTextureTransformExtension : Extension

public ExtTextureTransformExtension(Vector2 offset, Vector2 scale, int texCoord)
{

Offset = offset;
Scale = scale;
TexCoord = texCoord;
}

public JProperty Serialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace GLTF.Schema
{
class ExtTextureTransformExtensionFactory : ExtensionFactory
public class ExtTextureTransformExtensionFactory : ExtensionFactory
{
public const string EXTENSION_NAME = "EXT_texture_transform";
public const string OFFSET = "offset";
Expand Down Expand Up @@ -33,7 +33,7 @@ public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
JToken texCoordToken = extensionToken.Value[TEXCOORD];
texCoord = texCoordToken != null ? texCoordToken.DeserializeAsInt() : texCoord;
}

return new ExtTextureTransformExtension(offset, scale, texCoord);
}
}
Expand Down
3 changes: 3 additions & 0 deletions GLTFSerialization/GLTFSerialization/GLTFSerialization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net35\Newtonsoft.Json.dll</HintPath>
Expand Down
6 changes: 6 additions & 0 deletions GLTFSerialization/GLTFSerializationCLI/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
59 changes: 59 additions & 0 deletions GLTFSerialization/GLTFSerializationCLI/GLTFSerializationCLI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6D33A58F-E6C8-4BA4-9420-DFF2AFC8D813}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>GLTFSerializationCLI</RootNamespace>
<AssemblyName>GLTFSerializationCLI</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GLTFSerialization\GLTFSerialization.csproj">
<Project>{72ac331f-9810-4de2-8ea3-84559a787218}</Project>
<Name>GLTFSerialization</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
52 changes: 52 additions & 0 deletions GLTFSerialization/GLTFSerializationCLI/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.IO;
using GLTF;
using GLTF.Schema;


namespace GLTFSerializationCLI
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("GLTFSerialization CLI");
if(args.Length == 0)
{
Console.WriteLine("Usage:");
Console.WriteLine(" GLTFSerializationCLI [gltf_file]");

goto exit;
}

byte[] data;
try
{
data = System.IO.File.ReadAllBytes(args[0]);
}
catch (DirectoryNotFoundException e)
{
Console.WriteLine("Directory not found");
goto exit;
}
catch (FileNotFoundException e)
{
Console.WriteLine("File not found");
goto exit;
}

GLTFRoot root = GLTFParser.ParseJson(data);
ExtTextureTransformExtension ext = (ExtTextureTransformExtension)
root.Materials[1].PbrMetallicRoughness.BaseColorTexture.Extensions["EXT_texture_transform"];
root.Serialize(Console.Out);
Console.WriteLine();

exit:
if (System.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Press Enter to exit...");
Console.ReadLine();
}
}
}
}
36 changes: 36 additions & 0 deletions GLTFSerialization/GLTFSerializationCLI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GLTFSerializationCLI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GLTFSerializationCLI")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6d33a58f-e6c8-4ba4-9420-dff2afc8d813")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 737135d

Please sign in to comment.