(May 2019) Monthly WIP & Screenshot Thread

Coming soon to Minie: soft-body physics!

18 Likes

You’ve been doing some really nice things with physics. I was looking at your buoyancy video and wanted to put a camera in the ocean floating around in a barrel. Do you have test classes available to get the general idea of how to implement them available?

Nice work, btw :slight_smile:

1 Like

Simulating a camera floating in a barrel shouldn’t be difficult if you use Minie. I’d be happy to help.

Like most of my demos, the buoyancy demo is open-source, available from GitHub:
https://github.com/stephengold/Minie/blob/master/MinieExamples/src/main/java/jme3utilities/minie/test/BuoyDemo.java

2 Likes

Small update. Crawling is now possible too. Amazing how effortless this was actually, after figuring out how to change the shape of a dyn4j physic object :smiley:

I avoid polishing or fine tuning the game at this state, still a rough prototype to try out a few game mechanics elements. I have a couple of ideas and want to check if they are fun or not.

6 Likes

I’ve used Dyn4j, and found that sometimes collisions are not being registered and object falling through another.

I’ve never had this problem… and I did some pretty crazy stress testing including super-fast objects, etc… probably this deserves its own thread but I’m guessing it was situational.

And for super fast objects there is the possibility to mark it as a “bullet” to avoid that an object passes through an other unnoticed. And yes I also never had such an issue.

Spent few days exploring basic AI in jMonkey and implementing it into my game.
It’s really fun! :sunglasses:

Just only lemur container doesn’t appear where I want it to be :face_with_raised_eyebrow:

6 Likes

Toying around with all kinds of noise generation. I’ve implemented a lot of the functionality I need. The only thing left is layer masking (mask layers with a “land mass” layer for example - like mountains - so they don’t appear below a “sea level”) - which is already half there. I can make some pretty cool worlds a lot quicker now I have a lot of options to tweak. I’d like to finish this up and move on now, so I’ll hopefully be uploading this to github over the next few days.

Fun fact - javafx control overlays don’t get painted in FRAPS, so combobox options can’t be seen when I click them.

9 Likes

I have recently used the bullet integration SiO2/extensions/bullet/src/main/java/com/simsilica/bullet at master · Simsilica/SiO2 · GitHub to integrate it in my sim-eth-es based game. On desktop is running very smooth though…

10 Likes

More progress with my game prototype. Took me around 2h for pickup and shoot :slight_smile:

6 Likes

Progress on soft-body physics:

15 Likes

Great job :slightly_smiling_face:

@sgold a few questions beforehand:

  • Would it be possible to do a character cloth sim with bullet softbody ?
  • And is there something like accuracy control for increasing performance, so by lowering accuracy we can gain extra fps ?
3 Likes

nice, i just hope it will be in JME bullet basecode someday :slight_smile:

1 Like

Toying with various ways to plot vegetation. Its all fine and well planting grass and flowers, but larger objects need a different method.

In the image below there are three layers. The large circles are trees, smaller ones bushes maybe, and yellow even smaller bushes or something. They won’t intersect and you can set a minimum space between them.

The image is just a visual of the algorithm to make sure it works before I go any further.

I don’t think it’s the final code I’ll use, but it’s a proof of concept, nonetheless.

