curve vertex move in quad mesh , in runtime ?

Mushrooms Labs Q&ACategory: Curved Poly Shape Editorcurve vertex move in quad mesh , in runtime ?
mun sungwon asked 5 years ago

Dear sis,
 
Good advice. I’ll give a good comments in asset store. Your sample code is good working. Thanks,
I have a another question.
Your shape editor support this kind of movement ?
I’d like to move vertex in 2 ways.   Linear move . another is curved move in quad mesh.
I tested your sample. Only move the linear vertex move in quad mesh,
 
Give a way. How to move the vertex as a linear and curved way in runtime. ( quad mesh)
 
I send screen shot to your email.
 
Thanks,
 
Vincent

1 Answers
Alessandro MartinelliAlessandro Martinelli Staff answered 5 years ago

Hello vincent.
Ok, I’m going to explain you a bit more about the CurvedPolygonsNet object i showed you last time (for everybody else reading the question was this: https://support.mushroomslabs.com/question/curved-poly-shape-editor-runtime-support/)
But please: We are going to have a full documentation for runtime API and there are many things I can’t explain in a short message and which will be explained in depth in the docs. I shall ask you a bit of patience for more details about runtime components. Everything will be out with Curved Poly – Shape Editor v 1.2 which is on the road (there will be an article with more details soon about this).
Now your infos. Here I will show you an example based on the Quad1x primitive, which is one of the most simple.
What you Need to Know
Take this data from runtime structure (curvedPolygonsNet) i showed you last time:
Vector3[] vertices = curvedPolygonsNet.GetVertices();
short[] edges = curvedPolygonsNet.GetEdgesIndex();
short[] edgesIndex = curvedPolygonsNet.GetEdges();
Vertices will be an array of 12 positions in this case. It will have this structure: [v0, v1, v2, v3, h4, h5, h6, h7, h8, h9, h10, h11] where v0, v1, v2, v3 are main vertices and h4, h5 … h11 are handles (that is the internal curves vertices).  edges and edgesindex will have , instead this content:
edges [ 0, 4, 5, 1, 2, 6, 7, 3, 0, 8, 9, 2, 1, 10, 11, 3]     edgesIndex [ 0, 4, 8, 12, 16]
edges contains a full list of all the indices of each edge. EdgesIndex contains the limits of each edge within edges. So, in this example, edgesIndex says that the first edge goes from index 0 to index 4 (excluded), the second edge from 4 to 8 (excluded) and so on. Each edge can have 4 or 2 indices (4 for curved edges and 2 for linear edges). If you use primitives from the Primitives folders they are made only of curves, but if you use primitives from the libraries they may have lines.
So, now you can reconstruct the structure of each edge:
Edge 1 :  [0, 4, 5, 1]  meaning  [v0, h4, h5, v1]
Edge 2 :  [2, 6, 7, 3]  meaning  [v2, h6, h7, v3]
Edge 3 :  [0, 8, 9, 2]  meaning  [v0, h8, h9, v2]
Edge 4 :  [1, 10, 11, 3]  meaning  [v1, h10, h11, v3]
Ok. When you move a vertex, you also want to move it’s adjacent handles. To know which are the adjacent handles, you have to check the edges. For example we can see that, in this case, the main vertex v0 has two adjacent handles h4 and h8 (they are closed to it Edge1 and Edge3). So if you want to move v0, you probably want to move h4 and h8 of the same amount:
Vector3 delta = Vecto3.right*0.2f;
vertices[0]+=delta;
vertices[4]+=delta;
vertices[8]+=delta;
But: this depends on what you wish to accomplish, you will need to write your own code and formulas to move vertices. And for every model, you need to extract the adjacency relationships from the edges as i did first in this example.
Again: in two months or so we are going to have Shape Editor version 1.2 with runtime API  clearly exposed and documented online. If you need to know more, I shall ask you a bit of patience.

Michael ChristiansenMichael Christiansen replied 5 years ago

Will it be possible to label vertices on a model with names that can be used to identify at runtime? This will make code immune to changes in the changes in vertex ordering / placement caused by changes to the model.

Alessandro MartinelliAlessandro Martinelli Staff replied 5 years ago

No, it will not be possible. I know a lot of geometric data formats around (really a lot) and no one would give names to single vertices; usually names are given to single parts of objects (like Curved Poly Geometries) which makes sense, but giving a name to vertices would significantly increase the amount of memory used to store data.

For example: try to imagine how much more bytes would require to name vertices on a common mesh of 5000 polygons.

I understand your needs, but keeping the amount of bytes as lower as possible on Curved Poly Assets is a priority for Curved Poly. The final goal of this project is to create huge libraries of models to be used in games which take an impressively low amount of data in builds.

That said: the order of vertices will not change if you don’t re-edit the model. It will not change either in the case you reshape it with Pointings Operator or Selection Operator. It’s not possible to change that order with Shape Editor at all. Vertices will change order only when you restructure the model with the Edit Operator and in a very few other cases like canceling hidden elements in the Hiding Operator or updating new parts with Create Operator.