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.