Code Monkey home page Code Monkey logo

unitygltf's Issues

Building for Mac?

I realize this project is pre-1.0 so you may not be expecting people to be trying to build it, but I tried anyway.

I tried the steps described in the readme:
Open GLTFSerialization\GLTFSerialization.sln and compile for release. This will put the binaries in UnityGLTF\Assets\UnityGLTF\Plugins

From within both Rider and Monodevelop without success.

In monodevelop I get a project error with GLTFSerialization "Unknown ToolsVersion 15.0" and GLTFSerializationUWP failed to load.

In Rider GLTFSerializationUWP failed to load.
MSBuild targets were not found: Make sure that all SDKs required for projects in this solution are installed, or specify a different MSBuild version in settings.

Just a heads up since I'm guessing you have larger fish to fry.

Thanks.

Project Architecture

Notes from our meeting with @MSblgross, @stevenvergenz, and Ken Wolfe.

  • Blake will be splitting his pull request into separate parts so that it is easier to review.
  • glTF Serialization/Deserialization will be split out into a separate project within this repo and moved to a separate Khronos repo when ready.
  • We'll be keeping the "UnityGLTF" name for the Unity project and using "GLTFSerialization" for the external serialization/deserialization project.
    • Note: Capitalization of GLTF will be kept this way for the sake of C#'s Pascal case for class names.
    • In the future we may try to generate the serialization code from the glTF JSON Schema, but there is additional work needed to add manual deserialization using JSON.NET.
  • Once Blake's architecture changes have landed we'll be breaking the importer/exporter code into classes for importing/exporting specific sets of Unity components.
    • An example would be MeshImporter which would generate Unity Mesh objects, cache them, and add the correct components (MeshFilter and MeshRenderer) to a node.
    • The importer/exporter will hold fields for the component importer/exporters to be used and can be extended as necessary.
    • I'll be working on a PR for these changes and have more details to discuss with the community soon.
  • Once the architecture changes are made the focus will be on supporting the full glTF 2.0 spec for runtime import.
    • @PlutoVR has been working on animation support, we'd really like to work with you to get that merged into the repository. Let us know what we can do to help.

If there are other changes you'd like to see to the architecture of the project please let us know. Ideally after making these large architectural changes we can get to a versioned, pre-alpha release and a more stable place for anyone trying to use UnityGLTF.

GLTF external assets URI needs to be enconded

Hello,

All GLTF Uri must be enconded otherwise it won't find the correct path in the webserver.

For example:
model.gltf
model.bin
textures/model's texture.jpeg

The loader will fail to find 'model's texture.jpeg'

The GLTFLoader.cs file must enconde al URIs:

For example:
image.Uri = WWW.EscapeURL (image.Uri);

Improve JSON Deserialization Performance

Currently JSON deserialization is a bit slow and not concurrent. It blocks the renderer and causes dropped frames. I'd like to move it to another thread or at least make it concurrent. There's also likely a lot of room for improvement in overall parsing speed.

Add Contributor Guide

We should add a guide for new contributors that explains our style guide, development setup, testing, and PR submission process.

Integration Tests Not Working

The integration tests are not running properly. I am on version 2017.1.0f3 of Unity. The error I get is:

NullReferenceException: Object reference not set to an instance of an object
UnityTest.GuiHelper.GetConsoleErrorPause () (at Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/GuiHelper.cs:13)
UnityTest.IntegrationTestsRunnerWindow+RunnerCallback..ctor (UnityTest.IntegrationTestsRunnerWindow window) (at Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs:499)
UnityTest.IntegrationTestsRunnerWindow.Update () (at Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs:229)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:305)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:313)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:272)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:265)
UnityEditor.HostView.SendUpdate () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:341)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:109)

Split GLTF folder into submodule

It would be much easier to include this in your project and keep it up to date if there were a separate repository for the package itself as well as this repo for the project, tests, etc.

Interpretation of bytestride parameters

I believe there may be a mistake in how bytestride is interpreted inside Accessors. The reference:

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#floating-point-data

