Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Model] Unable to import GLTF json and GLB binary 3d Model assets #603

Open
acampbellb opened this issue Feb 13, 2020 · 6 comments
Open
Labels
area-Asset area-Graphics bug Something isn't working

Comments

@acampbellb
Copy link

acampbellb commented Feb 13, 2020

Release Type: Official Release/GitHub

Version: 3.2

Platform(s): Windows

Describe the bug
Unable to create a 3D Model asset from a GLTF file (GLTF json form or GLB binary form). The models load without a problem in GLTF viewers, Xenko's Assimp library seems to be the problem. An eaten exception seems to be occurring somewhere w/ in the call to ExtractEntity (see below).
Model attached, you can use this viewer to confirm model as valid https://gltf-viewer.donmccurdy.com/

gltf_model.zip

** Exception **

Index was outside the bounds of the array.

at Xenko.AssimpNet.NetTranslation.Materials.convertAssimpStackCppToCs(aiMaterial* material, aiTextureType type) in C:\xenko\xenko\sources\tools\Xenko.Assimp.Translation\Materials.cpp:line 161

Callstack

Xenko.GameStudio.exe!Xenko.GameStudio.DataBindingExceptionRethrower.FirstChanceExceptionThrown(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e) Line 84
at C:\xenko\xenko\sources\editor\Xenko.GameStudio\DataBindingExceptionRethrower.cs(84)
[External Code]
Xenko.Assimp.Translation.dll!Xenko::AssimpNet::NetTranslation::Materials::convertAssimpStackCppToCs(aiMaterial* material, aiTextureType type) Line 161
at C:\xenko\xenko\sources\tools\Xenko.Assimp.Translation\Materials.cpp(161)
Xenko.Importer.Assimp.dll!Xenko::Importer::AssimpNET::MeshConverter::GenerateOneTextureTypeLayers(aiMaterial* pMat, aiTextureType textureType, int& textureCount, Xenko::Assets::Materials::MaterialAsset^ finalMaterial) Line 741
at C:\xenko\xenko\sources\tools\Xenko.Importer.Assimp\Xenko.Importer.Assimp.cpp(741)
Xenko.Importer.Assimp.dll!Xenko::Importer::AssimpNET::MeshConverter::BuildLayeredSurface(aiMaterial* pMat, bool hasBaseColor, bool hasBaseValue, Xenko::Core::Mathematics::Color4 baseColor, float baseValue, aiTextureType textureType, Xenko::Assets::Materials::MaterialAsset^ finalMaterial) Line 897
at C:\xenko\xenko\sources\tools\Xenko.Importer.Assimp\Xenko.Importer.Assimp.cpp(897)
Xenko.Importer.Assimp.dll!Xenko::Importer::AssimpNET::MeshConverter::ProcessMeshMaterial(aiMaterial* pMaterial) Line 1085
at C:\xenko\xenko\sources\tools\Xenko.Importer.Assimp\Xenko.Importer.Assimp.cpp(1085)
Xenko.Importer.Assimp.dll!Xenko::Importer::AssimpNET::MeshConverter::ExtractMaterials(aiScene* scene, std::map<aiMaterial *,std::basic_string<char,std::char_traits,std::allocator >,std::less<aiMaterial *>,std::allocator<std::pair<aiMaterial * const,std::basic_string<char,std::char_traits,std::allocator > > > >& materialNames) Line 1305
at C:\xenko\xenko\sources\tools\Xenko.Importer.Assimp\Xenko.Importer.Assimp.cpp(1305)
Xenko.Importer.Assimp.dll!Xenko::Importer::AssimpNET::MeshConverter::ExtractEntity(System::String^ inputFilename, System::String^ outputFilename, bool extractTextureDependencies) Line 1477
at C:\xenko\xenko\sources\tools\Xenko.Importer.Assimp\Xenko.Importer.Assimp.cpp(1477)
Xenko.Assets.Models.dll!Xenko.Assets.Models.AssimpAssetImporter.GetEntityInfo(Xenko.Core.IO.UFile localPath, Xenko.Core.Diagnostics.Logger logger, Xenko.Core.Assets.AssetImporterParameters importParameters) Line 36
at C:\xenko\xenko\sources\engine\Xenko.Assets.Models\AssimpAssetImporter.cs(36)
Xenko.Assets.Models.dll!Xenko.Assets.Models.ModelAssetImporter.Import(Xenko.Core.IO.UFile localPath, Xenko.Core.Assets.AssetImporterParameters importParameters) Line 70
at C:\xenko\xenko\sources\engine\Xenko.Assets.Models\ModelAssetImporter.cs(70)
Xenko.Assets.Presentation.dll!Xenko.Assets.Presentation.Templates.ModelFromFileTemplateGenerator.CreateAssets(Xenko.Core.Assets.Templates.AssetTemplateGeneratorParameters parameters) Line 130
at C:\xenko\xenko\sources\editor\Xenko.Assets.Presentation\Templates\ModelFromFileTemplateGenerator.cs(130)
Xenko.Assets.Presentation.dll!Xenko.Assets.Presentation.Templates.AssetTemplateGenerator.Run(Xenko.Core.Assets.Templates.AssetTemplateGeneratorParameters parameters) Line 32
at C:\xenko\xenko\sources\editor\Xenko.Assets.Presentation\Templates\AssetTemplateGenerator.cs(32)
Xenko.Core.Assets.Editor.dll!Xenko.Core.Assets.Editor.Components.TemplateDescriptions.TemplateGeneratorHelper.RunTemplateGeneratorSafe.AnonymousMethod__0() Line 56
at C:\xenko\xenko\sources\editor\Xenko.Core.Assets.Editor\Components\TemplateDescriptions\TemplateGeneratorHelper.cs(56)
[External Code]

