I would like to create a rectangular tube-shaped extrusion along a spline and a defined width. But I can’t do the extrusion correctly.
In the image we can see that the extrusion is not flat, it forms weird things. At both ends it does not touch the ground. In short, I think I didn’t really understand how shape extrusion works.
Thank you Cedric for your help. I wouldn’t have imagined that this could be generated by an image. I didn’t even know it was possible for an image to create vertex changes.
Thanks Cedric, but this won’t work for what I want to do.
There you generate a terrain complet. What I do is a field editor. We create a flat terrain or with a heightmap and users can modify it by creating mountains, rivers by painting. Then I would like to create a tool so that it can create paths along a spline and that this path is flat on the x and z axis, but not in Y (except by softening the angles to have a fluid path )
On the other hand, your projection system could perhaps be used to apply the texture of the path, I discovered something with your PG. But that still remains a bit complicated for me to understand.
Did you look at my PG to better understand what I wanted to do? It works, but has issues.
I wish I could correct that. You can see in the image that the Shape has an angle that I don’t understand.
I use an extrusion, because with a tube it doesn’t work well. A ribbon created similar problems for me and I was advised to create an extrusion to create the shape which draws the path, then discard it once the paths have been generated.
Can you try to repro your issue with a smaller PG? without any manual interaction. I guess it’s the path that introduces a up computation but I’m not sure.
I’ve drastically simplified your extrusion here
What it shows is that on a curved 3D path, the extrusion (and underlying ribbon) has to interpolate vertices that induce torsion. I don’t have a workaround for this, although I can imagine one.
on a side note, the adjustFrame parameter for extrusions only has meaning when the path exactly reverses itself between two control points, i.e. given two consecutive points on the path, pi pj, the array contains [… pi, pj, pi, pj, …]
Thanks @lowclouds for have simplified the extrusion.
So should I understand that this is not the right approach of it this way?
This works very well with a tube, but it forms a rounded path. Which can be good for digging rivers, but not for paths. I suggested creating a square tube instead of the round one and I was told to do it with an extrusion. But that doesn’t seem to work too.
Do you have another idea that might work ?
Maybe @Cedric you have another solution.
I just had an idea. Seeing that you have a tube it seems to work, but it forms a rounded path. Is there no possibility of then flattening this path which has been rounded by the tube.
Here’s a PG with a hit. It works well, but the path takes the shape of the tube. Would it be nice if we could flatten this path next? But I don’t know how to do that. With a square tube it would simplify things for me.
The tube extrusion just hides the underlying problem; you’d still see issues where curvature is high if you tried to flatten it. Check out this modification, where I’ve used a Catmull Rom spline to increase the number of sections in the path. You can tweak the number of spline points to exaggerate this. When the curvature of the path gets high, the path begins to self-intersect, and torsion is still introduced - you could hand-draw this out to see why this happens.
Again, I don’t have a solution in hand, but I may eventually
You are right, the problem is the same with a tube which is based on a ribbon too.
I applied your changes. I don’t know how other publishers do this. I see this everywhere, but it seems that with Babylon we can’t do it. Sometimes I want to give up on everything. I’ve been stuck on this feature for 1 month and it seems that there is no solution.
This works perfectly well if my path is a bit straight. If I could get this result with a rounder path, it would be perfect.
You just need to be able to prevent the ribbon from bending. But it doesn’t seem possible to constrain this from what I understand.
Here’s a start of an outline of how to fix this, although many details are unfinished. The above playground shows the binormals that ExtrudeShape is using to construct the road. The longer red vectors sticking out are parallel to the xz plane (constructed by crossing the tangent vector with 0,1,0. You could use these to construct a ribbon and then extrude that - but you’ll still have to deal with the curvature causing self-intersections. That’s part two.
Thank you very much @lowclouds. It works perfectly well with your solution.
I adapted all of this in my PG and the result is just perfect. I used a ribbon, without extruding it. And the colored lines, I display them in Debug mode.
I have a little question @lowclouds . Is it possible to center the line so that the ribbon is centered on the line white. On the screenshot above, you can see the white line and I try to center it on the red lines.