-
Notifications
You must be signed in to change notification settings - Fork 22
Fix missing textures #113
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
Merged
Merged
Fix missing textures #113
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9fcecd2
Added Wood as standard materials
vnoves 4a5fb9d
Added Tint Functionality
vnoves 3c041fc
Clean Materials Variables
vnoves 4ba1cd5
Fixed UVs
vnoves 54b6910
Remove Unnecessary calling
vnoves e8aa349
Fix Debug Post Build
vnoves 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using Autodesk.Revit.DB; | ||
| using Autodesk.Revit.DB.Visual; | ||
| using Common_glTF_Exporter.Core; | ||
| using Common_glTF_Exporter.Windows.MainWindow; | ||
| using Revit_glTF_Exporter; | ||
| using Common_glTF_Exporter.Materials; | ||
| using Common_glTF_Exporter.Model; | ||
| using System.IO.Ports; | ||
| using System.Windows.Controls; | ||
| using System.Windows.Media.Media3D; | ||
| using Material = Autodesk.Revit.DB.Material; | ||
| using System; | ||
|
|
||
| namespace Common_glTF_Exporter.Materials | ||
| { | ||
| public static class MaterialTextures | ||
| { | ||
| public static GLTFMaterial SetMaterialTextures(Material material, GLTFMaterial gl_mat, | ||
| Document doc, float opacity) | ||
| { | ||
|
|
||
| ElementId appearanceId = material.AppearanceAssetId; | ||
| if (appearanceId == ElementId.InvalidElementId) | ||
| { | ||
| return gl_mat; | ||
| } | ||
|
|
||
| var appearanceElem = doc.GetElement(appearanceId) as AppearanceAssetElement; | ||
| if (appearanceElem == null) | ||
| { | ||
| return gl_mat; | ||
| } | ||
|
|
||
| Asset theAsset = appearanceElem.GetRenderingAsset(); | ||
|
|
||
| Asset connectedAsset = AssetPropertiesUtils.GetDiffuseBitmap(theAsset); | ||
| string texturePath = AssetPropertiesUtils.GetTexturePath(connectedAsset); | ||
|
|
||
|
|
||
| if (!string.IsNullOrEmpty(texturePath) && File.Exists(texturePath)) | ||
| { | ||
| SetTextureProperties(gl_mat, texturePath, connectedAsset, theAsset, opacity); | ||
| } | ||
|
|
||
| return gl_mat; | ||
| } | ||
|
|
||
| private static void SetTextureProperties(GLTFMaterial gl_mat, string texturePath, Asset connectedAsset, | ||
| Asset theAsset, float opacity) | ||
| { | ||
| gl_mat.EmbeddedTexturePath = texturePath; | ||
|
|
||
| float scaleX = AssetPropertiesUtils.GetScale(connectedAsset, UnifiedBitmap.TextureRealWorldScaleX); | ||
| float scaleY = AssetPropertiesUtils.GetScale(connectedAsset, UnifiedBitmap.TextureRealWorldScaleY); | ||
| float rotation = AssetPropertiesUtils.GetRotationRadians(connectedAsset); | ||
| gl_mat.Fadevalue = AssetPropertiesUtils.GetFade(theAsset); | ||
| gl_mat.TintColour = AssetPropertiesUtils.GetTint(theAsset); | ||
| gl_mat.BaseColor = AssetPropertiesUtils.GetAppearenceColor(theAsset); | ||
|
|
||
| gl_mat.pbrMetallicRoughness.baseColorFactor = new List<float>(4) | ||
| { | ||
| 1, | ||
| 1, | ||
| 1, | ||
| opacity | ||
| }; | ||
|
|
||
| gl_mat.pbrMetallicRoughness.baseColorTexture = new GLTFTextureInfo | ||
| { | ||
| index = -1, | ||
| extensions = new GLTFTextureExtensions | ||
| { | ||
| TextureTransform = new GLTFTextureTransform | ||
| { | ||
| scale = new float[] { 1f / scaleX, 1f / scaleY }, | ||
| rotation = rotation | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.