Thanks to Dennis Ippel
Many thanks to Dennis Ippel whose creation of the AS3 Blender exporter made my creation of the XML Exporter and XML Papervision Primitive possible (or at least infinitely easier). This is an iteration of his work. Essentially, I rewrote his Python AS3 Exporter to export XML from Blender and then created a Papervision XML Primitive which uses that XML. Links for the XML Exporter and Primitive are given in this article.
At first glimpse you might be wondering, why would you need an XML exporter for Blender and Papervision XML Primitive?
And there are actually two answers to this question. First, Blender doesn’t have a handy exporter for Papervision. It presently exports to Actionscript (to find out more check it out here ) So, creating an exporter that exports to XML gives you the ability to pick that XML up into an XML primitive. Presently, primitives are created mathematically in Papervision. By using an XML Primitive you can make any object in Blender and use it like a primitive in Papervision. Just by dropping its XML file (and image if textured) into Papervision.
The XML Primitive is simple; it just references the XML file and color or image (if textured) as shown below. All the properties of Papervision primitives apply to it such as translation, rotation, and scaling.
myWidget = new XMLPrimitive(“Widget.xml”, color or bitmap asset);
The second purpose is to create a mechanism for saving and using box models created in Papervision. That’s right you’re going to box model in Papervision.
Click on the image below to see the physics roller in action.
String Roller for Virtual Physics Lab
In the YouTube below, I demonstrate how to use the exporter and xml primitive and discuss how they were made.
YouTube Video – Development and How to Use
How it was made
How to use it
Demo 1 Widget with Color (no Texture)
Demo 2 Ship with Texture
Demo 1 Widget with Blender File (Flex and Flash Code)
Demo 2 Ship with Blender File (Flex and Flash Code)
This xml exporter/primitive was originally made to create widgets for a series of virtual physics experiments at NKU. Creating the widget above using the xml exporter has streamlined the process of making these widgets. There are two ways to create these primtives – textured and untextured.
Two Ways (Textured and Untextured)
Note: Presently the XML Primitive does not except shaded materials. Only untextured and textured primitives created in Blender are allowed.
There are two ways to get a XML primitives out of Blender – textured and untextured. Demo 1 above is the untextured way (but you can still give it a color using the color material) and demo 2 is the textured primitive. An example of a texture object is given below. And if you want to learn how to texture an object in Blender watch the following two videos.
UV Mapping (Texturing an object in Blender)
Part 1 – UV Mapping
Part 2 – UV Mapping
Following the procedure above you can create an object and put a texture on it for XMLExport. You can click the image below to see an animated example of and XML exported primitive. The image below shows a textured ship on the left and its texture map on the right.
Putting a Texture on a Ship
Important: But regardless of which XML primitive you use (textured or untextured) you must triangulate your object in edit model by pressing Ctrl+t or your objects will have triangular holes in them. An example of the XML generated by the XMLExporter is given below
Installing the Exporter/Primitve
Unzip the exporter/primitive found here
and place the XMLExport python file in the following scripts directory
- Windows: /Blender Foundation/Blender/.blender/scripts/ (Blender .2.46: C:\Documents and Settings\<username>\Application Data\Blender Foundation\Blender\.blender\scripts)
- Mac: /Applications/blender/blender.app/Contents/MacOS/.blender/scripts/
then place the XMLPrimitive in the primitive Papervision folder found in the following directory
and that’s it. You are now ready to make an XML Primitive in Blender. Just reference this exported file in your XMLPrimitive as show below and add a color or bitmap depending on if your Primitive is textured or not.
//Use a color for an untextured primitive
var paper2:ColorMaterial = new ColorMaterial(0xFFFF00,1,false);
paper2.doubleSided = true;
//Use a bitmap for an textured primitive
//Reference the XML generated file and your texture or color
mcylinder = new XMLPrimitive(“Widget.xml”,paper2);
An example of the type of export code you will be seeing is given below.
The XML generated for this primitive is shown below;
<?xml version=’1.0′ encoding=’utf-8′?>
To see the code for the Python exporter or XML Primitive click the more button below;
Read the rest of this entry »