Search Results for

    Show / Hide Table of Contents

    Class Foliage

    Represents a foliage actor that contains a set of instanced meshes.

    Inheritance
    System.Object
    Object
    SceneObject
    Actor
    Foliage
    Implements
    ISerializable
    Inherited Members
    Actor.SetLayerRecursive(Int32)
    Actor.SetLayerNameRecursive(String)
    Actor.HasTag()
    Actor.HasTag(Tag)
    Actor.HasTag(String)
    Actor.AddTag(Tag)
    Actor.AddTagRecursive(Tag)
    Actor.RemoveTag(Tag)
    Actor.SetParent(Actor, Boolean, Boolean)
    Actor.GetChild(Int32)
    Actor.GetChild(String)
    Actor.GetChild(Type)
    Actor.GetChildren(Type)
    Actor.DestroyChildren(Single)
    Actor.GetScript(Int32)
    Actor.GetScript(Type)
    Actor.GetScripts(Type)
    Actor.AddMovement(Vector3)
    Actor.AddMovement(Vector3, Quaternion)
    Actor.GetWorldToLocalMatrix(Matrix)
    Actor.GetLocalToWorldMatrix(Matrix)
    Actor.OnDebugDraw()
    Actor.OnDebugDrawSelected()
    Actor.GetPrefabRoot()
    Actor.FindActor(String)
    Actor.FindActor(Type, Boolean)
    Actor.FindActor(Type, String)
    Actor.FindActor(Type, Tag, Boolean)
    Actor.FindScript(Type)
    Actor.HasActorInHierarchy(Actor)
    Actor.HasActorInChildren(Actor)
    Actor.IntersectsItself(Ray, Single, Vector3)
    Actor.Intersects(Ray, Single, Vector3)
    Actor.LookAt(Vector3)
    Actor.LookAt(Vector3, Vector3)
    Actor.LookingAt(Vector3)
    Actor.LookingAt(Vector3, Vector3)
    Actor.ToBytes(Actor[])
    Actor.FromBytes(Byte[])
    Actor.FromBytes(Byte[], Dictionary<Guid, Guid>)
    Actor.TryGetSerializedObjectsIds(Byte[])
    Actor.ToJson()
    Actor.FromJson(String)
    Actor.Clone()
    Actor.OnEnable()
    Actor.OnDisable()
    Actor.OnParentChanged()
    Actor.OnTransformChanged()
    Actor.OnActiveChanged()
    Actor.OnActiveInTreeChanged()
    Actor.OnOrderInParentChanged()
    Actor.OnStaticFlagsChanged()
    Actor.OnLayerChanged()
    Actor.OnBeginPlay()
    Actor.OnEndPlay()
    Actor.AddStaticFlags(StaticFlags)
    Actor.RemoveStaticFlags(StaticFlags)
    Actor.SetStaticFlag(StaticFlags, Boolean)
    Actor.HasStaticFlag(StaticFlags)
    Actor.ResetLocalTransform()
    Actor.AddChild(Type)
    Actor.AddChild<T>()
    Actor.GetChild<T>()
    Actor.TryGetChild<T>(T)
    Actor.GetOrAddChild<T>()
    Actor.AddScript(Type)
    Actor.AddScript<T>()
    Actor.GetScript<T>()
    Actor.TryGetScript<T>(T)
    Actor.FindScript<T>()
    Actor.FindActor<T>(Boolean)
    Actor.FindActor<T>(String)
    Actor.FindActor<T>(Tag, Boolean)
    Actor.GetChildren<T>()
    Actor.GetScripts<T>()
    Actor.RotateAround(Vector3, Vector3, Single, Boolean)
    Actor.ToString()
    Actor.Children
    Actor.Tags
    Actor.Layer
    Actor.Name
    Actor.IsActive
    Actor.StaticFlags
    Actor.PerInstanceRandom
    Actor.LocalPosition
    Actor.LocalOrientation
    Actor.LocalScale
    Actor.Sphere
    Actor.Box
    Actor.BoxWithChildren
    Actor.EditorBox
    Actor.EditorBoxChildren
    Actor.HasContentLoaded
    Actor.IsPrefabRoot
    Actor.IsStatic
    Actor.IsTransformStatic
    Actor.WorldToLocalMatrix
    Actor.LocalToWorldMatrix
    SceneObject.SetParent(Actor, Boolean)
    SceneObject.LinkPrefab(Guid, Guid)
    SceneObject.BreakPrefabLink()
    SceneObject.GetNamePath(Char)
    SceneObject.IsDuringPlay
    SceneObject.HasParent
    SceneObject.HasPrefabLink
    SceneObject.PrefabID
    SceneObject.PrefabObjectID
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public sealed class Foliage : Actor, ISerializable

    Constructors

    Foliage()

    Initializes a new instance of the Foliage.

    Declaration
    public Foliage()

    Properties

    FoliageTypesCount

    Gets the total amount of the types of foliage.

    Declaration
    [Unmanaged]
    public int FoliageTypesCount { get; }
    Property Value
    System.Int32

    GlobalDensityScale

    Gets or sets the global density scale for all foliage instances. The default value is 1. Use values from range 0-1. Lower values decrease amount of foliage instances in-game. Use it to tweak game performance for slower devices.

    Declaration
    [Unmanaged]
    public static float GlobalDensityScale { get; set; }
    Property Value
    System.Single

    InstancesCount

    Gets the total amount of the instanced of foliage.

    Declaration
    [Unmanaged]
    public int InstancesCount { get; }
    Property Value
    System.Int32

    Methods

    AddFoliageType(Model)

    Adds the type of the foliage.

    Declaration
    [Unmanaged]
    public void AddFoliageType(Model model)
    Parameters
    Model model

    The model to assign. It cannot be null nor already used by the other instance type (it must be unique within the given foliage actor).

    AddInstance(ref FoliageInstance)

    Adds the new foliage instance. Ensure to always call RebuildClusters() after editing foliage to sync cached data (call it once after editing one or more instances).

    Declaration
    [Unmanaged]
    public void AddInstance(ref FoliageInstance instance)
    Parameters
    FoliageInstance instance

    The instance.

    Remarks

    Input instance bounds, instance random and world matrix are ignored (recalculated).

    GetFoliageType(Int32)

    Gets the foliage type.

    Declaration
    [Unmanaged]
    public FoliageType GetFoliageType(int index)
    Parameters
    System.Int32 index

    The zero-based index of the foliage type.

    Returns
    FoliageType

    The foliage type.

    GetFoliageTypeInstancesCount(Int32)

    Gets the total amount of the instanced that use the given foliage type.

    Declaration
    [Unmanaged]
    public int GetFoliageTypeInstancesCount(int index)
    Parameters
    System.Int32 index

    The zero-based index of the foliage type.

    Returns
    System.Int32

    The foliage type instances count.

    GetInstance(Int32)

    Gets the foliage instance by index.

    Declaration
    [Unmanaged]
    public FoliageInstance GetInstance(int index)
    Parameters
    System.Int32 index

    The zero-based index of the foliage instance.

    Returns
    FoliageInstance

    The foliage instance data.

    Intersects(ref Ray, out Single, out Vector3, out Int32)

    Determines if there is an intersection between the current object or any it's child and a ray.

    Declaration
    [Unmanaged]
    public bool Intersects(ref Ray ray, out float distance, out Vector3 normal, out int instanceIndex)
    Parameters
    Ray ray

    The ray to test.

    System.Single distance

    When the method completes, contains the distance of the intersection (if any valid).

    Vector3 normal

    When the method completes, contains the intersection surface normal vector (if any valid).

    System.Int32 instanceIndex

    When the method completes, contains zero-based index of the foliage instance that is the closest to the ray.

    Returns
    System.Boolean

    True whether the two objects intersected, otherwise false.

    RebuildClusters()

    Rebuilds the foliage clusters used as internal acceleration structures (quad tree).

    Declaration
    [Unmanaged]
    public void RebuildClusters()

    RemoveAllInstances()

    Clears all foliage instances. Preserves the foliage types and other properties.

    Declaration
    [Unmanaged]
    public void RemoveAllInstances()

    RemoveFoliageType(Int32)

    Removes the foliage instance type and all foliage instances using this type.

    Declaration
    [Unmanaged]
    public void RemoveFoliageType(int index)
    Parameters
    System.Int32 index

    The zero-based index of the foliage instance type.

    RemoveInstance(Int32)

    Removes the foliage instance. Ensure to always call RebuildClusters() after editing foliage to sync cached data (call it once after editing one or more instances).

    Declaration
    [Unmanaged]
    public void RemoveInstance(int index)
    Parameters
    System.Int32 index

    The zero-based index of the instance to remove.

    SetInstanceTransform(Int32, ref Transform)

    Sets the foliage instance transformation. Ensure to always call RebuildClusters() after editing foliage to sync cached data (call it once after editing one or more instances).

    Declaration
    [Unmanaged]
    public void SetInstanceTransform(int index, ref Transform value)
    Parameters
    System.Int32 index

    The zero-based index of the foliage instance.

    Transform value

    The value.

    UpdateCullDistance()

    Updates the cull distance for all foliage instances and for created clusters.

    Declaration
    [Unmanaged]
    public void UpdateCullDistance()

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.DeepClone<T>(T)
    Extensions.RawClone<T>(T)

    See Also

    Actor
    In This Article
    • Constructors
      • Foliage()
    • Properties
      • FoliageTypesCount
      • GlobalDensityScale
      • InstancesCount
    • Methods
      • AddFoliageType(Model)
      • AddInstance(ref FoliageInstance)
      • GetFoliageType(Int32)
      • GetFoliageTypeInstancesCount(Int32)
      • GetInstance(Int32)
      • Intersects(ref Ray, out Single, out Vector3, out Int32)
      • RebuildClusters()
      • RemoveAllInstances()
      • RemoveFoliageType(Int32)
      • RemoveInstance(Int32)
      • SetInstanceTransform(Int32, ref Transform)
      • UpdateCullDistance()
    • Extension Methods
    • See Also
    Back to top Copyright © 2012-2024 Wojciech Figat