<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>anoved.net &#187; prel3p</title>
	<atom:link href="http://anoved.net/tag/prel3p/feed/" rel="self" type="application/rss+xml" />
	<link>http://anoved.net</link>
	<description></description>
	<lastBuildDate>Sun, 13 May 2012 18:44:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Instruction Step Fading with PreL3P</title>
		<link>http://anoved.net/2007/10/instruction-step-fading-with-prel3p/</link>
		<comments>http://anoved.net/2007/10/instruction-step-fading-with-prel3p/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 20:07:00 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[l3p]]></category>
		<category><![CDATA[LDraw]]></category>
		<category><![CDATA[LEGO]]></category>
		<category><![CDATA[prel3p]]></category>
		<category><![CDATA[tcl]]></category>

		<guid isPermaLink="false">http://anoved.net/2007/10/instruction-step-fading-with-prel3p/</guid>
		<description><![CDATA[By substituting different colors in different parts of a model, PreL3P can be used to create interesting effects such as the step-by-step highlighting seen here: This page explains how this image was created. It is intended as a demonstration of what can be done with PreL3P, but other relevant topics are discussed. Windows users may [...]]]></description>
			<content:encoded><![CDATA[<p>By substituting different colors in different parts of a model, <a href="http://anoved.net/2007/10/prel3p/">PreL3P</a> can be used to create interesting effects such as the step-by-step highlighting seen here:</p>
<p><a href="http://flickr.com/photos/anoved/sets/72157602494240516/"><img src="http://anoved.net/files/prel3p/steps.png" width="632" height="432" alt="how to build a silly little doghouse" /></a></p>
<p>This page explains how this image was created. It is intended as a demonstration of what can be done with PreL3P, but other relevant topics are discussed. Windows users may be interested in <a href="http://lpub.sourceforge.net/">LPub</a> as a more convenient solution.</p>
<h3>Color Preparation</h3>
<p>Two sets of color code definitions are needed to achieve this effect. A set of modified colors is used first to give parts from previous steps a faded appearance. Then a set of normal colors is loaded to give new parts their vivid hue.</p>
<p>Here are the <a href="http://anoved.net/files/prel3p/normal.ldr">normal colors</a> from <a href="http://www.ldraw.org/library/official/ldconfig.ldr"><code>ldconfig.ldr</code></a> used to draw the current step and the final image: </p>
<pre><code>0 normal.ldr
0 !COLOUR Green  CODE  2 VALUE #008C14 EDGE 0
0 !COLOUR Red    CODE  4 VALUE #C40026 EDGE 0
0 !COLOUR Yellow CODE 14 VALUE #FFDC00 EDGE 0
</code></pre>
<p>I used <a href="http://wafflesoftware.net/hexpicker/">Hex Color Picker</a> along with the standard <a href="http://en.wikipedia.org/wiki/HSL_color_space">HSB</a> saturation slider to choose faded versions of these colors. You can use the color picker from any application to do this.</p>
<p><a href="http://anoved.net/files/prel3p/desat-in.png"><img src="http://anoved.net/files/prel3p/desat-in-small.png" width="127" height="159" alt="input the normal hex color" /></a> <a href="http://anoved.net/files/prel3p/desat-set.png"><img src="http://anoved.net/files/prel3p/desat-set-small.png" width="127" height="159" alt="reduce saturation to 50%" /></a> <a href="http://anoved.net/files/prel3p/desat-out.png"><img src="http://anoved.net/files/prel3p/desat-out-small.png" width="127" height="159" alt="output the desaturated hex color" /></a></p>
<p>Of course, this approach is not practical for converting large numbers of colors. You&#8217;ll have to devise your own system for selecting and generating suitable substitute colors.</p>
<p>Here are the <a href="http://anoved.net/files/prel3p/faded.ldr">faded colors</a> used for parts from previous steps:</p>
<pre><code>0 faded.ldr
0 !COLOUR Green  CODE  2 VALUE #598952 EDGE 0
0 !COLOUR Red    CODE  4 VALUE #B26676 EDGE 0
0 !COLOUR Yellow CODE 14 VALUE #FBEC87 EDGE 0
</code></pre>
<h3>Steps</h3>
<p>The <a href="http://www.ldraw.org/Article218.html#step"><code>STEP</code></a> meta command marks the end of each instruction step in an LDraw model. For example, here are the first three steps of the <a href="http://anoved.net/files/prel3p/doghouse.ldr">doghouse model</a> pictured above:</p>
<pre><code>1 2 0 0 0 1 0 0 0 1 0 0 0 1 41539.dat
0 STEP
1 14 50 -24 30 -1 0 0 0 1 0 0 0 -1 3005.dat
1 14 50 -24 -30 -1 0 0 0 1 0 0 0 -1 3005.dat
1 14 -50 -24 0 0 0 -1 0 1 0 1 0 0 3010.dat
0 STEP
1 14 0 -24 50 1 0 0 0 1 0 0 0 1 3009.dat
1 14 0 -24 -50 1 0 0 0 1 0 0 0 1 3009.dat
0 STEP
</code></pre>
<p>Most LDraw editors make it easy to create and organize steps. For instance, steps are always shown as part of the model hierarchy in Bricksmith&#8217;s &#8220;File Contents&#8221; drawer:</p>
<p><img src="http://anoved.net/files/prel3p/steps-in-bricksmith.png" width="216" height="189" alt="Steps in Bricksmith" /></p>
<p>Once a model is complete, its constituent steps can be exported as a series of individual files that represent the model up to that point. In other words, each exported step model is essentially identical to the original model except that it is truncated after the corresponding step.</p>
<p>Rendering each of these partial models produces an image depicting each step in the instructions.</p>
<h3>PreL3P Meta Commands</h3>
<p>Before proceeding to render the step models, PreL3P meta commands are inserted at the beginning of the file and at the beginning of the most recent step to invoke the appropriate color substitution schemes. The <code>-ldconfig</code> option is used to load the <code>faded.ldr</code> and <code>normal.ldr</code> files prepared above. (PreL3P supports the notion of &#8220;LDraw configuration files&#8221;&mdash;files containing pertinent meta commands; if present, any visible <a href="http://www.ldraw.org/Article218.html#linetypes">linetypes</a> are ignored.)</p>
<p>By default, PreL3P does not modify the basic color codes understood by L3P. To accomplish step fading, however, it may be necessary to do so. The <code>+codes</code> option tells PreL3P which color codes should be kept in their original form. The special parameter <code>none</code> causes all codes to be converted.</p>
<p>Here is the third step model with meta commands inserted:</p>
<pre><code>0 !PREL3P +codes none
0 !PREL3P -ldconfig faded.ldr
1 2 0 0 0 1 0 0 0 1 0 0 0 1 41539.dat
0 STEP
1 14 50 -24 30 -1 0 0 0 1 0 0 0 -1 3005.dat
1 14 50 -24 -30 -1 0 0 0 1 0 0 0 -1 3005.dat
1 14 -50 -24 0 0 0 -1 0 1 0 1 0 0 3010.dat
0 STEP
0 !PREL3P -ldconfig normal.ldr
1 14 0 -24 50 1 0 0 0 1 0 0 0 1 3009.dat
1 14 0 -24 -50 1 0 0 0 1 0 0 0 1 3009.dat
</code></pre>
<p>For each successive step the <code>-ldconfig normal.ldr</code> line should be inserted later in the file. If your editor includes the <code>STEP</code> lines in exported step models, it is fairly easy to locate the beginning of the last step. The correct location can also be found by comparing each step model file to the previous step&#8217;s file; the new step starts where the files differ. This is the method used by Travis Cobbs&#8217; <a href="http://news.lugnet.com/cad/?n=14921">shell script</a>.</p>
<p>The first step is a special case since there are no previous steps that need to be faded. You may be able to render it without modification. For consistency, however, you could load the standard color set at the beginning of the file:</p>
<pre><code>0 !PREL3P +codes none
0 !PREL3P -ldconfig normal.ldr
1 2 0 0 0 1 0 0 0 1 0 0 0 1 41539.dat
</code></pre>
<p>Note that the preparations are slightly more complex for <a href="http://ldraw.org/Article47.html">MPD files</a>. Another <code>-ldconfig faded.ldr</code> command would be needed at the end of the main model to draw submodels from previous steps in the faded colors. Any submodels included in the current step would need to use <code>normal.ldr</code> again. Submodels referenced by the previous step and the current step present a challenge that is left as an exercise for the reader.</p>
<h3>Running PreL3P</h3>
<p>Once the meta commands have been inserted, the step models can be processed with PreL3P. This replaces the original color codes with hexadecimal values that represent the exact shades defined in the color configuration files.</p>
<pre><code>prel3p -in doghouse3.ldr -out doghouse3-faded.ldr
</code></pre>
<h3>Rendering</h3>
<p>Finally the faded step models are ready to be rendered. PreL3P&#8217;s name is a bit of a misnomer; the output works just as well with <a href="http://ldview.sourceforge.net/">LDView</a> (note, however, that these hexadecimal colors do not conform to the LDraw format specification, so don&#8217;t expect them to work with all LDraw software).</p>
<p>Currently, it is easiest to render a batch of images from the command line. If you save a bunch of command lines to a file named <code>render</code>, you can run them all with <code>sh render</code> (other automation methods may be forthcoming). Here&#8217;s what one command looks like:</p>
<pre><code>ldview doghouse3.ldr -SaveSnapshot=doghouse03.png -AutoCrop=0 -SaveZoomToFit=0 -WindowWidth=1024 -WindowHeight=1024 -SaveActualSize=1 -cg30,45 -ModelCenter=0.0,-50,0.0 -ModelSize=250
</code></pre>
<p>With LDView 3.2 on Mac OS X, you might need to expand <code>ldview</code> to <code>/Applications/LDView/LDView.App/Contents/MacOS/LDView</code>. Only the first two arguments need to be changed from step to step; the rest specify the size of the output image and ensure that each image will be rendered at the same scale. I&#8217;m not particularly familiar with LDView&#8217;s command line syntax, so more succinct options may be possible.</p>
<p>Briefly, the <code>-cg</code> option specifies the &#8220;latitude and longitude&#8221; of the camera on a globe whose origin is specified in LDraw units by the <code>-ModelCenter</code> option. The <code>-ModelSize</code> option controls the distance from the camera to the center of the model. These options work together to ensure the same perspective is used to depict each step. Otherwise, the different dimensions of the individual steps might result in inconsistent default camera positions.</p>
]]></content:encoded>
			<wfw:commentRss>http://anoved.net/2007/10/instruction-step-fading-with-prel3p/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PreL3P</title>
		<link>http://anoved.net/2007/10/prel3p/</link>
		<comments>http://anoved.net/2007/10/prel3p/#comments</comments>
		<pubDate>Sat, 06 Oct 2007 23:52:00 +0000</pubDate>
		<dc:creator>Jim</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[l3p]]></category>
		<category><![CDATA[LDraw]]></category>
		<category><![CDATA[LEGO]]></category>
		<category><![CDATA[prel3p]]></category>
		<category><![CDATA[tcl]]></category>

		<guid isPermaLink="false">http://anoved.net/2007/10/prel3p/</guid>
		<description><![CDATA[PreL3P preprocesses LDraw files for color compatibility with L3P, which converts LDraw models to POV-Ray format. The current version of L3P (1.3) only knows about some color codes, but it does support arbitrary colors via an extended color syntax. PreL3P replaces LDraw color codes unrecognized by L3P with hexadecimal “extended color” specifications based on the [...]]]></description>
			<content:encoded><![CDATA[<p>PreL3P preprocesses LDraw files for color compatibility with <a href="http://www.hassings.dk/l3/l3p.html">L3P</a>, which converts LDraw models to <a href="http://www.povray.org/">POV-Ray</a> format. The current version of L3P (1.3) only knows about <a href="http://news.lugnet.com/cad/?n=14563">some color codes</a>, but it does support arbitrary colors via an <a href="http://www.hassings.dk/l3/l3p.html#extcol">extended color</a> syntax. PreL3P replaces LDraw color codes unrecognized by L3P with hexadecimal “extended color” specifications based on the <a href="http://www.ldraw.org/Article299.html"><code>COLOUR</code> definitions</a> provided by your <a href="http://www.ldraw.org/library/official/ldconfig.ldr">LDraw configuration file</a>. No special material tags are honored besides <code>ALPHA 128</code> (regular transparency). Color codes can also be mapped directly to other color codes.</p>
<p>PreL3P is a hack to allow models containing contemporary colors to be rendered with L3P and POV-Ray without touching any POV-Ray code. It is not intended to replace other, more expert, solutions to the color quandary; better results can arguably be had by manually including custom POV-Ray color definitions. Ideally, L3P and other programs like Bricksmith would support <code>ldconfig.ldr</code> themselves.</p>
<h3>Usage</h3>
<pre><code>prel3p # Default: [-in FILE] # stdin [-out FILE] # stdout [-ldconfig FILE] # LDRAWDIR/ldconfig.ldr [+codes none|l3p|CODE[,...]] # l3p (keep codes known by L3P) [-codes none|l3p|CODE[,...]] # none (preprocess all others) [-map IN:OUT] # no mappings [-flag quiet] # not quiet (report completion) [-flag noglob] # glob expansion supported [FILE[,...]] # none (see Alternate Usage) </code></pre>
<p>Explicit option values override the defaults.</p>
<p>PreL3P can be used as a filter:</p>
<pre><code>prel3p &lt; input.ldr &gt; output.ldr </code></pre>
<p>Output is not written until the input has been successfully parsed and processed, so files can be preprocessed in place:</p>
<pre><code>prel3p -in model.ldr -out model.ldr </code></pre>
<p>The <code>codes</code> options permit custom substitution schemes to be specified. The <code>+</code> and <code>-</code> characters represent color codes which should be preserved and color codes which may be replaced, respectively.</p>
<pre><code>prel3p +codes 0 # replace any code other than 0 (black) prel3p -codes 0,71,72 # replace codes 0, 71, and 72, but no others prel3p +codes l3p -codes 4 # preserve color codes known to L3P, except 4 prel3p +codes none # replace every color code (preserve none) </code></pre>
<p>Unspecified codes are handled according to the behavior implied by the type of the first <code>codes</code> option. <code>+codes</code> implies that other codes may be replaced; <code>-codes</code> implies that other codes should be preserved. Subsequent options of either type modify the initial set.</p>
<p>Color codes can be renumbered with the <code>-map</code> option. For instance, to replace instances of color code <code>7</code> with color <code>8</code>, specify <code>-map 7:8</code>. Mapping occurs before substitution, so if <code>-codes 8</code> is also specified and a <code>!COLOUR</code> definition for <code>8</code> is found, instances of <code>7</code> will ultimately be replaced by the hexadecimal equivalent of <code>8</code>.</p>
<p>A message reporting how many colors were changed and how many lines contained changes is printed when processing is complete. Mappings and color substitutions both constitute color changes.</p>
<p>Color definitions are normally read from <code>LDRAWDIR/ldconfig.ldr</code> (<code>LDRAWDIR</code> is an environment variable assumed to contain the path to your LDraw directory). Different configuration files may be specified with the <code>-ldconfig</code> option. Multiple <code>-ldconfig</code> options may be given, in which case the last of multiple definitions for the same color code takes precedence.</p>
<p>With the exception of color codes, PreL3P’s output is identical to its input. Whitespace, capitalization, and decimal precision are not modified. Unrecognized lines are preserved, as are unrecognized color codes (those not identified by the <code>ldconfig</code> file).</p>
<h4>Alternate Usage</h4>
<p>If no <code>-in</code> or <code>-out</code> arguments are specified, PreL3P will interpret unrecognized arguments as paths to files to process.</p>
<pre><code>prel3p model.ldr </code></pre>
<p>The original <code>model.ldr</code> is copied to <code>model.ldr.bak</code> and the processed version is saved in place as <code>model.ldr</code>.</p>
<p>In this context PreL3P understands glob <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/glob.htm#M12">wildcard characters</a>. For instance, in a directory containing only the files <code>model1.ldr</code>, <code>model2.ldr</code>, and <code>model3.ldr</code>, the following commands are equivalent:</p>
<pre><code>prel3p model*.ldr prel3p model?.ldr prel3p model[1-3].ldr prel3p model{1,2,3}.ldr prel3p model1.ldr model2.ldr model3.ldr </code></pre>
<p>This feature is intended primarily as a convenience for Windows command prompt users since this functionality is typically provided by the command line shell itself on other platforms (unless the argument is quoted). Wildcard expansion can be disabled with the <code>-flag noglob</code> option.</p>
<h4>Meta Commands</h4>
<p>In addition to the <code>!COLOUR</code> meta command, PreL3P understands unofficial meta commands which allow certain PreL3P command line options to be imbedded in models and configuration files.</p>
<p>The general form of these meta commands is:</p>
<pre><code>0 !PREL3P OPTION VALUE </code></pre>
<p>where <code>OPTION</code> is one of <code>-ldconfig</code>, <code>+codes</code>, <code>-codes</code>, or <code>-map</code> and <code>VALUE</code> is formatted as the analogous command line parameter.</p>
<p>Options and <code>!COLOUR</code> definitions are read from the input model header after command line options are parsed. The model header is comprised of all input lines preceding the first instance of any LDraw type <code>1</code> through <code>5</code> lines. Configuration files specified by <code>-ldconfig</code> options in the model header are appended to the configuration file queue and override the default <code>-ldconfig</code> if no explicit value is given on the command line.</p>
<p>Configuration files are parsed sequentially after reading the model header. The entire configuration file is read; LDraw type <code>1</code> through <code>5</code> lines are ignored. Additional configuration files specified by <code>-ldconfig</code> meta commands within configuration files are parsed at the point they are encountered.</p>
<p>PreL3P meta commands in the model that are not in the model header are parsed and applied as they are encountered during processing. This allows different color substitution schemes to be used for different parts of the model.</p>
<h3>Example</h3>
<p>Here is a simple LDraw file, <code>bricks.ldr</code>. It uses color codes <code>89</code> (Royal Blue), <code>92</code> (Flesh), and <code>72</code> (Dark Stone Gray).</p>
<pre><code>1 89 0 0 -20 1 0 0 0 1 0 0 0 1 3005.dat 1 92 0 0 0 1 0 0 0 1 0 0 0 1 3005.dat 1 72 0 0 20 1 0 0 0 1 0 0 0 1 3005.dat </code></pre>
<p>L3P doesn’t recognize these color codes, so it replaces them with the default color <code>7</code> (Gray). As a result, the initial rendering looks like this:</p>
<p><img style="border: 0;" src="http://anoved.net/files/prel3p/bricks.png" alt="L3P substitutes default gray for unknown colors" width="168" height="146" /></p>
<p>So, let’s use PreL3P to make a copy of the model with colors L3P can understand:</p>
<pre><code>prel3p -in bricks.ldr -out prebricks.ldr </code></pre>
<p>The contents of <code>prebricks.ldr</code>:</p>
<pre><code>1 0x029BB2EF 0 0 -20 1 0 0 0 1 0 0 0 1 3005.dat 1 0x02CC8E68 0 0 0 1 0 0 0 1 0 0 0 1 3005.dat 1 0x02635F61 0 0 20 1 0 0 0 1 0 0 0 1 3005.dat </code></pre>
<p>L3P converts this version of the model without complaint, and the final rendering looks like this:</p>
<p><img style="border: 0;" src="http://anoved.net/files/prel3p/prebricks.png" alt="Correct colors" width="168" height="146" /></p>
<h3>Changes</h3>
<p>1.1:</p>
<ul>
<li>Added “done” announcement and statistics with complementary <code>-flag quiet</code> option.</li>
<li>Multiple <code>-ldconfig FILE</code> option pairs may be given.</li>
<li>Added alternate usage syntax.</li>
</ul>
<p>1.2:</p>
<ul>
<li>Added <code>-map</code> option to convert color codes directly to other codes.</li>
<li>Added <code>!PREL3P</code> meta command versions of <code>-ldconfig</code>, <code>+code</code>, <code>-codes</code>, and <code>-map</code>.</li>
<li>Added <code>-help</code> option to display brief usage summary.</li>
<li>Tweaked alternate usage backup mechanism.</li>
</ul>
<p>1.3:</p>
<ul>
<li>Meta commands may be used throughout models.</li>
</ul>
<p>1.3.1:</p>
<ul>
<li>Properly report a few errors.</li>
<li>Limit number of <code>-ldconfig</code> references to prevent circular references.</li>
</ul>
<p>1.4:</p>
<ul>
<li>Added ability to process multiple files</li>
<li>Added support for wildcard characters</li>
</ul>
<h3>Download</h3>
<ul>
<li><a href="http://anoved.net/files/prel3p/prel3p-1.4-kit.zip"><strong>prel3p-1.4-kit.zip</strong></a> 14 KB<br />
Platform independent Starkit. Requires a separate <a href="http://www.equi4.com/pub/tk/downloads.html">Tclkit</a> (8.4.16 recommended).</li>
<li><a href="http://anoved.net/files/prel3p/prel3p-1.4-mac.zip"><strong>prel3p-1.4-mac.zip</strong></a> 1.9 MB<br />
Self-contained universal binary (x86 + PPC) for Mac OS X 10.4+.</li>
<li><a href="http://anoved.net/files/prel3p/prel3p-1.4-mac-service.zip"><strong>prel3p-1.4-mac-service.zip</strong></a> 2 MB<br />
Macintosh Starpack bundled as a service for filtering selected text. Install in <code>~/Library/Services/</code>.</li>
<li><a href="http://anoved.net/files/prel3p/prel3p-1.4-win.zip"><strong>prel3p-1.4-win.zip</strong></a> 559 KB<br />
Self-contained console binary for Windows.</li>
</ul>
<p>The source code may be extracted from any version with <a href="http://www.equi4.com/starkit/sdx.html">SDX</a>. An example localization file is available <a href="http://anoved.net/files/prel3p/en_us_example.msg">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://anoved.net/2007/10/prel3p/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

