Dynamic Water Physics 2
Search Results for

    Show / Hide Table of Contents

    Class MassFromVolume

    Script to calculate mass from mesh volume and material density. Removes need for guessing mass and ensures that all objects of same density are submerged equally.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    MassFromVolume
    Namespace: NWH.DWP2.WaterObjects
    Assembly: NWH.DWP2.dll
    Syntax
    [RequireComponent(typeof(WaterObject))]
    public class MassFromVolume : MonoBehaviour

    Fields

    | Edit this page View Source

    density

    Calculated density of the material in kg/m³.

    Declaration
    public float density
    Field Value
    Type Description
    float
    | Edit this page View Source

    mass

    Calculated mass of the object in kg.

    Declaration
    public float mass
    Field Value
    Type Description
    float
    | Edit this page View Source

    material

    Material preset containing density value.

    Declaration
    public WaterObjectMaterial material
    Field Value
    Type Description
    WaterObjectMaterial
    | Edit this page View Source

    volume

    Calculated volume of the simulation mesh in m³.

    Declaration
    public float volume
    Field Value
    Type Description
    float

    Methods

    | Edit this page View Source

    CalculateAndApplyFromDensity(float)

    Calculates mass from the given density and applies it to the Rigidbody.

    Declaration
    public float CalculateAndApplyFromDensity(float density)
    Parameters
    Type Name Description
    float density

    Material density in kg/m³.

    Returns
    Type Description
    float

    Calculated mass value.

    | Edit this page View Source

    CalculateAndApplyFromMaterial()

    Calculates mass from the assigned material's density and applies it to the Rigidbody.

    Declaration
    public float CalculateAndApplyFromMaterial()
    Returns
    Type Description
    float

    Calculated mass value.

    | Edit this page View Source

    CalculateSimulationMeshVolume()

    Gets volume of the simulation mesh. Scale-sensitive.

    Declaration
    public void CalculateSimulationMeshVolume()
    | Edit this page View Source

    SetDefaultAsMaterial()

    Sets the default WaterObjectMaterial from Resources.

    Declaration
    public void SetDefaultAsMaterial()
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics