-
-
Notifications
You must be signed in to change notification settings - Fork 944
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
Gltf Importer #1030
Closed
Closed
Gltf Importer #1030
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
bf458c9
Re added gltf importer
ykafia 0a94004
Merge pull request #1 from stride3d/master
ykafia bd99662
Merge pull request #2 from stride3d/master
ykafia 0ed55b5
file corrections
ykafia 97c4899
bump SharpGltf version
ykafia f8ddb09
Merge pull request #3 from ykafia/master
ykafia 01fa0d9
first MVP import gltf model + skeleton
ykafia 468c5b3
Finished importing all types of materials
ykafia d46164d
Mesh + Animation constraints
ykafia 9fe612c
Some changes
ykafia 5c9cc9d
Little Hack to import multiple animations
ykafia 67aa25b
Correct animation naming
ykafia edb18be
Merge pull request #4 from stride3d/master
ykafia 7a6069b
Animation asset name changes
ykafia d0825a0
Fixed glb texture import issue
ykafia 81f9fef
Corrected bone null name + animation name
ykafia 02df563
removed unused line of code
ykafia e0d98f8
Corrected name of mesh for animations
ykafia e7342f0
Doc comments
ykafia bf7c38c
static classes
ykafia 42ffc24
Correct naming of texture
ykafia f1f6843
Merge branch 'stride3d:master' into master
ykafia 516d12e
Corrected breaking change on FBX animation importer
ykafia c0a91fe
bump versions + simpler vertex buff creation + minor corrections
ykafia b9c587a
Corrections + cubic animation import
ykafia 6317fe6
Merge pull request #6 from stride3d/master
ykafia b2b75cd
Merge pull request #7 from stride3d/master
ykafia 1dd0212
Merge pull request #8 from ykafia/master
ykafia 6dcfc29
Added 8byte vertex color
ykafia f8a1b26
Merge branch 'gltfimport' of https://github.com/ykafia/stride into gl…
ykafia fc64315
Merge all meshes
ykafia 7f54126
Fusing animations and meshes
ykafia 005d765
ignore configs
ykafia 7fe1a50
Merge branch 'stride3d:master' into gltfimport
ykafia f0d9a22
Correction root animation import
ykafia 6770a72
Removed EntityInfoExtended
ykafia 8ee77d4
Merge branch 'stride3d:master' into master
ykafia 7d722e9
Merge pull request #11 from ykafia/master
ykafia 6e6db93
Removed project from sln
ykafia ddbc547
update reference GLTF
ykafia 6a3482f
Minor changes
ykafia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,5 @@ fastlane/report.xml | |
fastlane/screenshots | ||
*.user | ||
project.lock.json | ||
/hooks | ||
/lfs/objects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) | ||
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. | ||
using System; | ||
using System.Collections.Generic; | ||
using Stride.Core.Assets; | ||
using Stride.Core; | ||
using Stride.Core.Diagnostics; | ||
using Stride.Core.IO; | ||
using Stride.Animations; | ||
using Stride.Assets.Textures; | ||
using Stride.Importer.Common; | ||
using Stride.Importer.Gltf; | ||
using System.Linq; | ||
|
||
namespace Stride.Assets.Models | ||
{ | ||
public class GltfAssetImporter : ModelAssetImporter | ||
{ | ||
|
||
// Supported file extensions for this importer | ||
internal const string FileExtensions = ".gltf;.glb;"; | ||
|
||
private static readonly Guid Uid = new Guid("A5A08530-4856-4EB7-91F8-B0A148B3A627"); | ||
|
||
public override Guid Id => Uid; | ||
|
||
public override string Description => "Gltf importer used for creating entities, 3D Models or animations assets"; | ||
|
||
public override string SupportedFileExtensions => FileExtensions; | ||
|
||
/// <inheritdoc/> | ||
public override EntityInfo GetEntityInfo(UFile localPath, Logger logger, AssetImporterParameters importParameters) | ||
{ | ||
|
||
return GltfMeshParser.ExtractEntityInfo(SharpGLTF.Schema2.ModelRoot.Load(localPath.FullPath), localPath); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override void GetAnimationDuration(UFile localPath, Logger logger, AssetImporterParameters importParameters, out TimeSpan startTime, out TimeSpan endTime) | ||
{ | ||
var gltfFile = SharpGLTF.Schema2.ModelRoot.Load(localPath); | ||
endTime = GltfMeshParser.GetAnimationDuration(gltfFile); | ||
startTime = CompressedTimeSpan.Zero; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) | ||
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Linq; | ||
using Stride.Core.BuildEngine; | ||
using Stride.Core.Serialization.Contents; | ||
using Stride.Animations; | ||
using Stride.Rendering; | ||
using Stride.Importer.Gltf; | ||
|
||
namespace Stride.Assets.Models | ||
{ | ||
[Description("Import GLTF")] | ||
public class ImportGltfCommand : ImportModelCommand | ||
{ | ||
private static string[] supportedExtensions = GltfAssetImporter.FileExtensions.Split(';'); | ||
|
||
/// <inheritdoc/> | ||
public override string Title { get { string title = "Import GLTF "; try { title += Path.GetFileName(SourcePath) ?? "[File]"; } catch { title += "[INVALID PATH]"; } return title; } } | ||
|
||
public static bool IsSupportingExtensions(string ext) | ||
{ | ||
if (string.IsNullOrEmpty(ext)) | ||
return false; | ||
|
||
var extToLower = ext.ToLowerInvariant(); | ||
|
||
return supportedExtensions.Any(supExt => supExt.Equals(extToLower)); | ||
} | ||
|
||
protected override Model LoadModel(ICommandContext commandContext, ContentManager contentManager) | ||
{ | ||
var model = GltfMeshParser.LoadGltf(SourcePath); | ||
var sceneData = GltfMeshParser.LoadFirstModel(model); | ||
return sceneData; | ||
} | ||
|
||
protected override Dictionary<string, AnimationClip> LoadAnimation(ICommandContext commandContext, ContentManager contentManager, out TimeSpan duration) | ||
{ | ||
var file = SharpGLTF.Schema2.ModelRoot.Load(SourcePath); | ||
var sceneData = GltfMeshParser.ConvertAnimations(file,SourcePath.GetFileNameWithoutExtension()); | ||
duration = GltfMeshParser.GetAnimationDuration(file); | ||
return sceneData; | ||
} | ||
|
||
protected override Skeleton LoadSkeleton(ICommandContext commandContext, ContentManager contentManager) | ||
{ | ||
var file = SharpGLTF.Schema2.ModelRoot.Load(SourcePath); | ||
var sceneData = GltfAnimationParser.ConvertSkeleton(file); | ||
return sceneData; | ||
} | ||
|
||
public override bool ShouldSpawnNewProcess() | ||
{ | ||
return true; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return "Import GLTF " + base.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duration isn't used anywhere...