package com.jayfella.test;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.material.Materials;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector2f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Quad;
import com.jme3.system.AppSettings;
import com.jme3.texture.Image;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
import com.jme3.texture.image.ColorSpace;
import com.jme3.texture.image.ImageRaster;
import com.jme3.util.BufferUtils;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class TestRandomPlotter extends SimpleApplication {

    public static void main(String... args) {

        TestRandomPlotter testRandomPlotter = new TestRandomPlotter();

        AppSettings appSettings = new AppSettings(true);
        appSettings.setResolution(1280, 720);
        appSettings.setFrameRate(120);
        appSettings.setTitle("Test :: Vegetation Plotter");

        testRandomPlotter.setSettings(appSettings);
        testRandomPlotter.setShowSettings(false);
        testRandomPlotter.setPauseOnLostFocus(false);


        testRandomPlotter.start();

    }

    private final List<Point> areaPoints = new ArrayList<>();
    private final Random random = new Random();
    private final int size = 128;

    @Override
    public void simpleInitApp() {

        Geometry plane = new Geometry("Plane", new Quad(size, size));
        plane.setLocalScale(5);
        plane.setMaterial(new Material(assetManager, Materials.UNSHADED));
        guiNode.attachChild(plane);

        // start big and work our way down in size. This avoids the little ones stealing all the space.

        // some big trees
        List<Point> bigTrees = addPoints(5, 20, 10, 15, 1000, ColorRGBA.Brown);
        areaPoints.addAll(bigTrees);

        // some large bushes
        List<Point> bushes = addPoints(10, 5, 5, 8, 1000, ColorRGBA.Green);
        areaPoints.addAll(bushes);

        // smaller bushes
        List<Point> flowers = addPoints(100, 2, 1, 3, 1000, ColorRGBA.Yellow);
        areaPoints.addAll(flowers);

        ByteBuffer buffer = BufferUtils.createByteBuffer(size * size * 4);
        Image result = new Image(Image.Format.RGB8, size, size, buffer, ColorSpace.sRGB);
        ImageRaster imageRaster = ImageRaster.create(result);

        // fill the texture with a background color.
        for (int x = 0; x < size; x++) {
            for (int y = 0; y < size; y++) {
                imageRaster.setPixel(x, y, ColorRGBA.DarkGray);
            }
        }

        // draw some circles
        for (Point p : areaPoints) {

            for (int i = 0; i < 360; i++) {
                int x = (int) (p.pos.x + p.radius * FastMath.cos(i * FastMath.DEG_TO_RAD));
                int y = (int) (p.pos.y + p.radius * FastMath.sin(i * FastMath.DEG_TO_RAD));

                if ( x > 0 && x < size && y > 0 && y < size) {
                    imageRaster.setPixel(x, y, p.color);
                }

            }
        }

        Texture2D texture = new Texture2D(result);
        texture.setMagFilter(Texture.MagFilter.Nearest);

        plane.setLocalTranslation(200, 5, 1);
        plane.getMaterial().setTexture("ColorMap", texture);


    }

    private List<Point> addPoints(int amount, float minSpaceBetween, int minRadius, int maxRadius, int maxAttempts, ColorRGBA color) {

        List<Point> points = new ArrayList<>();

        int attempts = 0;

        while (points.size() < amount) {

            if (attempts >= maxAttempts) {
                break;
            }

            Point point = new Point();
            point.color = color;
            point.pos = new Vector2f(random.nextFloat() * size, random.nextFloat() * size);
            point.radius = minRadius + ( (maxRadius - minRadius) * random.nextFloat() );

            // don't let our point go outside the "zone".
            if (point.pos.x - point.radius < 0 || point.pos.x + point.radius > size || point.pos.y - point.radius < 0 || point.pos.y + point.radius > size) {
                continue;
            }

            boolean intersects = false;
            
            // check if we're intersecting with existing points
            for (Point p : areaPoints) {
                if (p.intersects(point, minSpaceBetween)) {
                    intersects = true;
                    break;
                }
            }
            
            // if we are, back out now.
            if (intersects) {
                attempts++;
                continue;
            }
            
            // check if we're intersecting with our current points.
            for (Point p : points) {
                if (p.intersects(point, minSpaceBetween)) {
                    intersects = true;
                    break;
                }
            }
            
            // if we are, back out now.
            if (intersects) {
                attempts++;
                continue;
            }
            
            // everything seems fine, plot the position.
            points.add(point);
        }
        
        // we won't always get what we wanted. We might not have been able to fit the amount we wanted due to space.
        System.out.println("Tried: " + amount + " - Managed: " + points.size());
        
        return points;
    }

    private class Point {

        Vector2f pos;
        float radius;
        ColorRGBA color;

        boolean intersects(Point point, float minSpace) {
            float dist = FastMath.abs(point.pos.distance(pos));
            return dist < (point.radius + radius + minSpace);
        }

    }

}

5 Likes

Super simple game to demonstrate the ability to change the game’s code on the fly and make it yours. Check the “Code!” button at the bottom-left corner :slight_smile:
https://www.youtube.com/watch?v=YPWutLDyWWc

The game can be downloaded from itch.io
https://adi-barda.itch.io/catch-the-spheres

2 Likes

I’m pretty sure Bullet softbody is capable of simulating cloth. Bullet comes with a SoftDemo app that appears to include ropes, cloth, and bunnies, but tbh I’ve never tried to run the app. (I think I’m developing an allergy to C++ :)) Cloth is a high priority for me, so I probably won’t release Minie 1.0 without it.

Bullet soft bodies have dozens of tunable parameters, some of which appear to trade performance for accuracy. So far, I’m impressed by the performance I get with the defaults: that squishy ball has 1,280 faces, and with Vsync turned off the app runs at 1,900 fps.

As anyone who’s read the “Documentation for Advanced Users” knows, @dokthar has already implemented Bullet soft bodies for JME. I’m building upon his work.

6 Likes

Got bored of the usual humdrum, so played around with supershapes. I’m missing a single vertex position right at the end, which is really annoying, but after a few hours of tinkering got the indices and normals to play nicely. And for fun I added a mixer to transition from one shape to another.

What’s cool is that you can transition from one shape to another - like from a square box to a rounded box, or a sphere to a cylinder - and all kinds of interesting things.

The animation is a bit trippy but meh. I did what I set out to do.

Paul Bourke knows a lot more about it than I do, so if you’re wondering what the hell I’m on about - have a good read.
http://paulbourke.net/geometry/supershape/

8 Likes

Wrote another prototype for a can’t stop running game. Have now everything in place to make the blocks fall when the player touches it :slight_smile:

To write those prototypes is quite some fun.

4 Likes

Planting the larger of the vegetation. Still needs some tweaking but all in all it’s starting to look like a nice little world to play around with. Slowly one by one adding things and reeling back the all-important numbers… I keep saying I’m going to publish the source and never do. It will happen.



24 Likes