vendredi 2 septembre 2016

Wings3d => ??? => *.svg -- a software/project log

I wasn't quite sure where to put this but I think it's more software than build log.

Here's what I want to do: extract the UV coordinates from a *.obj 3d model, convert the coordinates to SVG and then use an SVG editor to add details, etc., to produce card models. While there is software that allows this, most of it is unavailable to me either due to cost (Rhino!) or platform limitations. First and foremost, I don't run Windows so that eliminates most of the standard options. I can run of the available Windows programs under Wine in Linux, but in almost all cases there are significant limitations. I suspect that many of these limitations are due to my old laptop (coming up on 10 years old, now). I run Mint Mate Linux and I suspect the graphics drivers are responsible for the inability to pick and choose polygons in various programs such as Pepakura. While Blender is a viable option on Linux, I think that's similar to using a chain saw to cut out your card model pieces. It's just too complex for my tastes. I value simplicity in processes. It gives me joy. Using Blender makes this hobby unenjoyable (for me). So Blender sits on my machine as a last ditch option—though I think it's perfectly capable of doing what I want to do. Whether my desire to design card models is strong enough to drive me around Blender's learning curve is probably best left untested! What follows is my experience, explorations, trials, tribulations, observations, comments, complaints and no doubt a bit of venting. Nothing is set in stone. I am most likely, frequently wrong. It's very likely that the work-flow I'm designing will not be applicable to anything but simple shapes or too labor intensive to make it worth the effort. But the only way I'll discover that is through the journey.

I want to share my experiences, get feedback from others who have traveled this road, and hopefully, if all goes well, eventually I'll be able to provide a work-flow and tools that others can use to design their own card models. After all, what truly impresses me about the card-modeling community is the sheer variety of models available. And the more people who design models, the more variety there will be.

Since I am a proponent for open source programs, this is what I've chosen to use (for now): Wings3d for modeling and UV coordinate generation; Inkscape for editing the SVG document; I'll have to write my own code to convert UV coordinates to SVG. Several years ago I wrote a script in Ruby that to convert *.obj models to *.ac for use in the open source flight simulator, FlightGear. I'll use that program as the starting point to convert to UV coordinates since I already have code to parse out the *.obj file. Ideally, I'd like to write code to allow the actual unfolding of the geometry of a 3d model. But that's probably pushing my programming skills too far. Perhaps some day in the future. But for now I'll concentrate on the UV extraction. Once that's complete then I'll have a framework in which I might be able to integrate actual unfolding.

I've used Wings for years so I'm very comfortable creating models in it. While Wings does have some UV functionality, it is not ideal for card modeling. UV coordinates are used by computers to render a graphic image onto the surface of a 3d model. For this purpose, the UV coordinates do not need to reflect the 'true' shape (or size) of the 3d surface. In fact, there are certain efficiencies in stretching and warping the coordinates. So the first challenge is to figure out if and how Wings can generate UV coordinates which accurately reflect the true shape of a face in the 3d model.

So far my tests are encouraging, though it takes some creative work-arounds. In general, you can UV map model faces by their 'normals' which, if the normal is perpendicular, gives you a true shape for the UV coordinates of a face (or multiple co-planar faces). By marking various edges for cuts, and using the 'unfolding' and 'projection normal' commands you'll get a feel for how your various developments will be defined. You pretty much need to know where your cuts are going to be. Do not expect Wings3d to do this for you by using the Camera, Sphere or Cylinder mappings –they will only provide you with distorted shapes. Remember: Wings does not care if UV coordinates reflect actual shape. I don't think there's any way to teach how to get a feel for where to cut your model. You simply have to learn from experience. You may need to cut faces apart in order to get their true shapes. But once you have the true shapes, you can then recombine them in the next window by selecting shared edges and using the 'stitch' command. (Note that it is easier to select the shared edges in the 3d window rather than the UV Map window. Just ensure that you have the 'select line' tool active in both the 3d and UV windows.) This shared edge will usually represent a fold line in the card model. Non-shared edges will generally represent cut lines.

By combining together parts of the 3d model into groups, you can define sub-assemblies for the card model. Each group can (and should) be given a unique name and assigned its own material. This allows you to work on creating the UV coordinates for a small selection of faces (the sub-assemblies) rather than dealing with all the model faces at the same time. This is practically a necessity for complex models. There is a gotcha though. UV coordinates—even if they have the correct shape--do not represent the actual size of the face. UV coordinates have no sense of scale. UV coordinates normally range from 0.0 to 1.0 (think of this as the percentage of the graphic image that would be shown on the computerized 3d model). Furthermore, Wings3d will maximize the UV coordinates for each sub-assembly resulting in a single small wheel having the same size as a large fuselage. Essentially, each subassembly which you map to UV coordinates will have its own, arbitrary scale.

The solution to this conundrum is to combine all of the sub-assemblies into one object AFTER you have defined ALL the UV coordinates. You can then use the UV mapping command to display the coordinates of ALL of the combined object faces. At this point, they will not be sized in relation to each other. They will be shown with whatever arbitrary scale initially assigned. However, once you have them all showing in the same UV window, by selecting ALL the faces and then using the command “Scale | Normalize Faces” the various faces will be resized so that all are sized in relationship to one another. Their true shapes remain, only their sizes will be changed. You can also rearrange and stitch polygons together at this stage. This is a good point to start thinking about how the pieces will be laid out on the page for printing.

Once you have created all the UV coordinates and closed the UV mapping window, return to the 3d modeling window and separate the combined parts. You once again have access to all the individual parts, but their properly scaled UV coordinates remain unchanged. You'll notice that your initial sub-assembly groups and group names are no longer there. These are irretrievably lost when combining the parts into one part to resize the faces. I have not found any way around this. But the material definitions remain intact. Regroup and rename your sub-assemblies. You may be able to select the constituent parts by selecting by assigned material. Give each part a name which helps identify exactly what it is. Give each material a unique diffuse color. These group names and material colors will come in useful when the UV coordinates are converted into SVG objects.

At this point you could use Wings3d's ability to create texture maps to export your UV coordinates in a raster format. However, since I want SVG format I'll go on to the next step in my workflow.

Attached is a screen shot of how my model A7V looks at the end of this process. I'll show the UV coordinates in the next post.


--jeff (in maximum verbosity mode)

Attached Images
File Type: jpg a7v-1.jpg (35.9 KB)


Aucun commentaire:

Enregistrer un commentaire