implies (it doesn't appear to be explicit) that the bytestride is the total stride between values, not the unused bytes.

In Accesor.cs:

https://github.com/AltspaceVR/UnityGLTF/blob/master/Assets/GLTF/Scripts/Schema/Accessor.cs

It appears that if ByteStride is set, then it is added onto a calculation of the component width. (E.G. line 312).

Most densely packed objects don't set byteStride, but collada2gltf does, see attached object. In this case the bytestride is only indicating that the data is tightly packed.

test2.zip

Anthony

Publish to Unity Asset Store

I'd like to make this package as easy as possible for people to include in their projects. I'll publish it for free as soon as it's ready.

Accessor Flips Z Components in GLTFSerialization

The accessor currently flips z component when parsing it out of the binary data. This is needed for Unity due to differing coordinate space. This should be done in the UnityGLTF layer and not GLTFSerialization layer.

Runtime texture color space settings

glTF's PBR material definition specifies the color spaces that its various textures should be in: sRGB for baseColor, linear for metallicTexture, etc. However, Unity's DownloadHandlerTexture class used by UnityWebRequest always assumes the texture is sRGB, and does not provide an option to specify. So an alternative loader/handler will probably need to be created to properly import these textures.

^ @tparisi

How to export skin animation to gltf model?

Sorry, My English is so bad.

I drag the "dude.fbx " that it is a  model with the mesh skin animation in unity and export it.  the tools can't export the skin animation to gltf model.

Please help me. thanks!

Fix Animation Channel Parsing

The AnimatedCube integration test currently fails with the following exception:

Exception: Animation channel must be an object.
GLTF.GLTFAnimationChannel.Deserialize (GLTF.GLTFRoot root, Newtonsoft.Json.JsonTextReader reader) (at Assets/GLTF/Scripts/Schema/GLTFAnimationChannel.cs:28)
GLTF.GLTFAnimation+<Deserialize>c__AnonStoreyA.<>m__3 () (at Assets/GLTF/Scripts/Schema/GLTFAnimation.cs:36)
GLTF.JsonExtensions.JsonTextReaderExtensions.ReadList[GLTFAnimationChannel] (Newtonsoft.Json.JsonTextReader reader, System.Func`1 deserializerFunc) (at Assets/GLTF/Scripts/GLTFJsonExtensions.cs:55)
GLTF.GLTFAnimation.Deserialize (GLTF.GLTFRoot root, Newtonsoft.Json.JsonTextReader reader) (at Assets/GLTF/Scripts/Schema/GLTFAnimation.cs:36)
GLTF.GLTFRoot+<Deserialize>c__AnonStoreyE.<>m__B () (at Assets/GLTF/Scripts/Schema/GLTFRoot.cs:143)
GLTF.JsonExtensions.JsonTextReaderExtensions.ReadList[GLTFAnimation] (Newtonsoft.Json.JsonTextReader reader, System.Func`1 deserializerFunc) (at Assets/GLTF/Scripts/GLTFJsonExtensions.cs:55)
GLTF.GLTFRoot.Deserialize (Newtonsoft.Json.JsonTextReader reader) (at Assets/GLTF/Scripts/Schema/GLTFRoot.cs:143)
GLTF.GLTFParser.ParseString (System.String gltfContent) (at Assets/GLTF/Scripts/GLTFParser.cs:81)
GLTF.GLTFParser.ParseBinary (System.Byte[] gltfBinary, System.Byte[]& glbBuffer) (at Assets/GLTF/Scripts/GLTFParser.cs:75)
GLTF.GLTFLoader.ParseGLTF (System.Byte[] gltfData) (at Assets/GLTF/Scripts/GLTFLoader.cs:95)
GLTF.GLTFLoader+<Load>c__Iterator3.<>m__1 () (at Assets/GLTF/Scripts/GLTFLoader.cs:49)
GLTF.AsyncAction+<RunOnWorkerThread>c__Iterator0.<>m__0 (System.Object _) (at Assets/GLTF/Scripts/AsyncAction.cs:20)

Provide UnityWebRequest Headers options and Post method

Hello there,

First of all, thanks so much for this loader, it is a great contribution!

Can you provide a HTTP headers dictionary as argumento to the Loader object?

I need to provide authentication token to the Web Server:

`

var www = UnityWebRequest.Get(_gltfUrl);

 foreach(KeyValuePair<string, string> entry in headersDictionary)
 {
    www.SetRequestHeader(entry.Key,entry.Value);
 }

`

Also, can be there an option to use Post instead of Get?

var www = UnityWebRequest.Post(_gltfUrl, postData);

Thanks in advanced!

Problem loading examples Scenes: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

All works in Unity 2017.01f3 for Windows 10 x64.

Unity Version:
Unity 2017.01f3

Operating System:
OSX ElCapitan
10.11.6

Commit repo used:
06c9988

Unity Error:
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex
System.BitConverter.PutBytes (System.Byte* dst, System.Byte[] src, Int32 start_index, Int32 count) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/BitConverter.cs:176)
System.BitConverter.ToUInt32 (System.Byte[] value, Int32 startIndex) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/BitConverter.cs:257)
GLTF.GLTFParser.ParseBinary (System.Byte[] gltfBinary, System.Byte[]& glbBuffer) (at Assets/GLTF/Scripts/GLTFParser.cs:24)
GLTF.GLTFLoader.ParseGLTF (System.Byte[] gltfData) (at Assets/GLTF/Scripts/GLTFLoader.cs:132)
GLTF.GLTFLoader+c__Iterator0+c__AnonStorey3.<>m__0 () (at Assets/GLTF/Scripts/GLTFLoader.cs:71)
GLTF.AsyncAction+c__Iterator0+c__AnonStorey2.<>m__0 (System.Object _) (at Assets/GLTF/Scripts/AsyncAction.cs:20)

