Show / Hide Table of Contents

    General functions in Max

    Introduction

    The Simplygon Max plug-in exports a number of global MAXScript functions. To run Simplygon from the MAXScript Listener, select the objects you want to process, bring up the MAXScript Listener and run the sgsdk_ProcessSelectedGeometries() function.

    Supported script functions

    The following listing shows the available script functions exposed by the Simplygon Max plug-in (excluding SPL and shading networks which are documented separately).

    Function Parameter(s) Description
    sgsdk_ProcessSelectedGeometries <none> Process the currently selected geometries (generates the LODs).
    sgsdk_Reset <none> Resets all current settings in the Max plug-in.
    sgsdk_SetShowProgress bool showProgress Sets the ShowProgress flag. If set, the process runs in its own thread with a progress bar.
    sgsdk_SetSettingsPath string settingsPath Sets the path to the preset/SPL which will be used when processing.
    Note: SPL files are only allowed in combination with batch mode.
    sgsdk_SetLoginInfo string username
    string password
    Sets the login information which is required when in batch mode.
    sgsdk_SetBatchMode bool useBatchMode Sets the BatchMode flag. If true, the process will run with the current settings without opening the UI. Make sure to set the login information before processing.
    sgsdk_GetBatchMode <none> Gets the batch mode flag.
    sgsdk_MaterialColor string materialName
    string channelName
    float r
    float g
    float b
    float a
    Overrides or creates a color on the specified channel for the specified material.
    sgsdk_MaterialTexture string materialName
    string channelName
    string texturePath
    Overrides the texture for the specified material.
    sgsdk_MaterialTextureMapChannel string materialName
    string channelName
    int mapChannel
    Overrides the mapping channel/UV channel for the specified material.
    sgsdk_SetIsVertexColorChannel int mapchannel
    bool isVertexColor
    Overrides channels > 2 in Max to be used as vertex colors instead of UV coords.
    sgsdk_SetLockOnBone string boneName
    bool isLocked
    If lock is true, the specified bone and its parents will be locked during bone reduction.
    sgsdk_CustomShaderChannelOverride string materialName
    string materialChannel
    string simplygonChannel
    Maps DirectX material channel to Simplygon material channel.
    sgsdk_UseNonConflictingTextureNames bool useMaterialColor Override generation of unique texture names per object when a MaterialLOD is created. By default the value is set to true.
    sgsdk_SetUseColorChannelAsWeights int mapChannel
    bool removeField
    The specified channel (where channel > 2) is used as vertex weights. Set removeField to true if the channel should not be exported to Simplygon. Disable by setting the channel to -1.
    sgsdk_SetWeightsMultiplier int multiplier Sets the weight multiplier. The lower bound of the weights is 1/multiplier and the bound is multiplier. The multiplier must be in the range 2-8.
    sgsdk_SetWeightsInterpreter int interpreter Sets which interpreter to use when interpreting vertex colors as weights
    0 Black: reduce more | White: reduce less (Default)
    1 Black: unchanged | White: reduce less
    2 Black: reduce more | White: unchanged.
    sgsdk_GetTexturePathForCustomChannel string materialName Gets texture path for specified material channel, if exists.
    sgsdk_GetMaterialsWithCustomChannels Gets a list of materials that has custom channels.
    sgsdk_GetCustomChannelsForMaterial string materialName Gets a list of custom channels for the specified material.
    sgsdk_SetTextureOutputDirectory string outputDirectory Sets the output directory for the generated textures.
    sgsdk_UseSPL string object Specifies which SPL object to use (created with spl_Create).

    Examples

    The following examples show how to use Simplygon through MaxScript:

    Starting the Simplygon Editor

    This MaxScript will send the selected object(s) to the Simplygon UI.

    sgsdk_Reset();
    sgsdk_ProcessSelectedGeometries();
    

    Starting Simplygon in batch mode

    This MaxScript will send the selected object(s) for processing (no UI mode) and return the processed result when the processing is completed.

    sgsdk_Reset(); 
    sgsdk_SetLoginInfo "username" "password"; 
    sgsdk_SetSettingsPath "c:/MyPreset.preset"; 
    sgsdk_SetBatchMode true; 
    sgsdk_ProcessSelectedGeometries();  
    

    Lock bone/bones during process

    This MaxScript will send the selected object(s) to the Simplygon UI with some specific locked bones. Locked bones will not be affected during processing.

    sgsdk_Reset(); 
    sgsdk_SetLockOnBone "skeleton1_LeftForeArm" true; 
    sgsdk_ProcessSelectedGeometries(); 
    

    The next MaxScript will send over the selected object but instead lock multiple bones.

    sgsdk_Reset(); 
    boneList = #($skeleton1_LeftForeArm, $skeleton1_RightFoot)  
    for boneName in boneList do (  
        sgsdk_SetLockOnBone boneName.name true  
    )  
    sgsdk_ProcessSelectedGeometries();
    

    Using vertex colors

    This script will send the selected object(s) for a processing (no UI mode) based on the settings in MyPreset.preset. Mapping channel 3 will be overridden to be handled as a vertex color channel and mapping channel 4 will be used as vertex weights with a multiplier of 8. The result will return to Max when the processing has completed.

    sgsdk_Reset(); 
    sgsdk_SetLoginInfo "username" "password"; 
    sgsdk_SetSettingsPath "c:/MyPreset.preset"; 
    sgsdk_SetBatchMode true; 
    sgsdk_SetIsVertexColorChannel 3 true 
    sgsdk_SetUseColorChannelAsWeights 4 true 
    sgsdk_SetWeightsMultiplier 8 
    sgsdk_ProcessSelectedGeometries();
    
    Back to top Terms of Use | Privacy and cookies | Trademarks | Copyright © 2019 Microsoft