PaperModelers.com

Go Back   PaperModelers.com > Designers Corner > Software

Reply
 
Thread Tools Display Modes
  #1  
Old 09-02-2016, 11:16 AM
Kugelfang's Avatar
Kugelfang Kugelfang is offline
Member
 
Join Date: Feb 2009
Location: Silver Spring, MD, USA
Posts: 280
Total Downloaded: 37.97 MB
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 Thumbnails
Wings3d => ??? => *.svg -- a software/project log-a7v-1.jpg  
Reply With Quote
Google Adsense
  #2  
Old 09-02-2016, 01:45 PM
Kugelfang's Avatar
Kugelfang Kugelfang is offline
Member
 
Join Date: Feb 2009
Location: Silver Spring, MD, USA
Posts: 280
Total Downloaded: 37.97 MB
Part II:

A number of years ago I was interested in porting some of the 3d models I had made into FlightGear. I had originally gotten involved in 3d modeling for the proprietary Virtual Sailor and MicroFlight simulators. So I have a number of ships and planes already modeled. But since every simulator seems have its preferred format, being able to convert from one format to another was a helpful excersise. Interestingly enough, it was my interest in 3d modeling which had led me to create an SVG mapping library for a state agency which I worked for in 2004. I remember thinking that what I really wanted to do was convert my 3d models to card models. Here I am picking up that process again twelve years later using essentially the same tools. What goes around, comes around!

The first step was to find my old conversion script. Luckily, once located, I found that I had been pretty thorough. The Ruby script reads in the entire *.obj file as well as associated *.mtl file which holds definitions for materials applied to the model. All of this is stored in memory and all attributes are accessible from within the code—including the UV coordinates of each and every face in the model. In addition, the model identifies faces in a group and any materials assigned to those groups. Frankly, it only took a couple of hours to write a code module which spits out the UV coordinates as SVG polygons, combined and named by group and assigned the diffuse color of the material of the group as a class style for the SVG polygons. In short, each model group with UV coordinates in the *.obj file is written to an SVG document as an object of polygons with a stroke color matching the material color. For example, in my tank the object 'pilot_house' which is assigned material 'pilot_house' with a diffuse color of green, ends up in the SVG document as a combined group of polygons named 'pilot_house' drawn in green.

