home *** CD-ROM | disk | FTP | other *** search
-
- C I N E C H E M
- Molecular Rendering and Animation with HyperChem and 3D Studio
-
- --- with ---
-
- S T I N G R A Y
- Stingy Ray Tracer
-
- by John Walker
- Release 0.3 -- 13th October 1992
-
- INTRODUCTION
- ============
-
- HyperChem allows you to build molecules, analyse them in various ways,
- and perform simulations of molecular dynamics. HyperChem also
- includes a variety of rendering algorithms including stick, dot
- surface, disc, and space filling sphere representations of molecular
- structures. While these renderings are entirely adequate for grasping
- the conformation of a molecule, they are not comparable to those
- created by high-end systems.
-
- In addition to rendering still image of molecules, HyperChem's ability
- to save "Snapshots" in the course of a molecular dynamics simulation
- enables one to create animations of dynamics runs: the "molecule
- movies" which many think are achievable only with supercomputers.
-
- While more comprehensive rendering and animation support could be
- added to HyperChem (and undoubtedly will be as the product matures),
- Autodesk already sells a product which contains everything needed to
- create high-end molecular images and animations: 3D Studio.
- Unfortunately, HyperChem and 3D Studio models are entirely
- incompatible, preventing the user from harnessing these two
- complementary products into an integrated scientific modeling and
- presentation tool.
-
- CINECHEM bridges the gap between HyperChem and 3D Studio. Simple and
- easy to use because it relies on the existing user interfaces of
- HyperChem and 3D Studio rather than providing its own, CINECHEM
- permits the HyperChem user to create renderings an animations within
- an hour of installing CINECHEM and 3D Studio on his machine.
-
- JUMP START
- ==========
-
- 1. Install It
- --------------
-
- Copy the contents of the CINECHEM release disc into the directory in
- which you keep your HyperChem model (.HIN) files.
-
- 2. Make a Rendering
- --------------------
-
- Fire up HyperChem under Windows, open the system you'd like to render,
- and establish the viewing position for the picture using HyperChem's
- pan, rotate, and zoom tools. When you're happy with the viewpoint,
- save the system in .HIN format. (If you already have one or more .HIN
- files, you don't need to edit them with HyperChem, naturally). Try a
- reasonably simple molecule the first time so things don't take too
- long.
-
- After saving the .HIN file, exit HyperChem and quit Windows. (3D
- Studio is a non-DPMI-compliant 386 mode application, and it cannot run
- in a Windows DOS box. CINECHEM, however, will run under Windows.)
- Once you're back at the DOS prompt, run CINECHEM on the .HIN file:
-
- CINECHEM <name>.HIN
-
- If you omit the ".HIN", CINECHEM will supply it for you. When
- CINECHEM is done, you'll have a <name>.3DS file in the same directory
- as the .HIN file from which it was created. Load 3D Studio, and using
- "Load" on the "File" menu, navigate to your <name>.3DS file and load
- it. You'll see a variety of viewpoints on the screen. Click the
- mouse in one of these viewpoints and type "C" to supplant it with the
- "Camera" viewpoint. Then, using the menu at the right, select
- "Renderer", then "Render", then click in the Camera viewpoint to
- designate it as the viewpoint to be generated, then click "Render"
- once again for spirit at the huge and confusing dialogue box that
- appears. Clinkity, clankity, clunk, and in a few seconds (or more, if
- your machine is pokey), there's your picture! This initial rendering
- is, of course, just the point of departure for creating publication
- quality art; all of the facilities of 3D Studio are now at your
- disposal, so you can change material types, lighting, viewpoints,
- perspective, etc., without recourse to HyperChem or CINECHEM again.
- (Note that this means a HyperChem user can turn over "raw molecules"
- processed by CINECHEM to a 3D Studio expert for rendering, instead of
- becoming a 3D Studio expert himself.)
-
- 3. Make an Animation
- ---------------------
-
- To make animations, we assume you already know how to run a molecular
- dynamics simulation in HyperChem. If you don't and wish to learn,
- please refer to Chapter 10 of the HyperChem "Getting Started" manual,
- paying particular attention to section "Setting up Playback Dynamics"
- on page 147. Run your simulation with Snapshots enabled, saving the
- results of the simulation in a <run>.HIN and <run>.SNP file.
- (Normally, you'll save the simulation snapshots with a different name
- than your original .HIN file). Animations generally look best if you
- set the Snapshot period to 1 data step, although if you're using a
- very small time step you may wish to increase the snapshot period to
- reduce the size of the animation and the time required to generate it.
-
- To create a 3D Studio animation of the simulation, you need only
- invoke CINECHEM on the .SNP file:
-
- CINECHEM <run>.SNP
-
- CINECHEM assumes that <run>.HIN is in the same directory as the .SNP
- file and will error if it cannot be found there. If you omit the
- ".SNP", CINECHEM will search first for a snapshot file to animate and,
- if none is found, then look for a .HIN file to create a still image.
-
- As before, the results of CINECHEM will be found in a <run>.3DS file
- in the same directory as the .SNP and .HIN files. Exit HyperChem and
- Windows, fire up 3DS, and load the file as for the still rendering
- before. Don't panic---when the image appears on the screen it may
- look very odd; what you're seeing is the base model, not the actual
- frames of the animation. Select the Keyframer on the Program menu (or
- just hit F4), and you'll see the first frame of the actual animation.
- You can move the slider along the bottom of the screen to preview the
- motion of the atoms and bonds over the course of the simulation.
-
- As before, click in a viewport and type C to change it to the camera
- viewport, select Renderer, then Setup and configure the screen
- resolution you desire. Next select Render, click in the Camera
- viewport, enable "Disk" in the dialogue box to save the animation in a
- file, and click Render. The animation will be created and saved in an
- .FLC or .FLI file according to the resolution you requested. You may
- then play the animation within 3D Studio (assuming you have a suitable
- VGA-compatible display), or with the public domain AAPLAY or ANIPLAY
- utilities furnished with Autodesk Animator and Animator Pro.
-
- VARIETIES OF THE RENDERING EXPERIENCE
- =====================================
-
- You can control the operation of CINECHEM through specifications on
- the command line (file names and options) and through an optional
- configuration file which allows you to assign 3D Studio material types
- to various elements and bonds.
-
- The general form of the CINECHEM command line is:
-
- CINECHEM [options] infile[.HIN/.SNP] [outfile[.3DS/.NFF/.POV/.RIB]]
-
- If no [outfile] is specified, <infile>.3DS is assumed. If <outfile>
- is specified but no file type is given, ".3DS" is appended. If no
- file type is given for <infile> CINECHEM searches first for a .SNP
- file and the corresponding .HIN file from a molecular dynamics
- animation then, if no .SNP file is found, for an .HIN file to be
- rendered into a still image.
-
- CINECHEM accepts the following options:
-
- -A Set screen aspect ratio. (NFF/POV/RIB)
-
- -B Do not display bonds.
-
- -C<file> Load the named configuration file. If no file type is
- supplied, ".CFG" is assumed. (3DS)
-
- -D Dry: water molecules are not rendered.
-
- -E<factor> Expand (or contract) the distances between atoms by
- the given <factor>. This gives you smooth control
- over the relative size of the atom spheres and the
- bond lengths. The "-S" option is equivalent to a
- specification of "-E3".
-
- -H Do not display hydrogen atoms or bonds to them.
-
- -K Generate keyframer hierarchy to make atoms and bonds
- child objects of the molecule that contains them even
- if the input is a static model (.HIN) file instead of
- a model/snapshot (.HIN/.SNP) pair. This is handy when
- you want to manually animate a model to show, for
- example, how a molecule binds to an active site of
- another or to create animations of so-called
- "nanomachines". (3DS)
-
- -M Create special material types for each element and
- bond used in the model. (3DS)
-
- -Q Quiet (suppress sign-on line).
-
- -R<n> Rendering quality versus time tradeoff. If <n> if 0,
- rendering will be very fast but picture quality will
- be low. As <n> increases toward the maximum value of
- 9, image quality improves at the expense of rendering
- time. The default value is 7. (RIB)
-
- -S Generate a "stick and ball" rendering rather than the
- usual "space filling" representation. The spheres
- that represent atoms are reduced in size by a factor
- of three so they appear as balls at the junction of
- sticks representing the bonds.
-
- -T<factor> Thicken the bonds by the specified <factor>. A
- <factor> of 1 yields the default thickness, 2 twice
- that thickness, and 0.5 half the default. This is
- primarily intended to make bonds more visible when
- rendering stick and ball pictures for low resolution
- displays.
-
- -U Display a summary of the command line and options.
-
- -X<pixels> Set screen width to <pixels>. (NFF/POV/RIB)
-
- -Y<pixels> Set screen height to <pixels>. (NFF/POV/RIB)
-
- Some options are applicable only to certain output file formats; they
- are noted in the table above. Options irrelevant to the current file
- format are ignored.
-
-
- SPECIFICATIONS IN THE MATERIAL WORLD
- ====================================
-
- By default, CINECHEM chooses 3D Studio materials which reproduce the
- default colours that HyperChem uses when rendering atoms. (Note that
- if you change HyperChem's rendering colours with the "Display /
- Element Color..." dialogue, CINECHEM does not automatically use those
- new colour assignments. Bonds are rendered according to the type of
- the bond as follows:
-
- Bond type Material
- --------- ---------------
- Single White plastic
- Double Blue plastic 50
- Triple Copper
- Aromatic Gold
-
- You can change these material assignments by supplying a configuration
- file which assigns specific 3D Studio materials, either from the
- standard library or those you've created yourself, to elements and
- bonds. Here's a sample configuration file:
-
- ; Gaudy show-off configuration
-
- element_3ds H tile goldgranite
- element_3ds o red glass
- element_3ds c blue planet
- element_3ds n blue metalic
- element_3ds s yellow plastic
- element_3ds lp marble - pale
-
- bond_3ds s blue marble
- bond_3ds d ape
- bond_3ds t blue plastic
- bond_3ds a old metal
-
- Upper and lower case letters are treated as identical in processing
- the configuration file, blank lines are ignored, and any text on a
- line following a semicolon is taken as a comment. Two statements may
- be supplied in the configuration file:
-
- ELEMENT_3DS <element_symbol> <material name>
-
- This assigns <material name> (which may be any number of words) to
- the element with chemical symbol <element_symbol>. The <material
- name> must be defined in one of the libraries from which 3D Studio
- obtains material definitions. You can assign a material to lone
- pairs by using an element symbol of "LP".
-
- BOND_3DS [S|D|T|A] <material name>
-
- Assigns <material name> to the bond type (Single, Double, Triple,
- Aromatic) specified. The <material name> must be defined in one
- of the libraries from which 3D Studio obtains material
- definitions.
-
- A configuration file can be specified by naming it with the "-C"
- option on the CINECHEM command line, for example:
-
- CINECHEM -Cgaudy MYDNA.HIN
-
- where GAUDY.CFG is the configuration file that specifies rendering for
- MYDNA.HIN into MYDNA.3DS. Any elements or bond types not specified in
- the configuration file will be rendered according to the defaults. If
- no "-C" specification is given, CINECHEM will look for a configuration
- file named CINECHEM.CFG in the current directory and, if present, load
- it.
-
- An alternative method of managing material types is provided by the
- "-M" option. If you specify this switch, a material will be created
- for each type of element and bond which appears in the model. These
- material types are given names like:
-
- Hydrogen atom
- Carbon atom
- Neodymium atom
- Single bond
- Double bond
- Triple bond
- Aromatic bond
- ...etc.
-
- The materials are initialised to render in the default colours
- described above (if the "-M" option is selected, the configuration
- file is ignored). Choosing the "-M" option creates a 3D Studio model
- in which it's easy to change the appearance of specific kinds of atoms
- and bonds; just go to the Material editor, get the material you wish
- to change from the scene, modify it as you like, then put it back to
- the scene and re-render. You can use the "-M" option in conjunction
- with libraries which define materials for various elements and bonds,
- as well.
-
- RENDER UNTO OTHERS
- ==================
-
- By specifying an output file with an explicit extension, you can cause
- CINECHEM to create an input file for any of the following renderers:
-
- Extension Renderer
- --------- --------
-
- .3DS 3D Studio (default)
- .NFF StingRay
- .RIB Autodesk RenderMan
- .POV Persistence of Vision Raytracer
-
- None of the other renderers support animation, so even if you supply a
- snapshot file from a molecular dynamics simulation, only a rendering
- of the initial image will be created. The material specifications in
- configuration files and the optional assignment of material names
- based on element and bond types affect only 3D Studio output files.
-
- For example, to render a system called MYDNA.HIN into a Microsoft
- Windows bitmap file with a resolution of 640x480 pixels using
- StingRay, use the commands:
-
- CINECHEM mydna mydna.nff -x640 -y480
- STINGRAY mydna
-
- You can then view the resulting MYDNA.BMP file with your favourite
- Windows bitmap display program.
-
- StingRay
- --------
-
- StingRay (STINGy RAY tracer) is a public domain raytracer included
- with CINECHEM. It allows users to get started in high-quality
- molecular modeling rendering under Windows without the need to
- purchase 3D Studio. For some applications (particularly those where
- reflection and refraction are important, or where precise rendering of
- sphere and cylinder contours are important, as opposed to polygonal
- mesh approximations) it produces superior results. Since StingRay is
- a batch renderer with no user interface (or even display support),
- customising the pictures it generates requiring editing the model
- (.NFF) file with a text editor; this is obviously a lot less friendly
- than 3D Studio, but experts can create very classy images that way.
-
- Autodesk RenderMan
- ------------------
-
- Autodesk RenderMan is Autodesk's licensed version of Pixar's renderer
- which implements the portable RenderMan scene description language.
- AutoShade users who possess a copy of Autodesk RenderMan can use that
- renderer on HyperChem models by specifying an extension of ".rib" on
- the CINECHEM output file. The ".rib" file written by CINECHEM will be
- configured to render with very high image quality (and correspondingly
- slow rendering speed), with the image size, width, and aspect ratio
- given by options on the CINECHEM command line (defaults are a 640x480
- pixel image of square pixels). Output is written to a Truevision
- Targa (.TGA) file with the same name as the input .RIB file. You can
- change all of these parameters by editing the .RIB file before
- processing it with RenderMan.
-
- Persistence of Vision Raytracer
- -------------------------------
-
- The Persistence of Vision raytracer is a descendent of the DKB
- raytracer developed by David K. Buck. It was subsequently extended by
- a team of volunteers on CompuServe led by Drew Wells. POVRAY is a
- thoroughly professional, high-end rendering engine which implements
- primitives and provides capabilities absent from many expensive
- commercial products. Surfaces and solids up to quartics are
- supported, along with deformable "blobs", texture and bump mapping,
- and CSG operators. The Persistence of Vision raytracer is essentially
- in the public domain, but there are restrictions on its commercial
- dissemination which preclude supplying it with CINECHEM. You can
- obtain a current copy of POVRAY (including source code) from the
- COMART forum on CompuServe. POVRAY usually lives in Data Library 16,
- but check the "recent uploads" sections since CompuServe "saves space"
- by not duplicating the latest updates into the sections in which they
- will eventually reside.
-
- WHAT IS THIS "STINGRAY", ANYHOW?
- ================================
-
- 3D Studio combines a powerful collection of rendering facilities with
- an unparalleled user interface to animation which makes it the product
- of choice for high-end presentations; the awards it has won and the
- work produced with it demonstrate this.
-
- But 3D Studio has one major drawback; it's *expensive*. Chemists are
- poor. It's very hard to justify a US$3500 out of pocket expense to
- produce pictures that spice up one's publications. But if people
- could just get a taste of high-end rendering, then they'd want *more
- and more* and eventually be satisfied with nothing less than the Real
- Thing, including animation.
-
- Enter StingRay. StingRay stands for "STINGy RAY tracer"; it's a
- slightly extended implementation of the "MTV Raytracer" originally
- implemented by Mark VandeWettering, then of the University of Oregon.
- The author released this ray tracer into the public domain totally
- free of restrictions:
-
- This program is public domain. Feel free to modify it, hack
- it, use it inside other programs, and even sell it. I wrote
- it to better understand raytracing and hope that it helps
- others understand the raytracing process as well.
-
- StingRay is stingy in that it's free to acquire (including source
- code), but it's rich in functionality; in fact, it provides most of
- the facilities found in top-of-the-line molecular rendering systems.
- Its shortcomings are mostly in the representation of complex geometry
- which isn't used in molecular modeling, and in fancy optimisations to
- speed up the rendering process. The quality of the the images created
- is entirely comparable to those created by commercial products.
-
- StingRay is called with a command of the form:
-
- STINGRAY [options] input[.nff] [output[.bmp/.tga]]
-
- The input file is assumed to be a scene description in a slightly
- extended version of Eric Haines' Neutral File Format (NFF). The only
- extension supported by STINGRAY is a new "aspect" statement which
- permits specification of pixel aspect ratio for non-square screens.
-
- StingRay creates output image files in either Microsoft Windows Bitmap
- (DIB) format (.BMP files) or in TrueVision Targa-24 (.TGA) format.
- The format of the output file depends on the extension given on the
- output file name. If no output file name is specified, the output
- file will be written in Microsoft Windows bitmap format to the file
- <input>.BMP.
-
- StingRay always creates a full colour image (24 bits per pixel). If
- your display does not support full colour images (or a subset thereof,
- such as the 16 bit per pixel "high colour" displays), be sure to use
- an image viewing program that intelligently compresses the full colour
- image into one compatible with your display. If you just view the
- bitmap on your 256 colour display with Microsoft Paintbrush or WinGIF,
- you'll be disappointed since the true colour image will be brutally
- crushed into the Windows default colour palette. To do justice to the
- image, you need to intelligently flatten it to a custom-generated 256
- colour gamut. You can do this with the ANICONV utility supplied with
- Autodesk Animator PRO, with the public domain PICLAB program available
- on CompuServe or, if you're a Unix user, with the PBMPLUS utilities.
- If the utility you're using doesn't read .BMP files, you can create a
- Targa (.TGA) file by executing StingRay as follows:
-
- STINGRAY mydna mydna.tga
-
- ANICONV, PICLAB, and PBMPLUS all process full colour Targa files
- without difficulty. A copy of the current release of PICLAB is
- included with CINECHEM; it is also unrestricted public domain
- software.
-
- You can control the rendering process by specifying options on the
- STINGRAY command line:
-
- -Aratio Set screen aspect <ratio>
- -F Fast and cheap antialiasing
- -Josamp Antialias by oversampling <osamp> times
- -Q Quiet (no sign-on line)
- -T Show progress by line number
- -U / -? Print this message
- -V Verbose: print model and timing statistics
- -Xpixels Set screen width to <pixels>
- -Ypixels Set screen height to <pixels>
-
- Normally, the image size and aspect ratio are specified in the .NFF
- file that defines the model to be rendered; you may override these
- values with the "-A, -X, and -Y" options. The first time you run
- StingRay you may be disappointed with the results; you may notice
- "jaggies" and other rough edges that don't look like high-quality
- contemporary renderings. There's an unavoidable tradeoff between
- image quality and rendering time, and StingRay implements this in a
- very brutal fashion: N squared time. The "-Jn" switch, which enables
- stochastic oversampling of subpixels, controls the tradeoff between
- speed and quality. If you specify "-J16", each pixel of the final
- image will be the average of 16 randomly positioned subpixels within
- the box bounding the pixel in image space. The resulting image will
- be *beautiful*, but it will take *sixteen times* as long to create as
- a simple image with no oversampling. More sophisticated renderers,
- including POVRAY, use an adaptive oversampling algorithm which only
- calculates additional rays after detecting a sharp edge in the image;
- StingRay admits of no such sophistication. It's slower, but the image
- quality is impeccable.
-
- As an alternative to exhaustive oversampling with the "-Jn" switch,
- you can select quick and dirty smoothing with the "-F" switch; this
- simply averages groups of four pixels. This takes the bite off rough
- edges at the cost of a subtle blur to the overall image.
-
- HARDWARE AND SYSTEM REQUIREMENTS
- ================================
-
- CINECHEM and StingRay are intended to be used by HyperChem customers
- on the same machines on which they run HyperChem. Both were produced
- with WATCOM C 9.0 and a PharLap DOS Extender which is fully
- DMPI-compliant and runs either under a raw DOS environment or within a
- DOS window in Windows 3.1. If you're running HyperChem on your
- machine under Windows 3.1, you should have no trouble running either
- CINECHEM or StingRay in a DOS window. (Note that this permits you to
- save a model from HyperChem, process it with CINECHEM, render it in
- the background with StingRay, and view the results with a BMP display
- program, all without ever leaving Windows.)
-
- CINECHEM's memory requirements vary based upon the number of atoms in
- the model being generated and, for an animation, the number of
- snapshots to be rendered. In most cases, one or two megabytes are
- plenty. Lengthy animations of huge molecules can require lots of
- memory, but you'll probably run out of patience or disc space before
- RAM is exhausted.
-
- StingRay is as conservative in its memory usage as it is profligate in
- consuming CPU cycles. Essentially, only the model is kept in memory
- (unlike renderers which require enormous "reflection maps" and/or
- "shadow maps"), so one or two megabytes should suffice for huge
- molecules and high resolutions.
-
- StingRay requires a math coprocessor, but CINECHEM doesn't--it's not
- sufficiently compute bound that it would benefit from the restriction.
- Neither program benefits from a Weitek chip, if present.
-
- DETAILS AND DE BUGS
- ===================
-
- CINECHEM attempts to create 3D Studio camera and light objects which
- reproduce the same view of the molecule in 3D Studio that HyperChem
- displays when viewing the same .HIN file. Unfortunately, HyperChem
- doesn't indicate if a perspective view was enabled. CINECHEM always
- creates a perspective view (except when generating a RenderMan file),
- because all the renderers other than RenderMan work exclusively in
- perspective. Since HyperChem usually places the default camera far
- away from the molecule, perspective effects are not normally very
- great, but in some cases you'll want to adjust the camera's field of
- view to fill the frame with the molecule, taking account of
- perspective.
-
- The version of 3DSLIB used to build CINECHEM doesn't allow
- specification of an arbitrary viewport configuration. You're either
- stuck with the 3D Studio default configuration or one full-screen
- viewport to your specifications. Rather than fill the screen with the
- camera viewport (from which you can't adjust the camera and light
- locations), I opted for the default configuration which requires you
- to type "C" in a viewport to see the image to be rendered, but avoids
- endless fussing if you want to adjust the camera or light.
-
- If the "-M" option is not specified, CINECHEM has no need to place
- material definitions in the .3DS file it creates--it's relying
- exclusively on materials already defined in libraries accessed by 3D
- Studio. Nonetheless, CINECHEM defines a material called "Void of
- space", which it never actually assigns to an object. Why? Because
- if it doesn't, when you load the .3DS file, 3D Studio issues the jerk
- alert:
-
- CAUTION: File contains antiquated
- data type, please re-save
-
- which is as annoying as it is grammatically wrong (comma-splice), but
- if and when somebody provides me a version of 3DSLIB that doesn't
- cause this, I'll be more than happy to remove the nugatory material
- definition. OK? Cancel?
-