@@ -69,7 +69,8 @@ internal partial class BabylonExporter
6969 public void Export ( string outputDirectory , string outputFileName , string outputFormat , bool generateManifest ,
7070 bool onlySelected , bool autoSaveMayaFile , bool exportHiddenObjects , bool copyTexturesToOutput ,
7171 bool optimizeVertices , bool exportTangents , string scaleFactor , bool exportSkin , string quality , bool dracoCompression ,
72- bool exportMorphNormal , bool exportMorphTangent , bool exportKHRLightsPunctual , bool exportKHRTextureTransform , bool bakeAnimationFrames )
72+ bool exportMorphNormal , bool exportMorphTangent , bool exportKHRLightsPunctual , bool exportKHRTextureTransform , bool bakeAnimationFrames ,
73+ bool fullPBR , bool noAutoLight , bool defaultSkybox , string environmentName )
7374 {
7475 // Check if the animation is running
7576 MGlobal . executeCommand ( "play -q - state" , out int isPlayed ) ;
@@ -350,7 +351,7 @@ public void Export(string outputDirectory, string outputFileName, string outputF
350351 }
351352
352353 // Default light
353- if ( babylonScene . LightsList . Count == 0 )
354+ if ( ! noAutoLight && babylonScene . LightsList . Count == 0 )
354355 {
355356 RaiseWarning ( "No light defined" , 1 ) ;
356357 RaiseWarning ( "A default ambient light was added for your convenience" , 1 ) ;
@@ -404,12 +405,12 @@ public void Export(string outputDirectory, string outputFileName, string outputF
404405 GenerateMaterialDuplicationDatas ( babylonScene ) ;
405406 foreach ( var mat in referencedMaterials )
406407 {
407- ExportMaterial ( mat , babylonScene ) ;
408+ ExportMaterial ( mat , babylonScene , fullPBR ) ;
408409 CheckCancelled ( ) ;
409410 }
410411 foreach ( var mat in multiMaterials )
411412 {
412- ExportMultiMaterial ( mat . Key , mat . Value , babylonScene ) ;
413+ ExportMultiMaterial ( mat . Key , mat . Value , babylonScene , fullPBR ) ;
413414 CheckCancelled ( ) ;
414415 }
415416 UpdateMeshesMaterialId ( babylonScene ) ;
@@ -462,9 +463,44 @@ public void Export(string outputDirectory, string outputFileName, string outputF
462463 }
463464 }
464465
465-
466466 // Output
467467 babylonScene . Prepare ( false , false ) ;
468+
469+ var sourcePath = environmentName ;
470+ if ( ! string . IsNullOrEmpty ( sourcePath ) )
471+ {
472+ babylonScene . createDefaultSkybox = defaultSkybox ;
473+ var fileName = Path . GetFileName ( sourcePath ) ;
474+
475+ // Allow only dds file format
476+ if ( ! fileName . EndsWith ( ".dds" ) )
477+ {
478+ RaiseWarning ( "Failed to export defauenvironment texture: only .dds format is supported." ) ;
479+ }
480+ else
481+ {
482+ RaiseMessage ( $ "texture id = Max_Babylon_Default_Environment") ;
483+ babylonScene . environmentTexture = fileName ;
484+
485+ if ( copyTexturesToOutput )
486+ {
487+ try
488+ {
489+ var destPath = Path . Combine ( babylonScene . OutputPath , fileName ) ;
490+ if ( File . Exists ( sourcePath ) && sourcePath != destPath )
491+ {
492+ File . Copy ( sourcePath , destPath , true ) ;
493+ }
494+ }
495+ catch
496+ {
497+ // silently fails
498+ RaiseMessage ( $ "Fail to export the default env texture", 3 ) ;
499+ }
500+ }
501+ }
502+ }
503+
468504 if ( isBabylonExported )
469505 {
470506 Write ( babylonScene , outputBabylonDirectory , outputFileName , outputFormat , generateManifest ) ;
0 commit comments