Case Study 1: Split Ring Tool

There is the saying, you can’t see the forest for the trees. Well I think our problem is the reverse- we can see the forest, but can’t see the trees. We know what we need and where we need to get, but not how to get there. I think if we start looking at the trees it will help us narrow down our vision.

Spaxe’s post in ‘the way forward’ thread got me thinking. Let’s examine some ‘abstract’ case studies. I’m going to try to push for one a week if they are helpful, because they will be easy to give input on- they don’t have abstract and existential hurdles that trying to design an entire program have. By tackling these representative issues, we may get a better idea of what the systems will need to be. Eventually this will also help us with our UML design.

So, first up is, a Split Ring tool (Maya nomenclature). In Max, you’d grab a ring of edges, and hit ‘Connect’. What is this tool and how is it implemented?

=======================================

Tool Design

What does it need to do?
Split Polygon needs to take a ring of selected edges, and make an edge that intersects all edges at their midpoints. It will also split corresponding UV’s.

Options:
[ol]
[li]Instead of the midpoint, there needs to be an option for parametrical distance (50% would be midpoint of each edge).[/li][li]Ability to preserve UV’s or not. If not, then have an option to assign unique parametrical distance for the split UV edge.[/li][li]Option to assign a noise to the parametrical percentage per-edge.[/li][/ol]

Implementation
Split Poly tool is a class (what baseclass?). It has the ITopologyChanger and IUVChanger interfaces. It has the following methods:
[ul]
[li]cutEdge(mesh theMesh, int theEdge, float paramDist): Calls the appropriate functions for the mesh to create vertices (theMesh.createVert). Returns the vert ID.[/li][li]cutEdges(mesh theMesh, array consecutiveEdges, list parametricDistances): This calls cutEdge for each edge in the list, then calls theMesh.connectVerts for the newly cut vertices.[/li][li]getParametricDistances(int numToCreate): Returns an array of length ‘numToCreate’ of random floats between 0 and 1. Can be overloaded to have various parameters of any type to change random number generation.[/li][li]cutUvEdge and cutUvEdges, which work like their mesh counterparts.[/li][li]split(mesh theMesh, array consecutiveEdges): Depending on the settings of the tool (preserve UV’s, etc.), calls the rest of the functions above to cut edges and uv’s, preserve uv’s, generate noise or not, etc.[/li][/ul]

ITopologyChanger has the methods: cutEdge and cutEdges, and IUvChanger has the methods: cutUvEdge and cutUvEdges.

mesh class has createVert and connectVerts.

===============================

That was a very enlightening exercise for me. I think it is getting the first steps of how things are going to fit together. The actual code is irrelevant- are my methods in the right spot? Are things abstracted and OO enough? What issues are going to arise? Please give any feedback or make your own design.

Mmm. Woke up and today is the egg and bacon day . . .

Honestly I’m not quite sure why I used Maya’s Split Polygon tool as an example. Perhaps because before I was writing the other post, I was using it a lot and it didn’t like me. :rolleyes:

I just loaded up Maya and tried it again, and this time it liked me. So it’s . . . an annoying bug that I don’t know why it happened.

Basically, in Maya, there’s an option you can check off so that the split polygon tool doesn’t have to always split on edges, except the first and last point. So, what it enables is a great flexibility of drawing the lineflow. If a quad has edges A, B, C, and D, in that order, I could draw from A, and then draw in the center of the face if I wanted to, and then end in B. This, to me, is almost essential to have for the tool.

Aside from that, all else is extra features. :]

Hm. Talking about extra features . . . I’ll give that more thought and post later.

Oh shoot, been years since I used Maya, I was thinking about another tool. It should really be Maya’s ‘Split Ring’ tool. What the tool is doesn’t matter, it is about how it works… any tool would have been fine.