I’ll try to better explain myself
the problem you raise of shared points being inefficient is already present in your original example, whether or not you use lerp and whether or not you use tweening.
Are you talking about the exmples with only triangles? Every shape is a separate entity, I can’t see how they can have common points… For the Delaunay, isn’t the mesh library avoiding common points? And even if it doesn’t: already duplicated points + new duplicated points = double duplicated points.
Is your goal to animate a Delaunay object, or animate a single mesh seeded by a Delaunay?
If I understood correctly your question, are you asking me if I want to create a Delaunay object and then interpolate it’s points without another Dealunay calculation or if I want move the points continuosly calculation Delaunay triangulation? Doesn’t matter, if it’s easier even the first approach is useful, I don’t need to have a perfect Delaunay triangulation, I like that kind of shape but no needs to be perfect. Or interpolating from the center to the Delaunay position, or from the previous Delaunay points position to the new Delaunay, all without loosing from the screen the previous shape
If so, why is your simplified code based on an ArrayList and creating new triangles?
How do I mantain all the shape visible on screen without displaying them everytime iterating an Array? I’m sorry, but I only know this method
I used triangle as a generic shape, I thought that I would be able to adapt it to my Delaunay case
Why store PShapes at all if they are just an ephemeral render-time object?
Same as before, is there another method to always display shapes on screen beside storing in an ArrayList and displaying them?
Will you have one Delaunay object, or many?
many, as my previous posts and examples, I want to be able to create a new interpolating Delaunay without erase from the screen the previous. I’m able to create a new shape everytime I mouseClick, I’m able to create and interpolating Delaunay everytime I mouseClick, but I’m not able to do it in the same sketch
import megamu.mesh.*;
int numPoints = 10;
int dimension = 200;
int yoffset = 0;
float xoff = 0.0;
int coin;
float[][] points = new float[numPoints][2];
float[][] newPoints = new float[numPoints][2];
float[][] offset = new float[numPoints][2];
ArrayList<Delaunay> delaunayList = new ArrayList<Delaunay>();
int debNum = 200;
void setup() {
size(600, 500, P3D);
for (int i = 0; i < numPoints; i++) {
for (int j = 0; j < 2; j++) {
points[i][j] = (int) random(dimension);
newPoints[i][j] = points[i][j];
offset[i][j] = random(0.1, 0.3);
}
}
}
float camNoise = 0;
float xcamoffset;
void draw() {
background(255);
//Change height of the camera with mouseY
xcamoffset = map(noise(camNoise), 0.0, 1.0, -100, 100);
camera(xcamoffset, yoffset, 400, xcamoffset, yoffset, 0, 0, 1, 0);
camNoise+=0.01;
coin = (int) random(100);
if (coin < 10) {
createDelaunay();
}
for (int i = 0; i < numPoints; i++) {
for (int j = 0; j < 2; j++) {
points[i][j] = lerp(points[i][j], newPoints[i][j], offset[i][j]);
}
}
for (int i = 0; i < delaunayList.size(); i++) {
float[][] myEdges = delaunayList.get(i).getEdges();
for (int j = 0; j < myEdges.length; j++) {
float startX = myEdges[j][0];
float startY = myEdges[j][1];
float endX = myEdges[j][2];
float endY = myEdges[j][3];
line( startX, startY, endX, endY );
}
int[][] myLinks = delaunayList.get(i).getLinks();
for (int k = 0; k < myLinks.length; k++) {
int startIndex = myLinks[k][0];
int endIndex = myLinks[k][1];
float startX = points[startIndex][0];
float startY = points[startIndex][1];
float endX = points[endIndex][0];
float endY = points[endIndex][1];
line( startX, startY, endX, endY );
}
}
}
void createDelaunay() {
for (int i = 0; i < numPoints; i++) {
newPoints[i][0] = (int) random(dimension) + (map(noise(xoff), 0.0, 1.0, -width/2, width/2));
newPoints[i][1] = (int) random(dimension) + yoffset;
}
xoff = xoff + 0.01;
Delaunay myDelaunay = new Delaunay( points );
delaunayList.add(myDelaunay);
yoffset -= (int) random(5, 0);
}
This is the behaviour I want to achieve, but with the mesh library (and I can’t use the mesh library because I wasn’t able to find a way to fill the Delaunay object
Do you need to be able to perform operations like adding or deleting points or faces as the animation progresses, or are the number of points / faces conserved?
No, they remains always the same number
In general, one way of animating a mesh of triangle regions, e.g. with the mesh library, is like this:
etc
The code I provided you is an already working interpolating Delaunay object with the mesh library
I hope I didn’t forgot anything Thank you!