Class Graphics.Solid


This is the most essential class in the Solid 3D Graphics Simulator. Class Solid is a subclass of Graphics, which implements a framework for OpenGL graphics programming. The following sections describes the specific attributes and functions of Class Solid. For more details on how SansGUI supports OpenGL programming, please see the Class Graphics reference page.

Class Attributes

These attributes are specific to class Solid in the Solid 3D Graphics Simulator. The users can choose the values to change the 3D objects in the graphic window. For developers, these attributes are listed after the intrinsic attributes from the Graphics class (below) in the SansGUI data objects.

+ 3D Object Shape (iShape): An enumerated item that indicates the shape of the object to be displayed. The possible values are: 0)Tetrahedron, 1)Cube, 2)Octahedron, 3)Dodecahedron, 4)Icosahedron, 5)Box, 6)Cylinder, 7)Cone, 8)Sphere, 9)Torus, and 10)Teapot. The graphical objects are drawn by the aux{Solid|Wire}* routines in the OpenGL Auxiliary Library.

+ Color of Object (iColor): An enumerated item that sets the color of the 3D graphical object. The colors can be 0)Cyan, 2)Magenta, or 3)Yellow.

+ Display Method (iType): An enumerated item that indicates the display method, which can be 0)Solid or 2)Wireframe.

+ Current Angle (fAngle): The value of this attribute is a copy of the rotation angle about the Y-Axis (vertical). It is copied here for plotting purposes. We cannot plot the Rotation Angles [x y z] vector directly because SansGUI will pick up the first value (the x component, in this case) in any vector for plotting.

Class Functions

The class functions in the Solid 3D Graphics Simulator demonstrates how to write OpenGL API function calls supported by the Graphics class in SansGUI. Please refer to the souce code from the SansGUI distribution for more specific details.

+ Begin Run function (SG_xBgnRun_Graphics_Solid): sets up the rendering context, including hidden surface options, color material, lighting, etc. The background color is set according to the SG_STAT_PRINT status bit; it is set to white when the 3D image is to be printed to a printer. We also set the selection tracker to rectangle just to demonstrate the capability.

+ Pre-Evaluation function (SG_xPreEval_Graphics_Solid): responds to windows size change message after the user resizes the window. In Solid, we set up the orthographic projection parameters and handle translation (for moving the 3D objects) and scaling (for zooming in and out).

+ Evaluation function (SG_xEval_Graphics_Solid): processes the user's selection and returns the selection points in the message string for SansGUI to display when the SG_STAT_EDIT bit is set. During a simulation run, this routine rotates the 3D object about the Y-Axis and copies the the angle to the Current Angle attribute for displaying and plotting.

+ Post-Evaluation function (SG_xPostEval_Graphics_Solid): renders the 3D graphic object in the scene. We do not differentiate whether it is called during a simulation run or when repainting because the scene is rendered in the same manner. Rotation angles are processed in this routine as well as the color, shape, and displaying type of the 3D object.

Solid On-Line Document Pages

Solid Home Page

Class Graphics

Solid Simulation Control

Copyright © 2003 ProtoDesign, Inc.
Last updated: June 30, 2003