Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Buoyancy in AGK2?

Author
Message
Karna
14
Years of Service
User Offline
Joined: 22nd Jan 2010
Location: American Left Coast
Posted: 3rd Mar 2018 00:27
I'm working on a boat-based simulation, and so I have everything floating.

It looks like buoyancy is not natively supported in the included physics functionality. I am considering just having a plain under the "water" that objects rest on to appear as if floating on the surface of the water, but there are all sorts of problems that are created there.

Are there any ways or libraries to easily approximate buoyancy and/or floating on water?

Thank you!
puzzler2018
User Banned
Posted: 3rd Mar 2018 00:30 Edited at: 3rd Mar 2018 00:35
Can use the magical SIN and COS

SIN along the horizontal axis
COS along the vertical

eg

x = n * sin(angle)
y = n * cos(angle)

n = time

so it creates a sine wave over time,

eg

increase your angle back and forth for a boat sensation of going up and down - between say 180-300 degrees

angle > 300 then dec angle

if angle<180 then inc angle
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Mar 2018 10:39 Edited at: 3rd Mar 2018 10:45
i would try to give objects up force
you need the density of the Fluid Water = 1 g/cm³ = 1000 kg/m³ (wikipedia)
the volume that your object displaced
and weight force F = m * 9.81
https://en.wikipedia.org/wiki/Buoyancy
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 3rd Mar 2018 17:31
2D or 3D?
Karna
14
Years of Service
User Offline
Joined: 22nd Jan 2010
Location: American Left Coast
Posted: 9th Mar 2018 12:27
I'm writing in 3d.

There's my boat! It is riding low in the 'water'... but right now there is no real water, just objects floating in space.

I'm preparing to introduce physics, for the inevitable boat crashes, fires and people going overboard. I don't think I need real mathematical buoyancy, but objects do need to appear to float, so the easiest (and quickest) solution might be to scoot the boat objects along a plane (so they don't fall through into space) and then add a water graphic afterward, when I have the movements all worked out.

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Mar 2018 20:58
how about a collision box (water) and if objects are in you give them a up force?
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : NVIDIA (390.65) GeForce GTX 1050 Ti : Mac mini OS High Sierra (10.13)
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 9th Mar 2018 22:36
Quote: "how about a collision box (water) and if objects are in you give them a up force?"


3D Physics does not have force commands.
The coffee is lovely dark and deep,and I have code to write before I sleep.
puzzler2018
User Banned
Posted: 9th Mar 2018 22:38 Edited at: 9th Mar 2018 22:42
Just keep it simple with sin and cos - minecraft post gives an example

I purposely made a raft floating with wind cause I saw this thread - it would be use full

Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 10th Mar 2018 20:55
Thought would be a good idea to fill in the AppGameKit survey and ask for extending the physics with vehicle physics(the more people ask, the more likely it will be added), but when I checked https://pybullet.org/ and https://github.com/bulletphysics/bullet3 I didn't see(or at least not a first glance) an extensive section with examples or demos for vehicles/buoyancy, so perhaps a bit harder than I imagened. Thought was just a matter of converting C++ sources as I know bullet physics for vehicles to be present in other engines.
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 11th Mar 2018 12:49
Id settle for just having a way of applying forces in 3D physics for a start. At the moment, just setting velocities of objects is a bit simplistic.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 11th Mar 2018 15:41
Quote: "Id settle for just having a way of applying forces in 3D physics for a start. At the moment, just setting velocities of objects is a bit simplistic."


Tell Paul to just wrap them and expose them to tier1.
The coffee is lovely dark and deep,and I have code to write before I sleep.
Karna
14
Years of Service
User Offline
Joined: 22nd Jan 2010
Location: American Left Coast
Posted: 11th Mar 2018 20:36
@puzzler - Thank you! That looks great!

My particular struggle is how to make the objects (boats, people, etc) appear to be submerged to a waterline without falling through the world, and ideally without them appearing to flood (if they are boats) as well, as in the picture.

I like how the built-in physics package will let objects bump into each other, but it does not look like there is a simple way to flow around. I'm thinking about trying particles or small primitives for water, but I also worry about lagging the frame refresh rate... I would even be happy if I could take a negative image 'chunk' out of a shape, like 'shape subtraction' in POV Ray.
puzzler2018
User Banned
Posted: 13th Mar 2018 12:52
Cheers - no probs,

With the people or other objects - may have to change the pivot of the object, im not sure how to handle this - i havent seen a command that can change its home position.

I.E for a character - change the home position/pivot on its centre of its shoulders., so when roatetobjectlocalx, y, z, it can rotate on that pivot - looking like its submerged on the water plane

Unless there is a command to do this and I havent seen it.

puzzler2018
User Banned
Posted: 13th Mar 2018 13:02
Maybe helpful

FixObjectPivot and RotateObjectLocalX,Y,Z

This apparently rotates objects on its centre

https://forum.thegamecreators.com/thread/216160


Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 13th Mar 2018 14:11
Quote: "3D Physics does not have force commands."

i put it into feature request.
a = F / m
https://en.wikipedia.org/wiki/Acceleration
https://en.wikipedia.org/wiki/Velocity
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : NVIDIA (390.65) GeForce GTX 1050 Ti : Mac mini OS High Sierra (10.13)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Mar 2018 16:48
This might be worth having a look at:
http://dbcc.zimnox.com/?page=view&challenge=Buoyancy/Fluid%20Dynamics&lang=
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-11-27 14:45:42
Your offset time is: 2024-11-27 14:45:42