A Tool for Converting 2D Topographical Maps to 3D Models

Top2maya – A Tool for
Converting 2D Topographical
Maps to 3D Models
Rob Gillespie
Student Consultant
Date Issued: May 2002
(Updated May 6, 2002)
The Beckman Institute
Imaging Technology Group
Technical Report 01-008
Copyright © 2001 Board of Trustees of the University of Illinois
The Beckman Institute for Advanced Science and Technology
Imaging Technology Group
405 N Mathews
Urbana, IL 61801
[email protected]
http://www.itg.uiuc.edu
Top2maya – A Tool for Converting 2D Topographical Maps to 3D
Models.
Rob Gillespie
Consultant
Visualization, Media and Imaging Laboratory
[email protected]
Top2maya is a program written in MEL script which changes 2D topographical maps
into three-dimensional models and images. This script does this by changing an image
into grayscale, then displacing the pixels according to their intensity value. White gets
displaced the most on the y-axis, while black does not get displaced at all. The resulting
models make it easy to visualize the surface, while the rendered images are suitable for
presentation and/or publication. Top2maya is especially useful for transforming data
from the AFM, NSOM and confocal microscopes.
Getting Data Ready for Use With top2maya
This script needs the data image to be an RGB TIFF. If you have any other format it will
need to be converted to an RGB TIFF using Adobe Photoshop. NOTE: All TIFFs are not
RGB TIFFs. The Digital Instrument’s AFM software in the Microscopy Suite uses
indexed-color TIFFs. This must be changed. To make sure your data is in the proper
format, first open the image in Photoshop. You can then crop it if needed to make sure
you only get the part of the image you want. Once the image is ready, go to Image ->
Mode and make sure there is a check mark next to RGB color. Once this is set, go to File
-> Save as… and set the image type to TIFF. Your data should now be ready for use with
top2maya.
Running Maya:
Maya is currently installed on Pollock, Hofmann, Iannis, Arbus and Krasner in the
VMIL. To start the program, go to Start Menu -> Quickfind -> Maya. Once the program
is running, you will need to do some initial setup.
Maya Interface Window
Fixing the Spotlight Problem (First Time Users Only):
If you have never run Maya before, you will have to manually create a spot light. The
lighting portion of top2maya will not work and the rendered scenes will appear dark if
you have not created a spotlight at least once in your Maya profile. You can do this with
the pull down window at the top of the screen by going to Create->Lights->Spot Light.
Again, once you have done this once you will never need to do it again. Once this is all
done, you can save your preferences by going to File->Save Preferences or it will
automatically be saved when you quit Maya.
Running top2maya:
Near the top of the Maya window, there is a row of larger icons. This is called the shelf.
On this there should be an icon labeled T2M. If you do not see this left-click on the folder
icon next to these large icons and select the ITG shelf. Next, click on the T2M icon. This
will launch the script. Note that running the top2maya will DELETE everything in the
scene. As a precaution, it will prompt you before this is done. If you have any work done
in the scene, make sure to save it before running the script. For more information on how
to manually add a shelf button, see the section entitles, “Manually Adding top2maya to
the Shelf” at the end of this report.
Parameters in top2maya:
There are several parameters in top2maya which can be set. They are as follows:
Image Path: This is the path of the image you are going to change into a 3D
model. If nothing is entered in the next field it is also the image used to color the
new model. When typing in the image path, use the forward slash ‘/’, not the
backslash ‘\’ for the path. Maya does not recognize the backslash and the model
will not work properly if you use it.
Enter Path to Map a Different File for Shading: If you would like to generate
the model with one topographical map and then shade, or color it, with a different
image, you can enter the path of that image here. It must be in the same format as
previously discussed in the Getting Data Ready for Use With Top2maya section.
By doing this you can visualize multiple properties on one model.
Lights Checkbox: Make sure this is checked if you would like lights in your
scene. Without lights your output will be black. The only reason this should be
unchecked is if you want to do your own lighting design.
Animate Checkbox: Check this to set up an animated sequence to show off the
model. This animation rotates the model 360 degrees then towards the end tilts it
up and holds. Even if you are not going to use an animation it is recommended to
use this option in order to set up the camera to bring the model into the proper
scale.
Width, Depth and Height:
These defaults should work well for any square image coming from the atomic
force microscopes. On the other hand, if you have exact measurements, or ratios,
for the width, depth and height, you can enter them here. This will allow you to
keep the visual representation of your data as exact as possible if that kind of
precision is needed.
Stereo Rendering Options:
If you would like to render out images for three-dimensional viewing with the
crystal-eyes glasses, you can choose one of these options. None sets up the basic
script with no stereo image options. The stereo animation radio button will render
out a comparable stereo image to the basic animation. That is, you must first
render out with no stereo options, then render the animation again with the stereo
animation option selected. This sets up a stereo view, which can be put into
Entomon. Entomon is a program written by Daniel Weber which sets up 3D
images and animations using crystal-eyes glasses. For more information on
Entomon, talk to Daniel Weber. The third option, also requiring Entomon, is the
stereo still option. When this is checked and the script is run, a second window
will pop up complete with instructions. You must first position the camera on the
image you would like to see in stereo. Once this is done, that image must be
rendered. After the render, press the complete button on the stereo still window.
This will position the camera in a new position dependent on the distance away
from the center of the object. At this point a second image must be rendered out.
These images can then be put into Entomon. Again, for help with stereo imaging,
email Daniel Weber at ([email protected]).
Tessellation U and V: These are the tessellation numbers in the U and V
directions. This says how many polygons are going to be set up across the height
and width of each grid unit. The default values should get all the detail out of
almost any image. If you have a very large image or a very rough surface you
may need to raise these values. The best method for determining these values is
trial and error.
Grid Units U and V: This is how many units the grid is divided into. These can
be raised instead of or in addition to the tessellation values to increase accuracy.
The defaults are set to accommodate most data types.
Displace Geometry: Once you have all the fields set, click this button to make
the 3D model.
Export Options and Manipulating Maya:
You can either export an animation or a single frame. If you want to export an animation,
you can skip this section and go straight to Setting Up for Export.
To export a frame you will first need to set up the view you wish to export. To get the
proper size proportions, you should first go to View -> Camera Settings -> Resolution
Gate. This is in the window pull down menus, not the main menus on the top. This will
set up a resolution gate showing you the size of the area actually being rendered. You can
now position the model within the box. In order to position the model properly, there are
several movement functions you will need to know. To move around in the window you
have 3 functions:
Alt-Left Mouse Button – Orbit
Alt-Middle Mouse Button – Pan
Alt-Left and Middle Mouse Button – Zoom
By holding down the Alt key and doing these button combinations you can orbit around,
center and zoom in on your model to get the proper orientation. Another variable you
may wish to adjust is the height scaling of the model. To do this, you first need to click
on the model to select it. Once selected the wireframe of the model should be highlighted
in green. In the channel box on the right side of the screen under
nurbsPlane1_displacement1 there is an
attribute titled scale Y which is set to 0.13.
By raising or lowering this value you can
change the height, or maximum
displacement, of the model.
General Export Settings (Frame and
Animation):
You are now ready to set up your export
options. Choose Window -> Render
Globals… to open a dialog box. In the
Image File Output section, set the File
Name Prefix to what you would like the
images to be titled. Do not use spaces in the file name. Under the Image File Output
section you can also set the Image Format. This can be whatever file type you would like
your output to be, ie. TIFF, JPG, IFF, YUV, etc. In the Image File Output section you
must also set the Camera field to Camera1. This will make sure you are exporting what
you are looking at.
Next open up the Resolution section by clicking on the arrow. Pick the resolution you
would like your image to be rendered at (ie. 320x240, 640x480, etc.) Finally open up the
Anti-Aliasing Quality section. Here you can set the quality of your render. For good
quality it is recommended to set the Presents field to Production Quality.
Setting Up to Export a Single Frame:
If you would like to export a single frame, close this window and continue on to the
Rendering section of this document.
Setting Up to Export an Animation:
To set up to render an animation you need to change a few more fields in the Window ->
Render Globals… dialog box. In the File Output section you will need to set the
Frame/Animation Ext option to name.#.ext for Windows NT or name.ext.# on an SGI.
You will also need to change the End Frame property to 135. Everything should now be
set up to render your animation. Continue on to the Rendering Section of this document.
Setting Up for Export to the ACCOM to Print to Video:
To send to the ACCOM, you will need the Image Format property in the File Output
section in Render Globals to Quantel (YUV). You will also need to open the Resolution
section and set the Width field to 720 and the Height field to 486. Once rendered out, see
the documentation at http://www.itg.uiuc.edu/help/accom/ This will take you through the
rest of the steps needed to put your frames or animation onto video.
Rendering:
To render out your frames or animation you will need to make sure you are in the
Rendering Menu set. This can be selected in the pull down dialog box at the top left side
of the screen under the Edit and File menus. Make sure it says Rendering in this box.
Next go to Render -> Save (Batch) Render. This will open up a browser. Type in a file to
save the animation scene at. The animation scene is not your actual rendered images, but
a Maya Binary scene file. When done, press the Save/Render button. Your image(s) are
now being rendered out. If you are rendering a lot of images at a high resolution this
could take some time. To follow the progress of the rendering you can go to Window ->
General Editors -> Script Editor and the progress will be displayed in the window. Your
images will be saved into the project you set earlier in a folder called “images.”
Viewing the Final Output:
Depending on your image format, there may be several ways to view your output. If you
have just single images in a TIFF or JPG format you can view them in any imaging
software such as Adobe Photoshop. If you are using a not so common image format, for
example YUV or the Maya default IFF file type you will need to use Fcheck. You can
start this by running it in Start menu -> Quickfind -> Fcheck. Fcheck can be used to view
animations or images. To view an image go to File -> Open Image… and then select the
image you wish to view from the browser. To view an animation go to File -> Open
Animation… and select the first frame in the animation. This first time through the
animation will be slow and choppy as everything is being loaded into memory. Once the
first pass is done it should speed up considerably. For further help on manipulating
animations in Fcheck, open Help -> Animation Controls in the Fcheck program.
Manually Adding top2maya to the Shelf:
Next you will need to source the top2maya script and create a shortcut to it on the shelf.
This only has to be done once per project. A shelf is a customizable row of buttons which
the user can define. It is the second row of buttons from the top, and each user has two
shelves they can use. To add the script to your shelf, go to Window -> General Editors ->
Script Editor. In the Script Editor, go to File -> Open Script and browse to
C:\maya\scripts and open top2maya.mel. This should place a few lines of text into the
Script Editor. Add a semi-colon after this line, then hit the keyboard enter button. On the
next line, type deleteWindow. Highlight both lines of text by dragging over it with the
right mouse button, then hold the middle mouse button down over the highlighted text
and drag and drop the text onto the shelf. This will add a button for the script onto your
shelf. The new button will have MEL printed on it. Again, this should only have to be
done once as long as you use the same project.
Additional References:
If you wish to use more advanced techniques than described in the report, there are
several resources available. In the lab you can refer to the Maya Manuals, Maya
Complete 2, and Learning Maya 2. Help is also available on the Web at
Http://www.highend3d.com.