Kurt Schwehr Copyright (C) 2003 kdschwehr _at_ ucsd dot edu DRAFT DRAFT DRAFT Viz Lecture Series Lecture 5 $Revision: 702 $ CONTENTS VRML/IV MODELS DxfToIv CORE RESISTIVITY MAKING A MOVIE MAKING WEB THUMBNAILS XDIALOG/XWIT MAGMAP (Cande) - not started MAGMAP (Parker) - not started SOUND - more links TERRAIN - ALPHA features ANIMATE
VRML/IV MODELS There are a number of ways to create VRML 1.0 or OpenInventor models that you can use in your visualizations. An easy way is to use the export functions of AutoCad / Mechanical Desktop to products. Since I don't know how to use either, I'll leave it up to you to figure out how to create a model in these CAD (Computer Aided Design) programs. In this lecture, I have included three models to illustrate some of the things that can be done. The first is a model of a dart that I found at the 3D Cafe's Models (http://www.3dcafe.com/avatar/dart.wrl). You can use this model to mark locations of interest in your 3D terrains. This was used for the Mars Pathfinder mission to plan out way points for the Sojourner rover to drive to. This model was apparently created on MS Windows using an old program called Pioneer. To see it: ivview dart.wrl The second model is of a ship. The original model was provided by Mike McCann at MBARI in VRML 2 format. Since standard SGI OpenInventor can not read VRML2, I converted the file to VRML 1.0 by hand using emacs and gview. The model is not as nice as the original VRML 2 file, but it can be used to represent a ship in the 3D world. ivview westernflyer.iv The last 3D model was made by Laurent Beguery using Mechanical Desktop 6. He took a few measurements and photos of the XStar EdgeTech chirp while it was on the deck of the R/V Sproul and from them created a CAD model of the fish. He then exported the file to VRML 1.0. To see the model: ivview edgetech-chirp4.wrl For more information: 3D Cafe Models Western Flyer EdgeTech Pioneer - old link
DxfToIv Often you will want to bring in a model of some object from a CAD program, but all you have is a dxf. Some versions of OpenInventor do know how to read dxf files, but not the standard SGI version. SGI's include a utility which can convert dxf to iv for you. It does not handle every type of dxf, but it often gets the job done. Here is an example of a marker created in FormZ by Peter Coppin which was then exported to dxf. /usr/sbin/DxfToIv flag5.dxf > flag5.iv ivview flag5.iv For more info: man DxfToIv man AliasToIv man ObjToIv man SlaToIv man SoftimageToIv http://www.bigsignal.net/ http://www.eventscope.org/ http://schwehr.org/yellowstone/ - Look at the 3D Models That are tons of 3D file formats out there and plenty of variations on each. If you have MS-Windows, there are a number of tools that you can use. One that has been tried (thanks to JCHill) is the Myriad converter. They have a free trial so you are able to see if it can handle the type of conversions that you would like to do. If you are running Mac OSX, you can use it within VirtualPC. For more info: http://www.myriadviewer.com/formats.htm http://www.microsoft.com/windowsxp/virtualpc/
Core Resistivity Recently, Jill Weinberger showed me an interesting image of a bore hole resistivity log. It was presented in just an xy gif image, so I put together a short demo that illustrates a couple ideas in OpenInventor. This first is just that the default texture coordinates for the basic geometric shapes are often exactly what you would like. Here we want to map a 360 image onto a cylinder which represents the walls of the bore hole. Here is a short bit of OpenInventor to just that: Texture2 { filename "resistcore.gif" model DECAL } Cylinder { parts SIDES radius 0.1 height 2 } This gives us a hollow cylinder with the texture on both the inside and outside. Then if we add a flat view along side the core, we can get two intuitive coordinate frames that compliment each other. The final product is: ivview resistcore.iv A simple cylinder gives us the opportunity to explore some topics that are much harder to understand on complext surfaces. There is a sample program in the XCore package called makeCylinder that creates pretty much what the above two lines in resistcore.iv do. Run it and take a look at the output. It takes the width, height, number of sides to the cylinder, the texture file and output file name. makeCylinder 0.1 2 5 resistcore.gif resist-cyl.iv This generates an Inventor file that uses PER_VERTEX_INDEXED material binding and shows how to do texture coordinates and surface normals. The output file is a good example that is not too complex. For more information: man SoBaseColor man SoMaterialBinding man SoTexture2 man SoTextureCoordinate2 man SoNormal
MAKING A MOVIE A common task is to make a quick movie of some visualization to give a sense of the model changing and/or the point of view moving around. In lecture 1, I introduced the snapshot command to grabbing images of parts of the screen. You can try xwd (X-Windows Dump) but that often is unable to grab the 3D graphics portion of the screen. First use this program to grab a sequence of images. Name them by number and make sure that you pad the file names with zeros so that all filenames are the same length. This will cause a listing of files to come in the order that we would like to have the images. For example, with less than a thousand images, I could safely use 001.rgb 002.rgb, 003.rgb, etc. For this I am making a movie of the Santa Barbara terrain for Lecture 4. Here are the images: ls -l ??.rgb | awk '{print $5,$9}' 318783 01.rgb 311174 02.rgb 306761 03.rgb 296799 04.rgb 278024 05.rgb 249777 06.rgb 294751 07.rgb 370806 08.rgb 528537 09.rgb 704481 10.rgb 795173 11.rgb 863885 12.rgb 764403 13.rgb 755223 14.rgb 846934 15.rgb 897092 16.rgb 815515 17.rgb 850898 18.rgb 819993 19.rgb 815437 20.rgb 747883 21.rgb First, we need to make the images smaller so that these sample movies do not end up being too large. #!/bin/bash for i in ??.rgb; do sgitopnm $i | pnmscale -xysize 200 200 | pnmtosgi > ${i%%.rgb}b.rgb done In Lecture 4, we used gifsicle to create an animated gif. This time we would like to make some real movies. On the SGI there is a handy command line movie tool that takes individual images and combined them to make movies: makemovie. Here we make a couple quicktime movies, each with slightly different parameters. makemovie -o santabarbara_qtv.mov -f qt -c qt_video -r 1 \ -s 100,100 ??.rgb makemovie -o santabarbara_qanim.mov -f qt -c qt_anim -r 1 ??b.rgb makemovie -o santabarbara_qjpg.mov -f qt -c jpeg -r 1 ??b.rgb You can edit your movie with SGI's moviemaker program. For more information: man makemovie man snapshot man moviemaker
MAKING WEB THUMBNAILS There are tons of different options to create thumbnails for web pages. You can use imagemagick, php, etc. But here is a little sample script of what I frequently use that relies on the netpbm tools. This script is setup for converting SGI rgb images (e.g. snap.rgb from snapshot) to jpg images. FIX: recode so that the url shows up right #!/bin/bash for image in [a-zA-Z0-9]*.rgb; do i=${image%%.rgb} sgitopnm $image | pnmscale -xysize 100 100 | pnmtojpeg > _thumb${i}.jpg sgitopnm $image | pnmtojpeg > ${i}.jpg echo ""\ >> HEADER.html done For more informatio: http://netpbm.sourceforge.net/ This package is available through fink on Mac OS X.
XDIALOG/XWIT Alex always get frustrated with me that I don't use perl or python for my scripts and that I always go back to bash. Well, sort Alex, but I'm doing it again here. But I promise that I'll keep trying to force myself back to real scripting languages. Hey, I did use perl in the last lecture and I've been calling python instead of awk to do simple math. xwit - http://www.slack.com/sw.html http://freshmeat.net/projects/xdialog http://xdialog.dyns.net/ man xmessage
MAGMAP (Cande) Steve Cande's magnetic lineations database.
MAGMAP (Parker) Bob Parker's magmap for plotting spherical harmonic models.
MORE LINKS TO SOUND PROGRAMS http://www-ccrma.stanford.edu/planetccrma/software/soundapps.html http://fife.speech.cs.cmu.edu/flite/index.html
TERRAIN - ALPHA features There are a couple of features in the X-Core terrain program that are in early development stages. They work, but just barely. The first is reduction of mesh sizes. This feature just prevent the code from writing out the NaN nodes. For grids that have lots of holes, this is a huge memory and disk space saver. The second feature is a simple color palette support. The code currently can not read in cpt files from gmt, but it does have one default color table. To turn on these features, you need to set the XCORE_CPT environment variable. Like this for bash: export XCORE_CPT="yes" To turn off this hidden feature, do this: unset XCORE_CPT
ANIMATE Often you would like animate an object such as a ship, AUV, or ROV in your scene. I have implimented a cheap hack in xcore to allow you animate one object. Unfortunately, you can only animate one object, and once it starts, it will loop forever. Hopefully I will raplace this hack with a node-kit general implimentation, but for now here is how to use this feature. This hack is available in xcore-0.7 until ??? First you need to create an Inventor model that has a translation node that is tagged with a "DEF ANIMATE_TR" name. Is is a very basic example (animate.iv): #Inventor V2.1 ascii Sphere{} DEF ANIMATE_TR Translation {translation 1 1 1} Cube{} Then create an xyz ascii file of all the positions you would like to loop through (animate_pos.xyz): 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 5 1 0 5 2 0 5 3 0 5 4 0 5 5 0 4 4 0 3 3 0 2 2 1 1 1 1 0 0 0 Then you can optionally set two environment variables that change the default filename to use and the time between each position. Here is with bash: export XCORE_ANIMATE_FILE=mypositions.xyz export XCORE_ANIMATE_INTERVAL=0.1 or csh/tcsh: setenv XCORE_ANIMATE_FILE mypositions.xyz setenv XCORE_ANIMATE_INTERVAL 0.1 Now view the file in xcore-ivview: xcore-ivview animate.iv You will see your model, but it will not be moving. You need to start the animation. Press the ESC key to change the hand to a pointer. This will let you use the keyboard in the viewer. Then press 'a' to begin the animation. When you do this, it will try to load your xyz file and start moving the object.