vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
470 stars 75 forks source link

Can't compile example due to Monogame constructor reference #33

Closed YTN0 closed 4 years ago

YTN0 commented 4 years ago

I am trying to get the example to work, however am running into an issue in SharpGLTF.Runtime.MonoGame.LoaderContext

Specifically, line 68 generates a compile error:

        var dstMesh = new ModelMesh(_Device, Enumerable.Range(0, srcPrims.Count).Select(item => new ModelMeshPart()).ToList())

The compiler complains that there is no empty contructor for ModelMeshPart(). It looks like the constructor is declared as internal.

Note, this is using the 3.7.8 dev build of Monogame.

vpenades commented 4 years ago

Hmm... indeed, since 3.7.8 that constructor has been made internal.

I'll check if I can find a workaround; maybe it's possible to create the instances via reflection with System.Activator.

The issue with the internal constructor is being followed here: https://github.com/MonoGame/MonoGame/pull/6620

vpenades commented 4 years ago

@YTN0 I've fixed the issue in this other repo:

https://github.com/vpenades/SharpGLTF.Monogame.Example

It no longer needs ModelMesh and ModelMeshPart, so it should not cause any compiling issues. In a while I'll reflect these changes in this repo too.