RE: OpenGL - application programming interface
1OpenGL.doc (Size: 208 KB / Downloads: 28)
Because playing games on personal computers has become so popular, and so many dazzling animations are appearing in movies, peoples are particularly interested in developing 3D graphics applications. OpenGL is a very useful tool to design a 3D scene.
OpenGL emerged from Silicon Graphics, Inc., in 1992 and has become a widely adopted graphics application programming interface (API). It provides the actual drawing tools through a collection of functions that are called within an application. It is available (usually through free downloads over the Internet) for all types of computer systems. OpenGL is easy to install and learn. One aspect of OpenGL that makes it so well suited for use in a computer graphics is its “device independence”, or portability. An OpenGL program can be developed and run on different computers.
OpenGL offers a rich and highly usable API for 2D, 3D graphics and image manipulation. Using it, people can progress rapidly and produce stunning animation in a short period.
Transformations are of central importance in computer graphics. We use affine transformations in 3D case, including translate, scale, rotations in 3D. We have designed tools used to shift, scale, and rotate figures through the “current transformation,” and OpenGL’s matrix operations are used to facilitate this feature. An overview of the OpenGL viewing pipeline is developed, and the roles of the model view, projection, and view port transformations are described briefly. The drawing of 3D objects using OpenGL’s tools is developed.
A FLAT HOUSE
In this part, we first try to use the basic 3D drawing functions of OpenGL to draw a simple “house”. This house only has three walls and one object inside. We use parallel projections to visualize an example 3D scene comprised of simple wire-frame objects.
This “flat house” drawing based on the simple “parallel projection”, shown in figure 1. The view volume is a rectangular parallelepiped (i.e. a box), whose four sidewalls are determined by the border of the window and whose other two walls are determined by a near plane and a far plane. So the 3D point (x, y, z) projects to (x, y, 0) in this projection.
OpenGL provides three functions glScaled (..), glRotated (..), and glTranslated (..) for applying modeling transformations to a shape. OpenGL also provides functions for defining the view volume and its position in the scene. These functions are used in our design of the house and camera.
Deciding the properties of Light
Some sources, such as a desk lamp, are in the scene, whereas others, like the sun, are infinitely remote. OpenGL allows you to create both types by using homogeneous coordinates to specify the position of the source. So we have (x,y,z,1): a local light source at the position (x,y,z) and (x,y,z,0): a vector to an infinitely remote light source in the direction (x,y,z). Arrays are defined to hold the colors emitted by light sources and are passed to glLightfv().
OpenGL allows three parameters to be set that specify general rules for applying the lighting model. These parameters are passed to variations of the function glLightModel. In order to make the objects in the scene visible even if we have not invoked any of the lighting functions, we set the ambient source to a non-zero value. After we built the light class, we can still move the light sources through translating, rotating and so on.
OpenGL serves two main purposes, to:
1. hide complexities of interfacing with different 3D accelerators by presenting a single, uniform interface
2. hide differing capabilities of hardware platforms by requiring support of the full OpenGL feature set for all implementations (using software emulation if necessary)
In its basic operation, OpenGL accepts primitives such as points, lines and polygons, and converts them into pixels via a graphics pipeline known as the OpenGL state machine. Most OpenGL commands either issue primitives to the graphics pipeline, or configure how the pipeline processes these primitives. Prior to the introduction of OpenGL 2.0, each stage of the pipeline performed a fixed function and was configurable only within tight limits. OpenGL 2.0 offers several stages that are fully programmable using GLSL.
Through the whole process, we now have a good understanding of the computer graphics, how it can be implemented to draw pictures and how the graphics pipeline works.
Rather than “digging” into specific aspect of OpenGL, we tried to present several basic features of this powerful tool. So, if we want to use it to fulfill some goals in the future, we know which aspect we should plunge into. Further effort can be made to a more realistic and beautiful scene with a more powerful camera.
As biomimetic autonomous agents situated in realistic virtual worlds, artificial animals also foster a deeper understanding of biological information processing, including perception, learning, and cognition. For example, they have enabled an advantageously novel, purely software approach to the design of active vision systems, an activity that has heretofore had to rely on mobile robot hardware.
We have been developing an active vision system using artificial fishes and, more recently, artificial humans demonstrating that virtual autonomous agents can support serious
experimentation with image analysis algorithms and sensor motor control strategies. Perception begins with a pair ofvirtual eyes that afford the agent high-acuity foveal vision plus wider field-of-view albeit lower-acuity peripheral vision. With mobile, foveated eyes, controlling gaze through eye movements becomes an important issue. The active vision system includes a stabilization module and a foveation module. By continually minimizing optical flow over the
retina, the stabilization module implements an optokinetic reflex, producing egomotion-compensating eye movements that stabilize the visual field during locomotion. The foveation module directs the gaze to objects ofinterest based on visual models stored in the agent’s brain. For example, a primary visual cue for recognition is color.