I was trying to create a subdivided surface.
What I try to archieve is subdivide the surface to make a quad mesh out of it.
Thats why I thought maybe just divide it points,but the problem is partition the list correct.
I just found how to subdivide into points.
Maybe someone can push it a little bit in the correct direction?
I don’t think there is an 1:1 equivalent which offers individual UV control yet. But you could create a mesh in the XYPlane using Mesh.CreateFromPlane and map that to the surface to create a new mesh…
For the grid what you have there seems little weird. The step is usually i++ and the amount of steps usually done by second part of the for loop conditions with i ans an integer (this also won’t get potential floating point errors). What I mean is you are being redundant in making a kind of step decimal there when you already have inputs for u and v might as well just use that as the amount of loops.
Also, you you are dealing with division count you don;t really need to reset the domain, usually you reset the domain if you are dealing with parameter values for the input. So you can just do some math dividing by the length of the domains.
private void RunScript(Surface S, int U, int V, ref object A)
{
List<Point3d> uvGrid = new List<Point3d>();
for(int i = 0; i < U + 1; i++)
{
for(int j = 0; j < V + 1; j++)
{
Point3d srfPt = S.PointAt(S.Domain(0).Length / U * i, S.Domain(1).Length / V * j);
uvGrid.Add(srfPt);
}
}
A = uvGrid;
thanks for explaining it clearly, I thought about something like that but didnt got it to work , so I used an example i found on the internet.
Is it possible to make a quad mesh out of it? Should be also doable with math I imagine? Or do you have an example of how to subdivide a srf?
The simplest is to use the existing component. Then only slighty harder is to use the method i’ve described by remapping an existing mesh face structure from the xy to the surface uv domains.
To make this ypurself in a C# component you would first create the mesh vertices using the points (done). Then generate the mesh face indices (faces). Then build a mesh. Example how to do this can be found here.
I give you one like for using exactly the same naming conventions and the naming of your variables. Although I dislike using i and j for loop indices. I prefer u and v, since we are moving in surface space.