How to represent flow on a Curve mesh?

Good day,

In my scene editor I have these Curve meshes I am using to represent connections in a control dialog.

I want to show the flow of the connection between these boxes.

Does anyone know how I can code a material for the Curve/Line that shows a dashed line with flow.

This is what it currently looks like:

image

What I want is something like this but will flow from left to right on the dashes of the curve:

image

Is that dashed line already drawn with a shader? If so I’d just offset the position along the line (used to determine if the dash is rendered or not) by time. I did flowing water like that (but it was offsettitng the texture coordinates)

Are you able to show how you create the curved line currently?

No the dashed line I edited in GIMP for representation for this forum topic.
This is my code:

    private Geometry drawLine2(Vector3f startPoint, Vector3f endPoint, float curveLength) {
        Vector3f[] controlPoints = new Vector3f[4];
        controlPoints[0] = startPoint;
        controlPoints[1] = startPoint.add(curveLength, 0, 0);
        controlPoints[2] = endPoint.subtract(curveLength, 0, 0);
        controlPoints[3] = endPoint;

        Spline spline = new Spline(Spline.SplineType.Bezier, controlPoints, 20, false);
        Curve curve = new Curve(spline, 40);
        Geometry lineGeom = new Geometry("line", curve);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");  // create a simple material
        mat.setColor("Color", ColorRGBA.Yellow);   // set color of material to blue
        lineGeom.setMaterial(mat);
        lineGeom.getMaterial().getAdditionalRenderState().setLineWidth(1);

        return lineGeom;

    }    

Whatever approach you use, you will probably need to set texture coordinates on the curve mesh.

…then without a custom shader, set a dashed texture and animate the texture coordinates.

Okay, how do I go about this?
Something like this?

setBuffer(VertexBuffer.Type.TexCoord, 2, BufferUtils.createFloatBuffer(vertexTexCoordinates));

Hi @ndebruyn , maybe you can find some useful examples here:

or maybe here:

1 Like

Thanks for sharing. I will look at it and see if I can use is.

1 Like

The example I use when wanting to know how to set things on a Mesh is Quad.java.

It’s not the most efficient way to set texture coordinates on a mesh if you are going to do it a lot… but it works fine and is simple to cut/paste that section of code. Especially if you already know you will have a fixed number of coordinates.

Edit: though if you find a material to do it then you only have to set the texture coordinates once and copying that code from Quad.java is the easiest way.

Thanks for all references and help by all.
I finally got a solution and just had to add the TextureCoords to the Curve mesh.
Using a material with a dashed texture and an animated UV movement to get the effect.

flow-brain

6 Likes

And here is an image of a more complex setup. Here you can see why I wanted to implement it.
The view now gives a beter and clear view of flow in the brain.
flow-brain-big

7 Likes