예제 #1
0
    void Update()
    {
        //	In case the object is rendered by any camera we have to update its position.
        if (ObjectIsVisible)
        {
            //	Check for material – you could add a check here if Gerstner Waves are enabled
            if (WaterMaterial == null)
            {
                return;
            }

            if (UpdateWaterMaterialPerFrame)
            {
                //	Update the Gestner Wave settings from the material if needed
                LuxWaterUtils.GetGersterWavesDescription(ref Description, WaterMaterial);
            }

            //	Get the offset of the Gerstner displacement. We have to pass:
            //	- a sample location in world space,
            //	- the Gestner Wave settings from the material sttored in our Description struct,
            //	- a time offset (in seconds) which lets us create an effect of the inertia of masses.
            Vector3 Offset = LuxWaterUtils.GetGestnerDisplacement(this.transform.position, Description, TimeOffset);

            //	We assume that the object itself does not move.
            var newPos = pos;
            newPos.x += Offset.x * Damping.x;
            newPos.y += Offset.y * Damping.y;
            newPos.z += Offset.z * Damping.z;

            trans.position = newPos;
        }
    }
예제 #2
0
    void Start()
    {
        trans = this.transform;
        pos   = trans.position;

        //	Get the Gestner Wave settings from the material and store them into or Description struct
        LuxWaterUtils.GetGersterWavesDescription(ref Description, WaterMaterial);
    }
예제 #3
0
    private void LateUpdate()
    {
        if (!this.ObjectIsVisible && !this.AddCircleAnim || Object.op_Equality((Object)this.WaterMaterial, (Object)null))
        {
            return;
        }
        if (this.UpdateWaterMaterialPerFrame)
        {
            LuxWaterUtils.GetGersterWavesDescription(ref this.Description, this.WaterMaterial);
        }
        Vector3 WorldPosition = Vector3.op_Subtraction(this.trans.get_position(), this.Offset);

        if (this.AddCircleAnim)
        {
            ref Vector3 local1 = ref WorldPosition;
            local1.x = (__Null)(local1.x + (double)Mathf.Sin(Time.get_time() * this.Speed) * (double)Time.get_deltaTime() * (double)this.Radius);
            ref Vector3 local2 = ref WorldPosition;
예제 #4
0
 private void Update()
 {
     if (this.ObjectIsVisible)
     {
         if (this.WaterMaterial == null)
         {
             return;
         }
         if (this.UpdateWaterMaterialPerFrame)
         {
             LuxWaterUtils.GetGersterWavesDescription(ref this.Description, this.WaterMaterial);
         }
         Vector3 gestnerDisplacement = LuxWaterUtils.GetGestnerDisplacement(base.transform.position, this.Description, this.TimeOffset);
         Vector3 position            = this.pos;
         position.x         += gestnerDisplacement.x * this.Damping.x;
         position.y         += gestnerDisplacement.y * this.Damping.y;
         position.z         += gestnerDisplacement.z * this.Damping.z;
         this.trans.position = position;
     }
 }
예제 #5
0
 private void Start()
 {
     this.trans = base.transform;
     this.pos   = this.trans.position;
     LuxWaterUtils.GetGersterWavesDescription(ref this.Description, this.WaterMaterial);
 }
예제 #6
0
 private void Start()
 {
     this.trans = ((Component)this).get_transform();
     LuxWaterUtils.GetGersterWavesDescription(ref this.Description, this.WaterMaterial);
 }
    void LateUpdate()
    {
        //	In case the object is rendered by any camera we have to update its position.
        if (ObjectIsVisible || AddCircleAnim)
        {
            //	Check for material – you could add a check here if Gerstner Waves are enabled
            if (WaterMaterial == null)
            {
                return;
            }

            if (UpdateWaterMaterialPerFrame)
            {
                //	Update the Gestner Wave settings from the material if needed
                LuxWaterUtils.GetGersterWavesDescription(ref Description, WaterMaterial);
            }

            var pos = trans.position;
            //	Reset pos by subtracting the last Offset
            pos -= Offset;

            //	Animate the position
            if (AddCircleAnim)
            {
                pos.x += Mathf.Sin(Time.time * Speed) * Time.deltaTime * Radius;
                pos.z += Mathf.Cos(Time.time * Speed) * Time.deltaTime * Radius;
            }

            //	Sync assigned Managed Water Projectors (transform)
            var count = ManagedWaterProjectors.Length;
            if (count > 0)
            {
                for (int i = 0; i != count; i++)
                {
                    var cpos = ManagedWaterProjectors[i].position;
                    cpos.x = pos.x;
                    cpos.z = pos.z;
                    ManagedWaterProjectors[i].position = cpos;
                }
            }

            //	Get the offset of the Gerstner displacement. We have to pass:
            //	- a sample location in world space,
            //	- the Gestner Wave settings from the material sttored in our Description struct,
            //	- a time offset (in seconds) which lets us create an effect of the inertia of masses.
            Offset = LuxWaterUtils.GetGestnerDisplacement(pos, Description, TimeOffset);

                #if UNITY_EDITOR
            var maxd = Offset.magnitude;
            if (maxd > MaxDisp)
            {
                MaxDisp = maxd;
            }
                #endif

            //	Calculate the new Offset
            Offset.x += Offset.x * Damping.x;
            Offset.y += Offset.y * Damping.y;
            Offset.z += Offset.z * Damping.z;

            trans.position = pos + Offset;
        }
    }