Add Code of Conduct

We should add a code of conduct to foster a positive and constructive community.

Update README

We should update the README with the project goals, 1.0 projected release schedule, and 1.0 goals.

Tangent vector problem

Hi,

I'm one of developers of glTF pipeline for CAD / Unity integration. I've used UnityGLTF project as a reference code for our Unity importer which generates meshes, materials, prefabs etc during glTF import. I found one problematic place in your code / math.

The problem is that your tangent vector looks incorrect. Code first (part of Accessor.cs):

	public Vector3[] AsVertexArray(ref NumericArray contents, byte[] bufferData)
	{
		if (contents.AsVertices != null) return contents.AsVertices;

		var arr = AsVector3Array(ref contents, bufferData);
		for (var i = 0; i < arr.Length; i++)
		{
			arr[i].Z *= -1;
		}
	...
	public Vector3[] AsNormalArray(ref NumericArray contents, byte[] bufferData)
	{
		if (contents.AsNormals != null) return contents.AsNormals;

		var arr = AsVector3Array(ref contents, bufferData);
		for (var i = 0; i < arr.Length; i++)
		{
			arr[i].Z *= -1;
		}
	...
	public Vector4[] AsTangentArray(ref NumericArray contents, byte[] bufferData)
	{
		if (contents.AsTangents != null) return contents.AsTangents;

		var arr = AsVector4Array(ref contents, bufferData);
		for (var i = 0; i < arr.Length; i++)
		{
			arr[i].W *= -1;
		}
	...

Here you may see that you're flipping Z coordinate for position and normal vectors, but not for tangent. If tangent vector is supposed to be orthogonal to normal, this orthogonality will be lost after this math. Inverting tangent's W flips handedness of the coordinate system - inverts binormal vector, but does nothing with tangent (vec3) itself. I think this is wrong.

I used special script which visualizes normal and tangent vectors (I can provide one for debugging purposes, but it works only in editor, not at runtime). I've played with all models from Kronos's glTF samples repository - with those who have tangents. Tangent vectors are good with some meshes, and bad with others. In fact, only models which has

"generator": "glTF Tools for Unity"

are "good" after importing with your math, other models are bad. I.e. "good" are models generated with your code.

I've reviewed glTF specification for tangent space and didn't find any reference that tangent's Z should be negated, i.e. glTF uses "classic" orthogonal tangent space. Could you please review your code for possible problems?

Thanks,
Konstantin

Error when playing a scene that tried to load a binary

Works fine for non-binary glTF, however all of the binary scenes print this error:

ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
System.Buffer.BlockCopy (System.Array src, Int32 srcOffset, System.Array dst, Int32 dstOffset, Int32 count) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Buffer.cs:112)
GLTF.GLTFLoader+<LoadImage>c__Iterator4.MoveNext () (at Assets/GLTF/Scripts/GLTFLoader.cs:574)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

Am I doing something wrong?

Putting 'extras' property into a JSON block early-exits parsing

The call to JToken.ReadFrom leaves the Value of the reader pointing to the next property, rather than an endObject - so when the caller attempts the next loop iteration (such as in Asset.cs::Deserialize) it will skip the next property and leave the reader in a weird state, thus skipping reading the rest of the glTF file.

Sample file:

{
	"asset": {
		"generator": "Unity 5.6",
		"extras": {
			"exporterVersion" : "2.1.1"
		},
		"version": "2.0"
	}
}

The version property will never be read.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.