-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update layout definition system * Fix log window size * Update auto generated layout system * Fix log window size in exporter form * Export Babylon attributes for standard material (backfaceCulling, maxSimultaneousLights, unlit) Add connection to log prints * Add default babylon attributes automatically at runtime Add KHR_materials_unlit checkbox * Fix Transparency mode when exporting a standard material to glTF Fix base color and metallic roughness textures names when exporting a standard material to glTF * Add a babylon material node to hold all attributes Fix diffuse and alpha textures merging when alpha is read from RGB * Ignore babylon transparency mode value when exporting Add Node editor (NE) templates Update Attribute editor (AE) templates * Export _unlit attribute for PBRMetallicRoughnessMaterial Export alphaCutOff attribute for Masked StingrayPBS material only Export merged color texture for Masked StingrayPBS material Fix default color initialisation when merging textures * Add sample files * Move log feature to dedicated internal class Add log level * Fix transparencyMode and alpha for Standard and Arnold materials * Add babylon material attributes to native materials Export babylon material attributes * Get arnold material opacity from dedicated attributes * Add samples for babylon material attributes attached to native materials * Set an unique ID for babylon attributes of an Arnold material * //Add the user custom attributes to metadata * // add custom user attributes in babylon and gltf for the lights, cameras, mesh and materials * Export custom attributes from nodes and materials * Do not export null CustomAttributes * Add samples for custom attributes * Export custom attributes for instances * Add support for DoubleSided material * Fix custom attributes retreivable * Add alphaCutoff default value for masked materials Fix diffuse texture bitmap loading in gltf for a standard masked material Do not export empty metadata array for materials * //add samples * Add sample files for DoubleSided material Fix nb of vertices for back face vertices * Add alphaCutoff default value for masked materials Fix nullable metadata cloning * Update samples for MASK transparency mode * Format file * Add automatically babylon attributes to a material when created * Export custom attributes as extras for lights in glTF Update sample files and rename objects * //Add the double sided export in maya //secured the retrieval of the babylon materials * Export lights as metadata * Update samples * //Fix empty extras * Clean up * //Upload and refresh of all the exemples * Fix opacity color and texture retreival from Arnold material Fix Standard material conversion when Owner is null Add safety checks * Update node and material names in samples * //Add the parameters to the babylonNode shaderGraph when add manually * Installer : Add AETemplates and NETemplates for Maya installation * Update Installer version to 1.3.0
- Loading branch information
Showing
210 changed files
with
25,291 additions
and
3,600 deletions.
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
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
173 changes: 173 additions & 0 deletions
173
3ds Max/Max2Babylon/Exporter/BabylonExporter.CustomAttributes.cs
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,173 @@ | ||
using Autodesk.Max; | ||
using BabylonExport.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Max2Babylon | ||
{ | ||
partial class BabylonExporter | ||
{ | ||
/// <summary> | ||
/// Return the custom attributes of a material | ||
/// </summary> | ||
/// <param name="materialNode"></param> | ||
/// <param name="babylonScene"></param> | ||
/// <param name="excludeAttributes">Attribute names to not export</param> | ||
public Dictionary<string, object> ExportExtraAttributes(IIGameMaterial gameMaterial, BabylonScene babylonScene, List<string> excludeAttributes = null) | ||
{ | ||
// Retreive the max object | ||
ManagedServices.MaxscriptSDK.ExecuteMaxscriptCommand("obj = sceneMaterials[\"" + gameMaterial.MaterialName + "\"];"); | ||
|
||
return _ExportExtraAttributes(gameMaterial.IPropertyContainer, babylonScene, excludeAttributes); | ||
} | ||
|
||
/// <summary> | ||
/// Return the custom attributes of a material | ||
/// </summary> | ||
/// <param name="materialNode"></param> | ||
/// <param name="babylonScene"></param> | ||
/// <param name="excludeAttributes">Attribute names to not export</param> | ||
public Dictionary<string, object> ExportExtraAttributes(IIGameNode gameNode, BabylonScene babylonScene, List<string> excludeAttributes = null) | ||
{ | ||
// Retreive the max object | ||
ManagedServices.MaxscriptSDK.ExecuteMaxscriptCommand("obj = execute(\"$'" + gameNode.Name + "'\");"); | ||
|
||
return _ExportExtraAttributes(gameNode.IGameObject.IPropertyContainer, babylonScene, excludeAttributes); | ||
} | ||
|
||
/// <summary> | ||
/// Return custom attributes retreive from a max object named "obj" | ||
/// </summary> | ||
/// <param name="metadata"></param> | ||
/// <param name="propertyContainer"></param> | ||
/// <param name="babylonScene"></param> | ||
/// <param name="excludeAttributes">Attribute names to not export</param> | ||
private Dictionary<string, object> _ExportExtraAttributes(IIPropertyContainer propertyContainer, BabylonScene babylonScene, List<string> excludeAttributes = null) | ||
{ | ||
RaiseMessage("ExportExtraAttributes", 2); | ||
|
||
// Return a string encoded with 2 separators | ||
// Parameter separator: _$€PParam_ | ||
// Name/Type separator: _$€PType_ | ||
string cmd = "s = \"\"" | ||
+ "\r\n" + "for objDef in (custAttributes.getDefs obj) do" | ||
+ "\r\n" + "(" | ||
+ "\r\n" + "pbArray = custAttributes.getPBlockDefs objdef" | ||
+ "\r\n" + "for indexPBlock = 1 to pbArray.count do" | ||
+ "\r\n" + "(" | ||
+ "\r\n" + "itms = pbArray[indexPBlock]" | ||
+ "\r\n" + "for y = 5 to itms.Count do" | ||
+ "\r\n" + "(" | ||
+ "\r\n" + "s = s + \"_$€PParam_\" + itms[y][1]" | ||
+ "\r\n" + "for z = 1 to itms[y][2].Count by 2 do" | ||
+ "\r\n" + "(" | ||
+ "\r\n" + "key = itms[y][2][z] as string" | ||
+ "\r\n" + "if (findString key \"type\") != undefined then" | ||
+ "\r\n" + "(" | ||
+ "\r\n" + "s = s + \"_$€PType_\" + itms[y][2][z+1]" | ||
+ "\r\n" + ")" | ||
+ "\r\n" + ")" | ||
+ "\r\n" + ")" | ||
+ "\r\n" + ")" | ||
+ "\r\n" + ")" | ||
+ "\r\n" + "s"; | ||
string result = ManagedServices.MaxscriptSDK.ExecuteStringMaxscriptQuery(cmd); | ||
|
||
if (result == null || result == "") | ||
{ | ||
return null; | ||
} | ||
|
||
// Parse the result into a dictionary | ||
string[] parameters = result.Split(new string[] { "_$€PParam_" }, StringSplitOptions.RemoveEmptyEntries); | ||
Dictionary<string, string> customAttributesTypeByName = new Dictionary<string, string>(); | ||
foreach (string parameter in parameters) | ||
{ | ||
string[] customAttribute = parameter.Split(new string[] { "_$€PType_" }, StringSplitOptions.RemoveEmptyEntries); | ||
string key = customAttribute[0]; | ||
if (customAttributesTypeByName.ContainsKey(key) == false) | ||
{ | ||
customAttributesTypeByName.Add(key, customAttribute[1]); | ||
} | ||
} | ||
|
||
// Remove preset custom attributes | ||
customAttributesTypeByName.Remove("presetName_str"); | ||
customAttributesTypeByName.Remove("preset_str"); | ||
customAttributesTypeByName.Remove("rampOn"); | ||
|
||
// Remove specified attributes | ||
if (excludeAttributes != null) | ||
{ | ||
foreach (string excludeAttribute in excludeAttributes) | ||
{ | ||
customAttributesTypeByName.Remove(excludeAttribute); | ||
} | ||
} | ||
|
||
// Handle each attribute type | ||
Dictionary<string, object> metadata = new Dictionary<string, object>(); | ||
foreach (KeyValuePair<string, string> entry in customAttributesTypeByName) | ||
{ | ||
object obj = null; | ||
|
||
RaiseMessage(entry.Key + "=" + entry.Value, 2); | ||
|
||
switch (entry.Value.ToLowerInvariant()) | ||
{ | ||
case "float": | ||
case "angle": // in rad units | ||
case "worldunits": | ||
obj = propertyContainer.GetFloatProperty(entry.Key); | ||
break; | ||
case "percent": // in base 1 (80% => 0.8) | ||
obj = propertyContainer.GetFloatProperty(entry.Key) / 100f; | ||
break; | ||
case "boolean": | ||
obj = propertyContainer.GetBoolProperty(entry.Key); | ||
break; | ||
case "integer": | ||
case "array": // selected enum value expressed as int starting from 1 | ||
obj = propertyContainer.GetIntProperty(entry.Key); | ||
break; | ||
case "string": | ||
obj = propertyContainer.GetStringProperty(entry.Key); | ||
break; | ||
case "color": // Color RGB in base 1 (not 255) | ||
obj = propertyContainer.GetPoint3Property(entry.Key).ToArray(); | ||
break; | ||
case "frgba": // Color RGBA in base 1 (not 255) | ||
obj = propertyContainer.GetPoint4Property(entry.Key).ToArray(); | ||
break; | ||
case "texturemap": | ||
IIGameProperty gameProperty = propertyContainer.QueryProperty(entry.Key); | ||
ITexmap texmap = gameProperty.MaxParamBlock2.GetTexmap(gameProperty.ParamID, 0, 0); | ||
obj = ExportTexture(texmap, babylonScene); | ||
break; | ||
case "node": | ||
// Currently not exported | ||
break; | ||
case "material": | ||
// Currently not exported | ||
break; | ||
default: | ||
RaiseWarning("Unknown type '" + entry.Value + "' for custom attribute named '" + entry.Key + "'", 2); | ||
break; | ||
} | ||
|
||
if (obj != null) | ||
{ | ||
metadata.Add(entry.Key, obj); | ||
} | ||
} | ||
|
||
// Print all extra attributes | ||
foreach (KeyValuePair<string, object> entry in metadata) | ||
{ | ||
RaiseVerbose(entry.Key + "=" + entry.Value, 2); | ||
} | ||
|
||
return metadata; | ||
} | ||
} | ||
} |
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.