Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
149 changes: 149 additions & 0 deletions glTF-Toolkit.UWP.Test/Assets/Avocado/Avocado.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"accessors": [
{
"bufferView": 0,
"componentType": 5126,
"count": 406,
"type": "VEC2"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 406,
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5126,
"count": 406,
"type": "VEC4"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 406,
"type": "VEC3",
"max": [
0.02128091,
0.06284806,
0.0138090011
],
"min": [
-0.02128091,
-4.773855E-05,
-0.013809
]
},
{
"bufferView": 4,
"componentType": 5123,
"count": 2046,
"type": "SCALAR"
}
],
"asset": {
"generator": "glTF Tools for Unity",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteLength": 3248
},
{
"buffer": 0,
"byteOffset": 3248,
"byteLength": 4872
},
{
"buffer": 0,
"byteOffset": 8120,
"byteLength": 6496
},
{
"buffer": 0,
"byteOffset": 14616,
"byteLength": 4872
},
{
"buffer": 0,
"byteOffset": 19488,
"byteLength": 4092
}
],
"buffers": [
{
"uri": "Avocado.bin",
"byteLength": 23580
}
],
"images": [
{
"uri": "Avocado_baseColor.png"
},
{
"uri": "Avocado_roughnessMetallic.png"
},
{
"uri": "Avocado_normal.png"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"TEXCOORD_0": 0,
"NORMAL": 1,
"TANGENT": 2,
"POSITION": 3
},
"indices": 4,
"material": 0
}
],
"name": "Avocado"
}
],
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"metallicRoughnessTexture": {
"index": 1
}
},
"normalTexture": {
"index": 2
},
"name": "2256_Avocado_d"
}
],
"nodes": [
{
"mesh": 0,
"name": "Avocado"
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
]
}
],
"textures": [
{
"source": 0
},
{
"source": 1
},
{
"source": 2
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 70 additions & 1 deletion glTF-Toolkit.UWP.Test/UWPTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Windows.ApplicationModel;
using Windows.Foundation;
using Windows.Security.Cryptography;
using Windows.Storage;
Expand Down Expand Up @@ -74,9 +76,76 @@ public async Task GLBConvertToWindowsMR()

StorageFolder outputFolder = await CreateTemporaryOutputFolderAsync("Out_" + glbBaseName);

var converted = await WindowsMRConversion.ConvertAssetForWindowsMR(sourceGlbFile, outputFolder, 512, TexturePacking.OcclusionRoughnessMetallic);
var converted = await WindowsMRConversion.ConvertAssetForWindowsMR(sourceGlbFile, outputFolder, 1, TexturePacking.OcclusionRoughnessMetallic);

Assert.IsTrue(converted.Name == "WaterBottle_converted.glb");

var basicProperties = await converted.GetBasicPropertiesAsync();
Assert.IsTrue(basicProperties.Size > 0);
}

[TestMethod]
public async Task GLTFConvertToWindowsMR()
{
const string gltfFileName = "Avocado.gltf";

// Copy all the resources to a temp folder, and save a reference to the GLTF file
var folder = await StorageFolder.GetFolderFromPathAsync(Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Avocado"));
StorageFile copiedGltfFile = null;

foreach (var resource in await folder.GetFilesAsync())
{
var copied = await resource.CopyAsync(ApplicationData.Current.TemporaryFolder, resource.Name, NameCollisionOption.ReplaceExisting);

if (resource.Name == gltfFileName)
{
copiedGltfFile = copied;
}
}

Assert.IsNotNull(copiedGltfFile);

// Convert the file for Windows MR and pack it.
StorageFolder outputFolder = await CreateTemporaryOutputFolderAsync("Out_" + Path.GetFileNameWithoutExtension(gltfFileName));

var converted = await WindowsMRConversion.ConvertAssetForWindowsMR(copiedGltfFile, outputFolder, 1, TexturePacking.OcclusionRoughnessMetallic);

Assert.IsTrue(converted.Name == "Avocado.glb");

var basicProperties = await converted.GetBasicPropertiesAsync();
Assert.IsTrue(basicProperties.Size > 0);
}

[TestMethod]
public async Task GLTFConvertToWindowsMRFromLocalState()
{
const string gltfFileName = "Avocado.gltf";

// Copy all the resources to a temp folder, and save a reference to the GLTF file
var folder = await StorageFolder.GetFolderFromPathAsync(Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Avocado"));
StorageFile copiedGltfFile = null;

foreach (var resource in await folder.GetFilesAsync())
{
var copied = await resource.CopyAsync(ApplicationData.Current.LocalFolder, resource.Name, NameCollisionOption.ReplaceExisting);

if (resource.Name == gltfFileName)
{
copiedGltfFile = copied;
}
}

Assert.IsNotNull(copiedGltfFile);

// Convert the file for Windows MR and pack it.
StorageFolder outputFolder = await CreateTemporaryOutputFolderAsync("Out_" + Path.GetFileNameWithoutExtension(gltfFileName));

var converted = await WindowsMRConversion.ConvertAssetForWindowsMR(copiedGltfFile, outputFolder, 1, TexturePacking.OcclusionRoughnessMetallic);

Assert.IsTrue(converted.Name == "Avocado.glb");

var basicProperties = await converted.GetBasicPropertiesAsync();
Assert.IsTrue(basicProperties.Size > 0);
}
}
}
7 changes: 7 additions & 0 deletions glTF-Toolkit.UWP.Test/glTF-Toolkit.UWP.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="Assets\3DModels\WaterBottle_diffuse.png" />
<Content Include="Assets\Avocado\Avocado_baseColor.png" />
<Content Include="Assets\Avocado\Avocado_normal.png" />
<Content Include="Assets\Avocado\Avocado_roughnessMetallic.png" />
<Content Include="Properties\UnitTestApp.rd.xml" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\SplashScreen.scale-200.png" />
Expand Down Expand Up @@ -150,6 +153,10 @@
<HintPath>..\Built\Out\v141\$(Platform)\$(Configuration)\glTF-Toolkit.UWP\Microsoft.glTF.Toolkit.UWP.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Avocado\Avocado.bin" />
<Content Include="Assets\Avocado\Avocado.gltf" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down