VoxelInstanceLibraryItem
Settings for a model that can be used by VoxelInstancer
Settings for a model that can be used by VoxelInstancer
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties6
FloatingSdfOffsetAlongNormalProperty
public float FloatingSdfOffsetAlongNormal { get; set; }Offset along instances upward axis to apply when the object is tested for being floating or not.
An instance is determined to be floating if the SDF at its origin is greater than 0. However, in practice, SDF can be imprecise, and the way instances spawn on triangles of meshes means SDF at their position will always fluctuate a bit around 0. This can lead instances to be overly removed after digging around them, or not enough. You can attempt to fix this by increasing this offset to very small values, so SDF slightly below instances (usually underground) is tested instead. Negative values will check below, positive will check above. Make sure to test resulting behaviors.
WARNING: changing this too high can break automatic removal entirely, but is relatively safer than VoxelInstanceLibraryItem.FloatingSdfThreshold.
FloatingSdfThresholdProperty
public float FloatingSdfThreshold { get; set; }Threshold used to find if SDF is air. If the SDF at the sampled location is greater, the instance is considered floating. See also VoxelInstanceLibraryItem.FloatingSdfOffsetAlongNormal for more info.
WARNING: changing this too high can break automatic removal entirely. While this can "turn off" removal after digging ground, it is not recommended to do this when instances have no collider, because then it leaves no way of removing them.
GeneratorProperty
public VoxelInstanceGenerator Generator { get; set; }Generator that will be used to pick points where the item will spawn.
LodIndexProperty
public int LodIndex { get; set; }LOD index of chunks of the terrain where this item will spawn. The higher it is, the broader the range it will spawn at around viewers, however it will have lower precision because it uses meshes of a lower level of detail. Prefer spawning larger objects on higher LOD indexes (large trees, boulders), and small objects on lower LOD indexes (grass, small rocks)
NameProperty
public string Name { get; set; }PersistentProperty
public bool Persistent { get; set; }If not enabled, items will always spawn if generator conditions are met: for example, if you dig a hole, it will remove grass in the surface, but if you leave the area and come back, grass will spawn inside the hole.
If enabled, and if the terrain has a VoxelStream supporting instances, this item will be saved in chunks where instances of it got modified (following the same events as voxel modifications), so if you leave and come back, instances of the item will remain in the same state as you left them. Only the transform of items is saved.
Note: saving relies on identifying the item in save files with the same number given in the VoxelInstanceLibrary. Removing the item or changing its ID can lead saves to load the item incorrectly.
See also [url]https://voxel-tools.readthedocs.io/en/latest/instancing/#persistence[/url]
Methods12
GetFloatingSdfOffsetAlongNormalfloat
public float GetFloatingSdfOffsetAlongNormal();floatGetFloatingSdfThresholdfloat
public float GetFloatingSdfThreshold();floatGetGeneratorVoxelInstanceGenerator
public VoxelInstanceGenerator GetGenerator();VoxelInstanceGeneratorGetItemNamestring
public string GetItemName();stringGetLodIndexint
public int GetLodIndex();intIsPersistentbool
public bool IsPersistent();boolSetFloatingSdfOffsetAlongNormalvoid
public void SetFloatingSdfOffsetAlongNormal(float sd);| Name | Type | Default |
|---|---|---|
sd | float | — |
SetFloatingSdfThresholdvoid
public void SetFloatingSdfThreshold(float sd);| Name | Type | Default |
|---|---|---|
sd | float | — |
SetGeneratorvoid
public void SetGenerator(VoxelInstanceGenerator generator);| Name | Type | Default |
|---|---|---|
generator | VoxelInstanceGenerator | — |
SetItemNamevoid
public void SetItemName(string name);| Name | Type | Default |
|---|---|---|
name | string | — |
SetLodIndexvoid
public void SetLodIndex(int lod);| Name | Type | Default |
|---|---|---|
lod | int | — |
SetPersistentvoid
public void SetPersistent(bool persistent);| Name | Type | Default |
|---|---|---|
persistent | bool | — |