void Start()
    {
                #if DW
        if (RealisticWaterPhysics.currentUseDW == true)
        {
            DynamicWaterSystemWater = GameObject.FindGameObjectWithTag("DynamicWater");
            if (DynamicWaterSystemWater != null)
            {
                if (DynamicWaterSystemWater.GetComponent <DynamicWater>() == true && DynamicWaterSystemWater.GetComponent <DynamicWater>().enabled == true)
                {
                    //Its limited to 10,000 by them, not me :P
                    DynamicWaterSystemWater.GetComponent <DynamicWater>().Density = PhysicsMaterialsList.getLiquidsMaterialValue(selectedOceanLiquidsMaterial);
                }
            }
        }
                #endif

        float CalculatedWaterDensity = PhysicsMaterialsList.getLiquidsMaterialValue(selectedOceanLiquidsMaterial);

        RealisticWaterPhysics.Setup(CalculatedWaterDensity, waterLevel, useExternalWaterLevel, useCeto, useDW, useAquas, usePW, selectedGasesMaterial, maxAirLevel, 4, 4);

        if (RealisticWaterPhysics.currentDebugEnabled)        // Just skip this if debug info is disabled.
        {
            Debug.Log("Calculated Water Density:" + CalculatedWaterDensity);
        }
    }
示例#2
0
    void calculateResults()
    {
        //Make sure a gameobject is selected!
        if (SelectedObject != null)
        {
            bool Failed = false;
            //First calculate the density of the object.
            if (SelectedObject.GetComponent <MeshFilter>() && SelectedObject.GetComponent <MeshFilter>().sharedMesh != null)
            {             // Use meshfilter based bounds
                CalculatedVolume = MeshVolume.getVolume(SelectedObject as GameObject);
            }
            else if (SelectedObject.GetComponent <Collider>())
            {             // Use collider based bounds
                CalculatedVolume = MeshVolume.getVolumeByColliderBounds(SelectedObject.GetComponent <Collider>());
            }
            else
            {
                Debug.Log("[Realistic Water Physics] Object is missing a mesh filter or collider.");
                Failed = true;
            }

            if (!Failed)            // a small fix!
            {
                //Now the percentage thats solit and the remaining is air.
                float percentageSolidMass = CalculatedVolume * ((selectedMaterialValue / 100) * percentageSolid);
                float percentageAir       = CalculatedVolume * ((RealisticWaterPhysics.currentAirDensity / 100) * (100 - percentageSolid));

                //The totaal mass of the object is the amount of solit material + the remaining amount of air.
                CalculatedMass = percentageSolidMass + percentageAir;

                //the density of the intire object is its calculated mass / its volume.
                CalculatedDensity = CalculatedMass / CalculatedVolume;

                CalculatedWaterDensity = PhysicsMaterialsList.getLiquidsMaterialValue(selectedOceanLiquidsMaterial);
                CalculatedAirDensity   = airDensity;



                if (CalculatedDensity > CalculatedWaterDensity)                // if denser then water density it will sink.
                {
                    CalculatedWillFloatInWater = false;
                }
                else
                {
                    CalculatedWillFloatInWater = true;
                }


                if (CalculatedDensity > CalculatedAirDensity)                // if denser then air density it will sink
                {
                    CalculatedWillFloatInAir = false;
                }
                else
                {
                    CalculatedWillFloatInAir = true;
                }
                DidTest = true;
            }
        }
    }
示例#3
0
    void NoneGUIElementsUpdate()
    {
        selectionGameObjects = new List <GameObject>(Selection.gameObjects);
        //Its not so nice but will shot the window search blocking Light window search.
        if (OldtoolbarInt != toolbarInt)
        {
            //User pressed as button!
            OldtoolbarInt = toolbarInt;
            //To keep the OnGUI() cleaner!
            if (toolbarInt == 0)
            {
                showSetupOptions           = true;
                showGameobjectSetupOptions = false;
                existingObjectsManager     = false;
                searchFilterResetDone      = false;
                resetSearchFilter();
            }
            else if (toolbarInt == 1)
            {
                showGameobjectSetupOptions = true;
                showSetupOptions           = false;
                existingObjectsManager     = false;
                searchFilterResetDone      = false;
                resetSearchFilter();
            }
            else if (toolbarInt == 2)
            {
                showGameobjectSetupOptions = true;
                showSetupOptions           = false;
                existingObjectsManager     = true;
                searchFilterResetDone      = false;
                resetSearchFilter();
                RealisticComponentSearch.SetSearchFilter("RealisticBuoyancy", 2);
            }
        }

        if (SelectedMaterialType == MaterialTypes.Solid)
        {
            selectedMaterialValue = PhysicsMaterialsList.getSolidMaterialValue(selectedSolidsMaterial);
        }
        else if (SelectedMaterialType == MaterialTypes.Liquids)
        {
            selectedMaterialValue = PhysicsMaterialsList.getLiquidsMaterialValue(selectedLiquidsMaterial);
        }
        else
        {
            selectedMaterialValue = PhysicsMaterialsList.getGasesMaterialValue(selectedGasesMaterial);
        }


        checkForChanges();       //Check to see if user changed anything, exept the gameobject thats a check of its own type.
        RememberOlds();          // Remember the options for now!

        createOrUpdateManager(); //Create or update the manager.

        CalculatedWaterDensity = PhysicsMaterialsList.getLiquidsMaterialValue(selectedOceanLiquidsMaterial);
        //CalculatedAirDensity = CalculateStuff(airTempeture, airDensity);
        CalculatedAirDensity = airDensity;         // Work in progress!
    }
示例#4
0
 private float getSelectedMaterialValue()
 {
     if (SelectedMaterialType == MaterialTypes.Solid)
     {
         return(PhysicsMaterialsList.getSolidMaterialValue(selectedSolidsMaterial));
     }
     else if (SelectedMaterialType == MaterialTypes.Liquids)
     {
         return(PhysicsMaterialsList.getLiquidsMaterialValue(selectedLiquidsMaterial));
     }
     else
     {
         return(PhysicsMaterialsList.getGasesMaterialValue(selectedGasesMaterial));
     }
     return(0.0f);
 }