BricksViewer Part File Format

Overview

BricksViewer uses an XML file format to define part data. During the build process all .xml files in $BUILD_DIR/bricks/xml/ are loaded, have normals calculated, and are then serialized to $BUILD_DIR/build/bricks/ and given the ending .style. These serialized class files are then included in the bricksviewer.jar. During development of a part file, you may wish to make repeated changes to a part without rebuilding the jar. If the BricksViewer app doesn't find a given part in a serialized format in the jar file, it will look for an XML file in the same directory it was launched from. For additional details see the section on authoring a part file.

Sample Part XML

<shape id="MyPart" normalType="face">
<substyle id="SolidStud" offy="11.0" offx="8.0" offz="8.0"/>
...

<point id="0" x="-4.0" y="0.0" z="4.0"/>
...

<triangle v1="0" v2="20" v3="3"/>
...
</shape>

Elements of a Part File

shape
Attribute Description Required
id The unique identifier for this part. This must match the id used in the LFXML file for parts or the id in the substyle for substyles. Y
normalType How to calculate vertex normals for this part. Valid values:
  • face
  • vertex
face should be used for "flat" objects and vertex for "curved" objects. Default is vertex.
N
substyle
Attribute Description Required
id The unique identifier of the part to load. Y
offx The X offset of the subpart N
offy The Y offset of the subpart N
offz The Z offset of the subpart N
angle The angle of rotation in degrees N
ax The portion of the angle of rotation to apply to the x axis in the range 0.0-1.0 N
ay The portion of the angle of rotation to apply to the y axis in the range 0.0-1.0 N
az The portion of the angle of rotation to apply to the z axis in the range 0.0-1.0 N
point
Attribute Description Required
id The unique (to the file) identifier of the point. Y
x The X coordinate of the point Y
y The Y coordinate of the point Y
z The Z coordinate of the point Y
triangle
Attribute Description Required
v1 The first point of the triangle Y
v2 The second point of the triangle Y
v3 The third point of the triangle Y
normalType How to calculate vertex normals for this triangle. Valid values:
  • face
  • vertex
face should be used for "flat" objects and vertex for "curved" objects. Overrides normalType specified at shape level.
N

Authoring a Part File

Before starting the process of authoring a part file for inclusion in BricksViewer, please read the BSD license BricksViewer is distributed under and make sure you are comfortable with it.

Authoring a part file is a fairly straightforward process. For example, if you wish to add the part foo to BricksViewer, you would follow these steps:

  1. Create foo.xml in the directory BricksViewer is run from.
  2. Fill foo.xml in with a skeleton definition.
  3. Start BricksViewer and open an LXF scene file containing a foo brick.
  4. Add substyles, points, and triangles as needed to foo.xml.
  5. Select the "Flush Style Cache" menu item from the "Advanced" menu.
  6. Select the "Reload" menu item from the "File" menu.
  7. Repeat 4-6 as needed to accurately define foo.

Triangles must be defined counter clockwise to render correctly. If you are authoring a part file with the goal of having it included in in BricksViewer, please:

  1. Check CVS at SourceForge to make sure it hasn't been added since the last release.
  2. Check the Parts Forum at SourceForge to make sure no one else is working on the part.
  3. Post to the Parts Forum at SourceForge to announce your intent to build the part.
  4. Author your part file
  5. Submit the plain XML of your part file to the Patch Tracker at SourceForge under the category "New Part File"

If you are fixing an existing part file, please submit the changes in patch format to the Patch Tracker at SourceForge under the category "Existing Part File".


© 2005 bricksviewer team