But all is not quite rosy. There are some challenges. The first is that of inconsistent coordinate systems. UV coordinates in an *.obj model range from 0.0 to 1.0, up and to the left. So a UV coordinate of 0,0 represents the lower left corner; 0,1 is the lower right corner; 1.0 is the upper left corner; and 1,1 is the upper right corner. Coordinates work differently in SVG. In SVG coordinates extend down and to the left. In addition, SVG uses actual measurements be they inches, pixels, ems or feet. So UV 0,0 would equate to SVG 0,11in (if inches was the defined measurement and you're using a 8x11 sheet of paper). This shift can be compensated for in the layout of the UV coordinates in Wings. See the attached screen shot taken in Wings. Note how the UV coordinates are positioned below the UV area (the area with the checkerboard pattern). This works, but it's a clumsy kludge. But for now….

The second issue is, of course, scale. The tank is modeled in actual size. The model is 24'1” long in Wings3d. But UVs don't care! When UV values are converted directly into SVG, suddenly the model is less than an inch long (if you're using inches in SVG). Woe betide the user who wants to work in pixels in SVG. Then my entire paper model ends up being less than 1 pixel in length. What scale is that, you ask? You'll have to find a real micro-modelor for that answer. You can of course rescale the images in Inkscape. That is, after all, the real benefit to using a vector format rather than a raster format.

So for now I simply multiply my UV coordinates by a factor of 500. I came up with that by trial and error. With the current layout of UV coordinates that gives me something close to an 8.5x11 graphic. Though I would like to be able to feed a scale factor into the script and have it automatically spit out SVG scaled to whatever size I called for. So I could model at 1:1 scale, but print out at 1:72 or 1:33 or whatever. To accomplish that, though, I think I may have to add an object into the model that corresponds to the bounding box of the model, e.g., for my tank it would be 24.1 feet long. Then, assign the object the maximum UV coordinates—so it will always extend from 0 to 1. That should then give me a reference which I could find in the model and scale accordingly. Hmmm… maybe it's too much work and I should just skip it… for now.

Anyhow, running the *.obj file through my script, I opened the resulting *.svg file in Inkscape. I added a layer (named 'exported shapes') and moved all the polygons to that layer. I then rearranged the groups to fit better on a 8.5x11 sheet of paper. I added a second layer (named 'labels') and added the text to identify the groups. A third layer was added (named 'fold lines'). This layer has some white dashed lines which overlay the red lines in the original outlines since I wanted to differentiate between fold lines and cut lines.

This is pretty crude but I'm new to Inkscape. I'm sure I have much to learn. First thing I noticed is that Inkscape *.svg files are not always rendered by other SVG viewers as complete. Whether that's an issue with Inkscape or the other viewers, I'm not quite certain. Consequently, I've uploaded the Inkscape *.pdf file rather than the *.svg file.

Attached are a screen shot showing the A7V UV coordinates as defined in Wings3d and a PDF file showing the final output after the editing in Inkscape.

I would greatly appreciate any feedback or test builds! Photos of how the shape fits together would simply make my day. I'm still without a usable printer for a while. Though I have to admit, I had cataract surgery yesterday and it has not curtailed my activities at all. I thought I'd spend a couple of days without being able to see clearly enough to work on this but that has not been the case at all.


--jeff (now turning down the verbosity mode)
Attached Thumbnails
Wings3d => ??? => *.svg -- a software/project log-a7v-3.jpg  
Attached Files
File Type: pdf a7v-20160902.pdf (22.8 KB, 22 views)
Reply With Quote
  #3  
Old 09-04-2016, 08:26 AM
Kugelfang's Avatar
Kugelfang Kugelfang is offline
Member
 
Join Date: Feb 2009
Location: Silver Spring, MD, USA
Posts: 280
Total Downloaded: 37.97 MB
My next test subject...

Here's a shot of my next test model, the DELAG Zeppelin LZ17 Sachsen. A bit more complicated geometry and a few more subassemblies. Since the graphics should be relatively simple I'd like to work this all the way to a finished model in Inkscape.

--jeff
Attached Thumbnails
Wings3d => ??? => *.svg -- a software/project log-lz17.jpg  
Reply With Quote
  #4  
Old 09-04-2016, 08:40 AM
John Bowden's Avatar
John Bowden John Bowden is offline
Eternal Member
 
Join Date: Jul 2007
Location: Madison, MS USA
Posts: 3,434
Total Downloaded: 223.07 MB
InkScape does allow saving in other SVG formats, have you tried the "Plain SVG" for your other SVG programs to render?
__________________
www.dgapapermodels.com

My Drawings
Reply With Quote
  #5  
Old 09-04-2016, 08:45 AM
John Bowden's Avatar
John Bowden John Bowden is offline
Eternal Member
 
Join Date: Jul 2007
Location: Madison, MS USA
Posts: 3,434
Total Downloaded: 223.07 MB
Looking at the formats InkScape does save to.. I noticed that it will save "Layers as Separate SVG (*.tar)" .......... I'm not sure if that will help with your other question about multiple pages........... of course this is version InkScape 0.91.

I also use InkScape 0.41 is why I added that last bit.
__________________
www.dgapapermodels.com

My Drawings
Reply With Quote
Google Adsense
  #6  
Old 09-06-2016, 08:30 AM
Kugelfang's Avatar
Kugelfang Kugelfang is offline
Member
 
Join Date: Feb 2009
Location: Silver Spring, MD, USA
Posts: 280
Total Downloaded: 37.97 MB
Thanks, John.

It didn't occur to me that Inkscape might be extending the SVG standard so it may include stuff that other renderers don't know anything about. There's a lot in Inkscape for me to explore.

--jeff
Reply With Quote
  #7  
Old 09-07-2016, 02:51 PM
Kugelfang's Avatar
Kugelfang Kugelfang is offline
Member
 
Join Date: Feb 2009
Location: Silver Spring, MD, USA
Posts: 280
Total Downloaded: 37.97 MB
I am chuffed!

Proof of concept. The workflow seems sound. This has gone through the complete Wings3d (modeling/unwrapping) => conversion script (*.obj to *.svg) => Inkscape (composition) => PDF.

There are some speed bumps in the process but I haven't found any show stoppers. Yet.

--jeff
Attached Files
File Type: pdf LZ-17_Sachsen.pdf (46.4 KB, 28 views)
Reply With Quote
  #8  
Old 09-07-2016, 06:50 PM
John Bowden's Avatar
John Bowden John Bowden is offline
Eternal Member
 
Join Date: Jul 2007
Location: Madison, MS USA
Posts: 3,434
Total Downloaded: 223.07 MB
Cool....... it created a vectored PDF. But each part is made up of several individual sections..........Are you going to to have to hand draw the parts to get usable outlines?
__________________
www.dgapapermodels.com

My Drawings
Reply With Quote
  #9  
Old 09-08-2016, 04:36 AM
Kugelfang's Avatar
Kugelfang Kugelfang is offline
Member
 
Join Date: Feb 2009
Location: Silver Spring, MD, USA
Posts: 280
Total Downloaded: 37.97 MB
What, eh?... all the parts should be grouped as single objects.

Oh... hmmm... I see. When Inkscape saves a layer as a *.pdf, it uses the layer as a group and seems to ignore the subgroups.

I'll look into it. I'd be surprised if Inkscape doesn't have a way to handle that and I just haven't found it yet.

Thanks,

--jeff
Reply With Quote
  #10  
Old 09-08-2016, 08:25 AM
John Bowden's Avatar
John Bowden John Bowden is offline
Eternal Member
 
Join Date: Jul 2007
Location: Madison, MS USA
Posts: 3,434
Total Downloaded: 223.07 MB
OK......... I think I figured out one way.........

Select all sections for a part........
Combine "Ctrl+K"
Union "Ctrl++"

this should get rid of all internal lines and leave just the outline of the part.........on the internal formers it will still leave the center circle.

I hope I've explained it where it is understandable
__________________
www.dgapapermodels.com

My Drawings

Last edited by John Bowden; 09-08-2016 at 08:35 AM.
Reply With Quote
Google Adsense
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 05:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)
Copyright © 2007-2023, PaperModelers.com