2. Material files Material files are for defining (additional) LDraw color information for use in both LD4DStudio previews and POV-Ray exports. There are two official material files located in the material folder, namely "official.xml" and "povray.xml". It is not recommended to edit these files. Instead create an additional one with your custom additions and / or changes. This is possible because LD4DStudio merges all material files whom you choose to load by way of inheritance. So if you define color 100 in a custom file it values will overwrite any existing definition of it made in files loaded before yours. The configuration dialog let you choose which files to load and in what order to do so. This way you have full control of your LDraw color configuration while still having a pretty good default in place out of the box. The generic structure is as follows:
<LD4DStudioMaterialFile> The materials block In the file the "Macros" element block is defined first. But for a better understanding of the whole, it is better if I explain the "Materials" block first. This block is started with the "Materials" element and encloses an unlimited number of "Material" elements. The "Materials" element has no attributes so lets concentrate on the huge list of attributes available for the "Material" element. Most attributes are POV-Ray specific and I'll go over them in fair limitation just to point out you can set those features from within the material files. So for their precise meaning I refer you to the excellent POV-Ray documentation on povray.org. The below table states all available attributes in the "Material" element, most of them are optional, if you leave them out the element the value in the second column will be used.
Above may be a lot to take on if you not familiar with POV-Ray materials. Therefore it might be a good idea to start reading the corresponding POV-Ray documentation first. The macros block In theory all you need is a "Material" block for every LDraw color number to get you going with correct colors in both LD4DStudio and POV-Ray exports. But in practice many attributes will be nearly the same for large groups of color numbers. Take for example number 0 through 15 all should be 'plain slightly reflective plastic', so wouldn't it be nice if you could manage the needed properties of all these 16 colors in one place? This can be done by using a "Macro" element in the "Macros" block above the "Materials" block. Within the Macro element you can use most of the attributes available for "Material" and assign them to a "Material" element using a single attribute, namely the mentioned "macro" attribute pointed out in above "Material" attributes table. A "Macro" element has all attributes used in "Material" element except for "macro", "overrides", "nr" and "descr". And in addition it has an "name" and "copyFrom" attribute. The first lets you define the name you want to use to refer to this "Macro" element from within a "Material" el element's "macro" attribute. For a better understanding of this open the povray.xml file in the material directory of your LD4DStudio installation. In it you'll find the "plastic" macro it defines all the attributes needed to get a nice plastic effect in POV-Ray. Now scroll down and you'll see the "Material" elements for color numbers 0 through 15 all have the attribute "macro" set to "plastic", therefor all these 16 colors will look like plastic in POV-Ray renderings. To make things even more dynamic the "Macro" element's "copyFrom" attribute let's you start a macro with a copy of the named previously defined macro. This is handy if two kinds of material are very simular like normal 'plastic' and 'transparent plastic'. So by using "copyFrom" for a generic transparent macro you'll only need to define the basic plastic material properties once. Like done in the "plasticTrans" macro in povray.xml Inheritance system You might also have noticed the "overrides" attribute in the povray.xml file "Material" definitions. This determines how previous set values are overwritten for this LDraw color number. For example: By default the official.xml file is loaded first to get basic RGB values for common LDraw colors as dictated by ldraw.org. But when the povray.xml file is loaded those values would be overwritten due to redefining existing color numbers. This off course is unwanted, because it would mean you'll have to specify the RGB values again in the povray.xml or all will be set to 0, 0, 0 making the information in official.xml useless. To prevent this, and thus creating a very dynamic material management, you can choose to only overwrite the POV-Ray specific properties for the chosen LDraw color. This way you can leave the RGB values upto LDraw.org/official.xml and concentrate only on things like reflection and normals in the povray.xml file. What to override is controlled by the "overrides" attribute in the "Material" element. Valid values for this attribute are:
Using custom material files When done creating a custom material file you must enable it by adding it to the matrial loading list controled in the configuration dialog. For details on this read the chapter on configuration in the manual. If you are an POV-Ray expert and think you have created better material for the common LDraw color numbers, feel free to contact me about modifing the default material files so everybody can enjoy even more realistic POV-Ray renderings. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Best viewed with Firefox 2, Seamonkey or IE 7 at 1024x768 or higher resolution. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright Roland Melkert 2008-2017, all rights reserved. LEGO is a registered trademark of the LEGO Group, which does not sponsor, endorse, or authorize this website. |