1.2. Objects, not Drawings

Inventor focuses on creating 3D objects. All information about these objects—their shape, size, coloring, surface texture, location in 3D space—is stored in a scene database. This information can be used in a variety of ways. The most common use is to display, or render, an image of the 3D objects on the screen.

For many 3D graphics packages, this image is the ultimate goal—a photorealistic representation on the screen of a 3D scene. But what if a user wants to move one of the objects to a different location, and perhaps view another object from a slightly different viewpoint? What if the user wants to experiment with a different range of colors for the objects and the background of the scene? What if a chemist wants to rearrange how two molecules align with each other? What if an airplane designer wants to redesign the curve of the airplane's wing? If the image exists only as a drawing on the screen, the programmer must write complicated code to implement these functions. Additional code is required to animate parts of the scene. With Open Inventor, the ability to make these changes is built into the programming model. Changing the objects in the scene, adding to the scene, and interacting with the objects becomes a simple process because such changes are part of Inventor's well-defined interface, and because they are anticipated by Inventor's basic design.

Using Database Objects in a Variety of Ways

Because the Inventor database holds information about the objects as they exist in their own 3D “world,” not just as a 2D array of pixels drawn on the screen, other operations in addition to rendering can be performed on the objects. The objects in the scene can be picked, highlighted, and manipulated as discrete entities. Bounding-box calculations can be performed on them. They can be printed, searched for, read from a file, and written to a file. Each of these built-in operations opens up a flexible and powerful arena for the application programmer. In addition, this programming model is intuitive because it is based on the physical and mechanical world we live in.

Animation

Inventor objects can also encapsulate behavior into the description stored in the scene database. Example 1.1, “ File Describing a Spinning Windmill , an excerpt from an Inventor file, describes a windmill whose blades spin at a specified rate. When this file is read into an Inventor program and displayed on the screen, the windmill is drawn and the blades are animated. No additional application code is used to make the blades spin; this description is part of the windmill object itself. Figure 1.2, “ Windmill shows an image of this windmill.

Windmill

Figure 1.2.  Windmill



Example 1.1.  File Describing a Spinning Windmill

#Inventor V2.0 ascii

Separator {
   Separator { 
      RotationXYZ {	
         axis Z
         angle 0 =
            ElapsedTime {	# Engine to rotate blades
               speed 0.4
            }
            . timeOut	# Engine output connected to 
                     	# angle of rotation
      }
      Transform {
         translation 0 0 0.5
      }
      Separator {	# Shaft for blades
         Material {
            diffuseColor 0.05 0.05 0.05
         }
         Transform {
            rotation 1 0 0 1.5708
            scaleFactor 0.2 0.5 0.2
         }
         Cylinder {
         }
      }
      DEF Blade Separator {	# Blade geometry and properties
         Transform {	# Blade interior
            translation 0.45 2.9 0.2
            rotation 0 1 0 0.3
         }
         Separator {
            Transform {
               scaleFactor 0.6 2.5 0.02
            }
            Material {
               diffuseColor 0.5 0.3 0.1
               transparency 0.3
            }
            Cube {
            }
         }
         Separator {		# Blade frame
            # .... (Details omitted)	
         }
     }
     Separator {		# Second blade
        RotationXYZ {
           axis Z
           angle 1.5708
        }
        USE Blade
      }
      Separator {		# Third blade
         RotationXYZ {
            axis Z
            angle 3.14159
        }
        USE Blade
      }
      Separator {		# Fourth blade
         RotationXYZ {
            axis Z
            angle -1.5708
         }
         USE Blade
      }
   }
   Separator { 	# Windmill tower
      	# ... (Details omitted)
   }
}