Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

103 Neutral

About Hairies

  • Rank
  1. ok, forget the density problem issue, its not that important...could you send me your buyouncy script so i could look at it ?
  2. first i want to know that how is it that 1) if p_fluid < p_body : Object sinks 2) if p_fluid = p_body: Object floats 3) if p_fluid > p_body: Object rises, if both water and object density dont change?
  3. So, actually the denities of both water and object don't change? im confused...why am i then reading that 1) if p_fluid < p_body : Object sinks 2) if p_fluid = p_body: Object floats 3) if p_fluid > p_body: Object rises...? Apart from that, can you help me calculating the correct motion of the object in water influenced by bouyency?
  4. you said that the density of water doesnt change, but how can the object sink or rise, if the waters density stays the same? From wikipedia i got this: "A body often rises till it breaks through the waters surface. In this case : V_submerged * p_fluid = V_body * p_body.
  5. But isnt it so, that the object in water floats if its density is equal to the water's density and it sinks if it is bigger and it rises if it is lower? so the density of the water somehow must change...actually finding the amount of displaced liquid shouldnt be too hard, because it is exactly the same as the amount of volume of the object submerged in water isnt it, so i just needed to calculate that volume?
  6. Hello there, im currently working on a framework to create my own games and wanted to add buoyancy physics to it. I understand the fundamentals, but still have problems to implement it the right way into my framework. I calculated the resulting force on the object by subtracing the gravity force from the buoyancy and worked out the resultgin acceleration. I know that the density of the water gets bigger as the object rises in the water, but i dont know when it gets lower...but these are only some problems...anyways ill post my code here(written in C#) and hope somebody will be able to help me creating realistic buoyancy physics. In the moment the object just accelerates up and never returns down -,-... using System; using System.Collections.Generic; using System.Linq; using System.Text; using DextroEngine; using DextroEngine.Physics; using Tao.OpenGl; namespace Shooter { class buoyancy_test:IGameObject { Renderer _renderer = new Renderer(); Sprite s = new Sprite(); Gravitation g = new Gravitation(9.81f); double pK = 0.75f;//object density double pFl = 1;//water density double watervolume = 0;//amount of object in water double YIncrement = 0;//amount to increase/decrease objects posítion double buoyancy = 0; double bodyforce = 0; double _totaltimePassed; float PercentInWater = 9f; bool moveup = false; bool movedown = false; public buoyancy_test() { s.SetWidth(10); s.SetHeight(10); s.rigidbody.Density = pFl; s.rigidbody.SetVolume(s.GetWidth(), s.GetHeight(),10); CalculateMass(); Get_pFl(); } public double CalculateMass() { bodyforce = pK* g.gravitation * s.rigidbody.GetVolume(); s.rigidbody.Mass = bodyforce / g.gravitation; return s.rigidbody.Mass; } public double InWaterVolume() { watervolume = s.GetWidth() * s.GetHeight() * PercentInWater; return watervolume; } public double Get_pFl() { double v_inWater = InWaterVolume(); pFl = (s.rigidbody.Volume * pK)/v_inWater; return pFl; } public void UpdateMovement(double time) { _totaltimePassed += time; buoyancy = pFl * g.gravitation * s.rigidbody.GetVolume(); double result_force = buoyancy - bodyforce; double a = result_force / s.rigidbody.Mass; if ((pFl > pK)&&(pFl < 1)) { moveup = true; movedown = false; } if ((pFl >1)) { moveup = false; movedown = true; } if (moveup) { YIncrement += (a * 0.5 * (_totaltimePassed * _totaltimePassed)); PercentInWater -= 0.1f; if (PercentInWater > 7.5f) { Get_pFl(); } } if (movedown) { YIncrement -= (a * 0.5 * (_totaltimePassed * _totaltimePassed)); PercentInWater += 0.1f; if (PercentInWater < 9.0f) { Get_pFl(); } } } public void Update(double elapsedTime) { UpdateMovement(elapsedTime); s.SetPosition(0, 0+YIncrement); } public void Render() { Gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); _renderer.DrawSprite(s); } } }
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!