Autodesk OneClick (Autodesk Character Generator)
Special instructions:
Autodesk supports level-of-detail (LOD) meshes on export. We are aware of four levels of detail and have built that into a helper script that provides an interface to switching these levels and subsequently switching out the SALSA, EmoteR, and Eyes configurations to work with each level. This functionality can occur at runtime, on-the-fly. If Autodesk changes the LOD support (adding/removing/renaming) the base mesh names, you can simply adjust these names in the OneClick. Additionally, you are not required to use all of the LODs available; you can use a single LOD which would operate nearly exactly like the other available OneClicks, or you can use any combination of available LODs that meet your design requirements. The LOD manager has been designed to search out and utilize the available LOD meshes (based on the Autodesk naming strategy).
NOTE: Please use the appropriate SALSA Suite with ACG OneClick, the current version (v2.5.0) requires Suite version 2.5.0+ and OneClickBase v2.5.0+.
LOD functionality is built into the OneClick applied to the model. In most OneClicks, the configuration application is simply called and the SALSA Suite modules are added to the model and automatically configured. Autodesk OneClick v2.5.0 now has two modes of operation. It can operate like standard OneClick configurations and also has the ability to setup a runtime-configured model with an API for controlling the LOD level.
In standard mode, the ACG OneClick will automatically select the highest LOD level available and configure the SALSA Suite for it. In LOD-manager mode, it will select the configured LOD level to start with (if valid). If an invalid LOD is specified, it will select the highest LOD level to start with.
LOD Functionality
The following general rules of functionality are available to supported Autodesk models.
-
Applying the OneClick to a model automatically applies SALSA, EmoteR, and Eyes and sets the model's highest level of detail as active.
-
Autodesk utilizes up to 4 levels of detail, although the functionality of the LOD Manager supports any number of LOD levels. The OneClick API treats these levels as zero-based [0..3]. If using the OneClick API to change levels of detail at run-time, specify the LOD as an integer between [0..3] and understand the rules above.
- 0 = crowd (lowest level)
- 1 = low
- 2 = mid
- 3 = high (highest level)
The LOD Manager parses and builds a list of available LODs on a character model. With the default mesh searches, this will be from 1 to 4 LODs. The Manager now culls out LOD levels where zero SkinnedMeshRenderers were found, which simplifies switching from low to high and vice versa.
-
Utilizing the LOD Manager, it is possible to set the LOD to a specific LOD between 0 and the maximum number of LODs discovered on the character model. If all default Autodesk LODs are discovered, there will be four LODs on the model [0 .. 3]. If 2 LODs are discovered, the available range will be [0 .. 1].
For example: If the crowd, mid, and high levels exist on the model, the available range will be [0 .. 2] (0 = crowd, 1 = mid, and 2 = high). Attempting to set the LOD to 3 will return false. See example in the API documentation below.
-
Specifying an LOD increase [IncreaseLOD()] attempts to increase the LOD detail by one level. If the next level is not available, the process returns false.
-
Specifying an LOD decrease [DecreaseLOD()] attempts to decrease the LOD detail by one level. If the next level is not available, the process returns false. The LOD level list is zero-based, so the minimum LOD level is 0.
ACG API Information
namespace CrazyMinnow.SALSA.OneClicks
class OneClickAutodeskCGLod(){}
public int MaxLod
Returns the highest LOD available based on [0..3] indexing. See LOD Functionality.
public void IncreaseLOD()
Increases the level of detail based on the rules in LOD Functionality above. Logs true when successful and false when an available LOD is not found.
public void DecreaseLOD()
Decreases the level of detail based on the rules in LOD Functionality above. Logs true when successful and false when an available LOD is not found.
public bool BumpLOD(int bumpAmount)
Increases or decreases the LOD level according to the parameter passed. This method is called by IncreaseLOD()
and DecreaseLOD()
, utilizing +1 and -1 respectively as parameters. BumpLOD(int bumpAmount)
returns true when the operation is successful and false when it fails.
NOTE:
BumpLOD()
automatically callsSetLOD()
and, if true, callsDeactivateLOD()
to turn of the previously active LOD.
public void DeactivateLOD(int lodToDeactivate)
Deactivates the specified LOD. It is not necessary to call this function if you use IncreaseLOD()
, DecreaseLOD()
, or BumpLOD()
as it is called automatically if the operation is successful.
public void DeactivateAllLODs()
Deactivates all LODs found on a character model. This function is generally called automatically during the Awake()
phase. It may be desirable to call this at other times determined by the design of the game and has therefore been made a public method.
public bool SetLOD(int lodLevel)
Set a specific LOD based on [0..3] available LODs. Note the rules in LOD Functionality above. This method automatically updates the SALSA Suite after the LOD is set; however, it does not deactivate the previous LOD. Returns true when successful and false when an available LOD is not found.
It is generally recommended to use
IncreaseLOD()
andDecreaseLOD()
instead of manually usingSetLOD()
. Using this function is a very manual implementation of switching LODs and requires an order of operation and some maintenance -- it will be necessary to manually keep track of the currently active LOD to turn it off and determine which direction to activate. See example below for implementation. The following assumes 3 discovered LODs: 0 = crowd, 1 = mid, 2 = high
CrazyMinnow.SALSA.OneClicks.OneClickAutodeskCGLod lodManager;
// To set an LOD, first cache the current ActiveLOD to facilitate
// deactivating the current LOD if SetLOD is successful.
var previousLOD = lodManager.ActiveLOD;
if (lodManager.SetLOD(0)) // attempt setting the LOD to 0 = crowd
{
Debug.Log("ActiveLOD: " + lodManager.ActiveLOD); // console output = 0
lodManager.DeactivateLOD(previousLOD);
}