SIMULATION IN OPENGL
by Oscar Gendrop Espinosa


INTRODUCTION

         A fly is put in a Balltrack Logitech mouse and sounds of cricket are reproduced to see the reaction of the fly.   The balltrack coordinates are brought into the rendering program which simulates the fly's moves.

"The flies (species = Ormia ochracea) are paritoids (this means they are parasites when they are immature, but not as adults) whose hosts are crickets. The larvae of the flies develop as internal parasites of crickets. The maggots burrow into the crickets after they are deposited on them by the female fly, and the female fly finds crickets by hearing and localizing the songs of male crickets. In order to accomplish all of this the female fly has and auditory system that is sensitive to the sounds produced by crickets and that allows them to detect what direction the sound is coming from. When a female fly hears a cricket song she turns in the direction of the source and walks towards it. This means that by presenting a cricket song to a female fly, we can reliably make them walk in a given direction. Much of the previous (and current) research on these flies relates to how they are able to detect and process directional cues from the sound stimuli. In addition to this we are interested in how these auditory cues are combined with signals from other sensory modalities, particularly vision. I should mention that it is very unusual for flies to be able to detect sound. Most flies do not have ears. There is a great deal known about vision in flies, though. For most flies this is the primary sensory system. What we are hoping to do is to study how visual and auditory information are combined by giving the flies combinations of sound and visual motion stimuli. We can induce them to orient and walk in response to cricket sounds and then we want to find out how much this response is affected by visual cues that are either consistent (visual motion matches the movement of the fly in response to sound) or conflicting (visual motion opposite to the fly's own movement)." Andrew Mason.
 

Go back to top


METHODS

The software interface to graphics OPENGL was used to render the world of the fly.
To be able to run this porgram you need to down load OPENGL from www.opengl.com adn all thge libraries possible form the page such that your compiler would be able to read the commands.   The reason for us to use OPENGL was because it was very portable and fast.   With OPENGL you can create 3D graphics with nearly the visual quality of a ray-tracer.  "OPENGL is intended for use with computer hardware that is designed and optimized for the display and manipulation of 3D graphics." (Wright and Sweet, 1996, p.7)

At the beginning of this project, I had no knowledge of OPENGL.   It took me almost 2 months to get use to it and understand how to use the tools.  I used several books: OPENGL SUPERBIBLE, OPENGL Programming for Windows 95 and Windows NT, OPEN GL Programming Guide.

Before I started programing the fly simulator I created very simple files that had objects moving in a window including squares, cones, triangles and that helped me understand more how objects works in OPENGL.

A program that existed in the OPENGL SUPERBIBLE CD-ROM called tank was use to star with some ideas.   A bunch of objects where implemented for example trees and the code of this trees looks as follows:
                                     treecode

The fly simulator consists in 5 files: fly.c, glutils.c, renderworld.c, viewwnd.c, and initworld.c.

Fly.c:  is the application shell for the fly simulator.

glutils.c:  is the file that contains the general purpose OpenGL Utility functions.

renderworld.c: This file actually renders the world. This is the most important one and the code looks as follows:  renderworld. This files includes all the objects created and the moment in which they are rendered.  Each object is created in the world 15 times and put in it at random.   Something to watch for in this file is when you use fuctions like auxSolidBox  that are from the auxilary library they can not be place in the display list becasue they cause problems.

viewwnd.c: This file contains the window procedure and code related to the view window. This window does the OpenGL rendering of the terrain.

initworld.c: This file contains the code to initialize the simulator.
 

The final rendered world looks as follows:   Fly.exe
 
 
 

Go back to top


RESULTS
This is how the render world looks like:

This render world is not a complete project it needs to be polish in different ways:


Go back to top


LINKS
  1. Professor Land's Page
  2. Oscar Gendrop Espinosa's  Page
  3. Neurobiology and Behavior


Go back to top


CONCLUSION

There are few things to work on that can get fixed.    First of all and more important the desicion about using UNIX base code should be reconsider if it is possible to change the hardware wihtout a hassle and cost.

The arrow keys input should inmediately be change to a mouse input.  For this there is a fuction call AUXMOUSEFUNC which is part of the auxilary libraries of OPENGL.   I tried for a long time to make it work but for some reason my world got rendered really different after using this function, and the mouse would not make it work.

Communication between the software developer and the hardware developer should happen more often and if possible work together 80% of the time ( that way the two teams learn both sides of the coin).

The objects need to be collision protected.

This project was a fun project since it gave me the opportunity to learn OPENGL, play around with the different functions, and create what I have done so far.  It was also frustrating since my spectations where set higher than the results were.   There were a lot of problems a long the way that need it to be taken care of and sometimes I found myself waiting for some hardware descisions that were going to take place but since the wait was for 2 weeks I decide to go ahead and continue.  The mouse Function was by far the most frustrating thing and I hope that the next person who takes care of this can figure it out fast.

I want to thank the support of Professor Land for this project.  Also my fellow student and good friend of mine Bill Feth who helped me when I got stock.
 
 

Go back to top