To Reproduce
Steps to reproduce the behavior:

  1. Add 3D Model asset
  2. Select GLB file (GLTF binary form)
  3. Accept default options
  4. Click OK

Expected behavior
3D Model asset is created.

@acampbellb acampbellb added the bug Something isn't working label Feb 13, 2020
@aurodev
Copy link

aurodev commented Feb 16, 2020

Is gltf fully supported yet? see: #96 #458

@tebjan
Copy link
Member

tebjan commented Feb 16, 2020

Xenko supports whatever Assimp 4.1 supports. I think it's missing a few special GLTF format variations, but there are easy to use tools, that convert model formats. so you can just convert it to a format that works.

@acampbellb
Copy link
Author

Doesn't work w/ straight GLTF (JSON), or GLB. Forced to use FBX, argh!

@Eideren Eideren changed the title Unable to import GLTF 3d Model assets [Model] Unable to import GLTF json and GLB binary 3d Model assets Apr 27, 2020
@vpenades
Copy link

Hi, I would humbly propose to use my library, SharpGLTF for glTF model importing.

@tebjan suggested me here to do the Stride integration myself, but I'm full hands with the MonoGame integration, which is the engine I do know, so I cannot do the Stride integration myself. I would be able to answer any technical question you may have.

@ykafia
Copy link
Contributor

ykafia commented Sep 22, 2020

Will work on this issue for now.
Some questions (for Stride's devs):

  • Should Gltf be able to load scenes or just focus on loading models ?
  • What would you think of making Assimp + Fbx optional (if possible) dependencies once Gltf is supported ? One pro would be less cpp dependencies

@vpenades
Copy link

@ykafia regarding loading scenes or models.... there's a reason why glTF supports multiple scenes, and it is resource sharing

I'll give two examples:

1- Imagine you have the scene of a castle, divided in many rooms. A lot of the rooms will reuse many meshes... so you can have a single glTF for the whole castle, and each "scene" is a room. So you can control which room is being rendered, but the meshes will be shared between rooms.

2- Imagine a spaceship model: scene 0 is a brand new ship, scene 1 is the same ship with some hull damage, scene 2 is the same ship completely destroyed. In this case, some spaceship parts can be reused between scenes

In all cases, it's all about saving memory for vertex/index buffers and textures.

@ykafia ykafia mentioned this issue Nov 9, 2020
7 tasks
@ykafia ykafia mentioned this issue Mar 9, 2021
77 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Asset area-Graphics bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants