Clothing Editor Code
Status: Alpha
Brought to you by:
martinellison
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" /> <meta http-equiv="CONTENT-TYPE" content= "text/html; charset=us-ascii" /> <title>README</title> <meta name="CHANGEDBY" content="Martin" /> <style type="text/css"> /*<![CDATA[*/ <!-- @page { margin: 2cm } html, body {font-family: "Arial", sans-serif;} P { margin-bottom: 0.21cm ; } H1 { margin-bottom: 0.21cm; font-size: 16pt } H2 { margin-bottom: 0.21cm ; font-size: 14pt; font-style: italic} H3 { margin-bottom: 0.21cm ; font-size: 12pt; } --> /*]]>*/ </style> </head> <body lang="en-AU" dir="ltr" xml:lang="en-AU"> <p>This describes the clothing editor (ClothEd), a program for converting clothing patterns into three-dimensional meshes.</p> <p>The clothing editor (ClothEd) is a program for converting clothing patterns into three-dimensional meshes that can be input into a 3D modelling package such as Blender. It is about 6000 lines of Perl and it is basically a prototype: the core functionality is barely working and it needs improvement everywhere (code quality, functionality, stability). This README.html and the TODO.html file in the distribution are the only documentation.</p> <h1>INSTALLATION</h1> <h2>Prerequisites</h2> <ul> <li>Perl modules: <ul> <li>Carp</li> <li>Data::Dumper</li> <li>DBD::SQLite</li> <li>DBIx::Class (bundle)</li> <li>Getopt::Long</li> <li>Wx (bundle)</li> <li>XML::Twig</li> <li>and any dependencies they might have</li> </ul> </li> <li>Perl</li> <li>Inkscape</li> <li>Blender 2.5 or later</li> <li>WxGlade (only for development)</li> </ul> The code simply needs to be copied into an appropriate directory. <h1>USAGE</h1> <h2>Overall</h2> <ul> <li>Create clothing pattern as SVG file using Inkscape</li> <li>Import pattern into the Clothing Editor, fix up, and create mesh</li> <li>Import mesh into Blender and clean up</li> </ul> <h2>Create clothing pattern</h2> <ul> <li>Draw the clothing pattern as closed paths using a Scaled Vector Graphics (SVG) editor such as Inkscape.</li> <li>Only use straight lines. Using arcs, Bezier curves, or freehand will cause the Clothing editor to crash.</li> <li>Label each piece (in Inkscape, use Object/Object Properties).</li> </ul> <h2>Run clothing editor</h2> <h3>Create database and load it</h3> <ul> <li>Create a new 'database' by running ./mkgarment.sh name</li> <li>Open the editor using ./clothed.pl. Given the current state of the program, it is best to run it from a terminal so you can see the error messages when it crashes.</li> <li>Command line options to clothed are: <ul> <li>db - specify thye database file</li> <li>in - specify the input (SVG) file name</li> <li>out - specify the output mesh file</li> </ul> These are all optional as the files can be selected using the file pickers.</li> <li>Select the name of your 'database' using the file picker control.</li> <li>Select the name of your SVG file and Load the pattern. (Note: the SVG can be reloaded again later if you have modified it. Usually you do not want to 'discard everything'. If the reload crashes the clothing editor because you have deleted some pieces or some points, run sqlite3 path/to/yourdatabase.db <tidy.sql and then try again).</li> </ul> <h3>Position pieces in 3D world space</h3> <ul> <li>Using the list boxes, select the pieces of the pattern that you want to work on. Note that you can select two pieces, one on the left and one in the centre.</li> <li>On the right hand side, zoom the 3D view to larger and use the rotate and pan controls to see all the pieces of the pattern. Initially they will all be superimposed. These controls only affect the viewport and do not move the pattern around.</li> <li>Select the correct orientation for each piece by selecting it in the left hand panel and selecting the correct orientation. For example you might choose: <ul> <li>for a front piece, U -> +X and V -> +Y</li> <li>for a side piece, U -> +Z and V -> +Y</li> <li>for a top piece, U -> +X and V -> +Z</li> </ul> </li> <li>Look at the 3D view to see that the pieces have the correct alignments.</li> <li>Use the location sliders on the left to move the pieces into their approximate position in the 3D view. Rotate the 3D view as required to determine the correct relative positions. If you need to move a piece carefully relative to another, select the other piece in the centre panel and select 'show selecvted'; then only the two pieces will be displayed. If you select 'Show connected' it will show all pieces connected to the left hand piece.</li> </ul> <h3>Join pieces together and subdivide pieces</h3> <ul> <li>Select a point in the left or centre panels by clicking on it; it should be hightlighted in red.</li> <li>'Join' another point by control-clicking on it. It should become yellow. This will result in both points becoming one point in the eventual output mesh. There will also be a grey line connecting the two points in the 3D view.</li> <li>Extra points can be selected by shift-clicking on them. They will become pink.</li> <li>If two points are selected (ie one red and one pink), you can click on Connect and the piece will be divided into two. The number of intermediate points can be controlled by the edit box.</li> <li>If four pieces are selected, you can click on Rectangle and the mesh will be divided into rectangles. The number of rectangles can be controlled by the edit box.</li> </ul> <h3>Write out mesh</h3> <ul> <li>Finally, choose your mesh output file and click on Write. This will calculate for several minutes or longer, depending on the number of iterations selected. Unless a piece is marked 'stiff', it will be divided into quads or triangles before output. If a piece is marked 'hide', it will impact the 3D conversion process but not be output into the mesh.</li> </ul> <h2>Import into Blender</h2> <ul> <li>Open Blender, go to text editor, open add_clothes.py and run it. (Once only: this registers the operator. As Blender 2.5 is still under development, add_clothes.py might not compile in your version of Blender).</li> <li>Go to the 3D editor, select Add|Clothes from the menu and select the mesh file that you created in the Clothing Editor. This should import the mesh.</li> <li>Things you could do in Blender to tidy the mesh and make it fit a humanoid model: <ul> <li>go into edit mode (select all) and calculate normals outward.</li> <li>grab (move), scale and rotate the mesh to make it match your model.</li> <li>create a simple armature (a dozen bones or so), parent it to the clothes mesh, apply heat to create vertex groups, move the armature until the clothing mesh matches your model in rest position, then apply the modifier (so that the clothes now match the model).</li> <li>use the sculpt tool and other tools to move the clothes mesh into position (hopefully, you will not need to do this).</li> <li>use 'retopo' to fix the mesh structure.</li> <li>usual clothing things such as applying a cloth modifier and parenting the clothes mesh to an armature.</li> </ul> </li> </ul> <h2>Show dump utility</h2> <p>If the main clothing editor is run with the tracing option on, it will produce a file dump.txt. which can be read by the showdump.pl utitlty. This is not required for normal operation but can give some insight into what the clothing editor is doing.</p> <p>The dump output consists logically as a sequence of frames. The leftmost spin button can be used to page through these frames.</p> <p>If the show checkbox is turned on, one of the regions in the display is filled in. By paging through the second spin button, it is possible to show each region in turn.</p> </body> </html>