[Mod] Interactive Physics (out of alpha!) [physics]

Post Reply
User avatar
sorcerykid
Member
Posts: 1461
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

[Mod] Interactive Physics (out of alpha!) [physics]

by sorcerykid » Post

Image

Interactive Physics Mod v1.1
physics (by sorcerykid)

Interactive Physics is a completely Lua-driven physics simulator and API for Minetest, offering a far more immersive gameplay experience with plug-and-play integration for new and existing mods alike.

The library handles quasi-realistic physical interactions between entities vs. players and entities vs. nodes (including air and water) -- sufficient to suspend disbelief for purposes of gameplay, but also with minimal performance costs incurred. It takes advantage of several features made available by PR #9747.

Image

Here's a demonstration video showing what is possible:

Image
https://vimeo.com/318083845
Showcasing Interactive Physics Library in Minetest

Besides the API, a control panel interface is available to manually override the physical properties of solid and liquid nodes as well as entities directly in-game.

Repository:

https://bitbucket.org/sorcerykid/physics

Download Archive (.zip)
Download Archive (.tar.gz)

Compatibility:

Minetest 5.3-dev patched with PR #9717

Dependencies:

ActiveFormspecs Mod by sorcerykid (optional)
Configuration Panel Mod by sorcerykid

Source Code License:

GNU Lesser General Public License v3 (LGPL-3.0)

Installation:
  1. Unzip the archive into the physics directory of your game
  2. Rename the physics-master directory to "physics"
  3. Add "physics" as a dependency to any mods using the API.
Usage Instructions:

Interactive physics supports a wide variety of basic physical properties for entities, liquid nodes, solid nodes, and air nodes. It's also possible to manually override these properties in-game by use of the Physics Wand. Simply point to the respective node or entity and left-click. A pop-up window will appear so that you can make the desired adjustments in realtime.

Image

Of course you can always click "Reset" to revert to the default values. If you wish to permanently change the properties of liquids and solids, then you can do so by editing the physics/materials.lua file.

As you can see, the following nodes have been pre-configured for you.

Code: Select all

return {
        ["group:water"] = { type = "liquid", viscosity = 0.5, density = 0.5 },
        ["group:lava"] = { type = "liquid", viscosity = 0.7, density = 0.5 },
        ["default:ice"] = { type = "solid", friction = 0.0, elasticity = 0.0 },
}
While it is also possible to configure entire groups of nodes as shown above, the physics wand itself can only override the properties of one node at a time in-game.

To set the global defaults for all liquid and solid nodes, just edit physics/config.lua. This is also where you can fine-tune gravity and adjust the properties of air itself.

Code: Select all

world_gravity = 10
air_viscosity = 0.0
air_density = 0.2
default_liquid = { viscosity = 0.2, density = 0.5 }
default_solid = { friction = 0.5, elasticity = 0.0 }
Note that in all cases, except for gravity, the values must range between 0, for no effect, to 1 for full effect. Avoid numbers outside of this range, otherwise the results will be undefined (and possibly not even supported in future versions).

Now that the basic setup is out of the way, you're ready to integrate Interactive Physics into your own mods! First and foremost, you will need to inherit the BasicPhysics superclass. The best place to do this is within the on_activate() callback of your entity.

Code: Select all

on_activate = function ( self, dtime, staticdata )
	BasicPhysics( self )
	:
end
Next, add a physics table to the entity prototype. Here is an example:

Code: Select all

        physics = {
                friction = 0.4,
                density = 0.7,
                elasticity = 0.3,
                resistance = 0.2,
        },
You can customize these values to your liking, in much the same way as you did earlier for liquid and solid nodes. However, any such changes will be reflected in all instances of that same entity. For situations where entities must not share the same physical properties, simply add self.physics = table.copy(self.physics) to the entity's on_activate() callback.
Last edited by sorcerykid on Sat May 16, 2020 21:19, edited 1 time in total.

User avatar
TumeniNodes
Member
Posts: 2874
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by TumeniNodes » Post

Very impressive!

This could be useful for projectile flight as well (arrows and spears) possibly even throwing axes and daggers, I think.
The possibilities are flooding the brain right now
Ich mag keine grünen Eier und Schinken, ich mag sie nicht Sam I Am

User avatar
Devy
Member
Posts: 132
Joined: Sat Jan 21, 2017 02:31
GitHub: CoderForTheBetter
In-game: devy

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by Devy » Post

Really great! I've been thinking about how cool some sports mods would be.

Is the code going to be posted here? Or should refer to the Athletics mod? Can you provide links? Testing will go faster if people can play with it!

User avatar
Hume2
Member
Posts: 618
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by Hume2 » Post

Is it possible to apply the density to all entities, so players wouldn't be able to sink in lava?
If you lack the reality, go on a trip or find a job.

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by aristotle » Post

Great job! :D +10!
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
Diamond knight
Member
Posts: 475
Joined: Sun Apr 19, 2015 19:50
GitHub: Diamondknight
In-game: Ferrumprinceps
Location: Chilling in Constantinople
Contact:

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by Diamond knight » Post

This would be good for a minigames server

Skulls
Member
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by Skulls » Post

What do you have your server step set to?

User avatar
sorcerykid
Member
Posts: 1461
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Interactive Physics (Sneak Peak) [physics]

by sorcerykid » Post

I'm very happy to announce that Interactive Physics library is now out of ALPHA at long last. I have been waiting for the buggy collision detection in the engine to be fixed. Thankfully there has been a huge improvement with Minetest 5.2 and 5.3-dev -- enough that I am confident that this library is finally usable.

The relevant PRs that addressed those issues are found here:
https://github.com/minetest/minetest/pull/9764 (just merged today!)
https://github.com/minetest/minetest/pull/9343

Here is a brief clip showcased Interactive Physics being used in conjunction with my Thievery and Mobs Lite mods. Both the broadhead arrow, the landmines, and the zombie gibs are physics enabled.

Image.

The repository has been updated with the latest development build:
https://bitbucket.org/sorcerykid/physics

The only dependency is ActiveFormspecs. However, it is optional, should you wish to manually override the physical properties of nodes and entities in-game. Otherwise, there are no required dependencies.

User avatar
ErrorNull
Member
Posts: 222
Joined: Thu Mar 03, 2016 00:43

Re: [Mod] Interactive Physics (out of alpha!) [physics]

by ErrorNull » Post

this looks awesome. so does your mod allow blocks like dirt and trees to behave and fall with gravity now? no more floating blocks?
My Villagers Mod: [villagers]

User avatar
sorcerykid
Member
Posts: 1461
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Interactive Physics (out of alpha!) [physics]

by sorcerykid » Post

Thanks! Dirt and trees are nodes, so they would not be effected unless converted into an object (a-la falling nodes for example).

On a related note, here's a video from a few weeks ago of the "new and improved" athletics mod using the latest version of Interactive Physics. The movement of the soccer ball is much more realistic now :)

Image
https://vimeo.com/420764088

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests