Now that we know how to use Blender. We need a way to import out blender files into a Graphics project.

0. .blend Files

Blender can export to a few different file types. By default, Blender saves its files to the Blender(.blend) file format. However, that is not all Blender can do. Through Blender's export tools we can include Collada(.dae), Stanford(.ply), Stl(.stl), 3D Studio(.3ds), Autodesk FBX(.fbx), WaveFront Object(.obj), and X3D Extensible 3D(.x3d).

1. Importing Isn't Easy.

Although Blender has support for many different file formats, it does not have support for .m3d model formats. The reason behind this is .m3d is a custom format which Frank Luna wrote specifically for his book. Since it is a custom format, not to many programmers use (or care to use) it.

One good thing about .m3d is it is "human readable", meaning we can easily read it and know what is going on. This makes writing a converter to it much easier. However, .blend files are not human readable, so inorder to write a converter for them, they need to be converted into something that is common and human readable.

The standard Microsoft Direct X Model files (.x) are both human readable and common enough to have a .blend to .x converter already created. One of the better ones on the internet is one made by Alexander Gessler and can be found here: http://www.greentoken.de/onlineconv/.

Writing a converter from .x to .m3d can be a pain. So one has been provided for you.

2. Downloading And Running Our Converter

Download the converter: CS470_xtom3dconverter.jar and save it somewhere you can access it easily.

To run the converter, open the windows command prompt (go to all applications and find it there under Windows systems).

Navigate to the directory you saved the file in (using "cd" to switch directories).

run the command

java -jar CS470_xtom3dconverter.jar

This runs the converter.

3. How To Get .blend Files To .m3d

Create an object in Blender. (The provided camera and light source are not necessary, so be sure to delete them.)

Save the object as a .blend file somewhere you can easily find it.

Go to http://www.greentoken.de/onlineconv/ and click on the big, green outlined, Add File button.

Select your .blend file and click open. The file will appear on the screen. Click the grey arrow next to it so that it will be uploaded to the converter.

When the file is finished uploading, click Next in the bottom right corner.

The converter will supply you with a list of possible file format to convert to. Select the X format at the bottom of the list and click Next.

On the next page click the big, green outlined, Start button.

When it is finished, download the file and save it somewhere easily accessible later (saving it in the same place you have your converter saved makes navigating to it later much easier).

Now run CS470_xtom3dconverter.jar through the windows command prompt. You will be prompted to enter the location of your file. If the file is in the same directory as the converter, simply type yourfile.x and hit enter. If not, enter the path of your file and hit enter.

The converter will spit out your new file as yourfile.m3d in the directory it is in.

4. Using These Files in Your Own Program

We will be using Lab 5 to import the file into for now.

First off, copy your new .m3d file into C:\User\yourcomputername\documents\Visual Studio 2013\Projects\CS470_Lab05\CS470_Lab05\

Then, open your Lab 5 in Visual Studio. Note: importing will not work if you do not have Lab 5 already completed.

Open BasicMeshApp.cpp.

In the constructor, change cube.m3d to yourfile.m3d.

5. Compiling and running the program

Once you have completed typing in the code, you can build and run the program in one of two ways:

You should see your model appear in the window. Note: the provided converter does not have support for color or textures built in. Your model will appear white.

To quit the program simply close the window.

M3d files have support for animation. An updated converter and in code parser will be available later.