Advertisement
Promo

Become a member of the ZDNet UK community

Resources Downloads

Download Now

Wave Simulation 1.0


License Free
Requirements Mac OS X with developer tools installed Source Code only, needs to be compiled
Downloads 12 Limitations None
Publisher Ex Nihilo File Size 30k
Date added 10 Mar 2003 Check your speed

This is a program that simulates a wave disturbance propagating on a two dimensional membrane. The program uses a timer to step the simulation. At each step a two dimensional wave equation is solved by using a finite differencing scheme that is space centered and time forward. The initial conditions have been exaggerated for better visibility in the OpenGL output. See the commentary in the source code for further details. The idea here is to demonstrate simple numerical processing and scientific visualization in a Cocoa based application.
The program structure uses the Model/View/Controller paradigm. The classes for this structure are grouped under one heading and the various support classes are grouped under another heading.
The View part of the program combines the user interface (UI) and the OpenGL rendering. The GLView class is a wrapper, i.e., sub-class, around the NSOpenGLView class that gives the class the ability to render, among other things, a mesh that is passed in from an outside source. The view point and lighting that the GLView class uses in its rendering is also provided from outside. The visible part of the GLView in the UI is an outlet for the rendering. Also, the GLView object has been set up so that a mouse click in the visible rendering area toggle between wire-frame and filled rendering.
The UI also contains two groups of NSStepper controls that have been 'wired' to act as spin buttons. These are serviced by action methods in the Controller part of the program. The Controller takes user input from the steppers and routes it to the GLView object where the information is used to update the rendering accordingly. The view point and light coordinates are displayed at the bottom of the UI in an NSTextView control.
In addition to handling the UI the Controller object runs a timer that it uses to control the simulation. When the timer fires the contoller sends a message to the Model object that tells it to step the simulation. The Model object updates the mesh configuration in response. The Controller then routes the updated mesh to the GLView object for rendering. The Controller object also responds to the 'Other->Reset' menu item by sending a message to the Model object that instructs it to reset the entire simulation.
The simulation is encapsulated in the Model class. A Model object is a passive entity. It relies on messages sent from the outside to trigger the things that it can do. As noted in the previous paragraph these functions are performed by the Controller object. The simulation is not especially optimal with memory or processor resources. However, each update cycle is quick enough to justify a single threaded structure for the program.
An important characteristic of this program is that the OpenGL rendering is encapsulated in two parts of the program: the GLView class and the DrawingFunctions.h module. All of the other support classes make no reference to OpenGL. The Avian class is meant to capture the concept of an extended physical body that can have a location in 3D space as well as an orientation. The FlyingCamera class is based on the Avian class and provides it with extras that are appropriate for handling views from various positions and orientations. The Mesh and MeshNode clases are also divorced from OpenGL. A GLView object 'knows' what to do with FlyingCamera and Mesh objects, but not vice versa. Also, the Controller object 'knows' how to relate user input, via the steppers, to FlyingCamera settings.
This program is also provides a good way to waste enormous quantities of time. The membrane uses a material that is meant to be a fair approximation of ruby. When the light is set to, say, colatitude equal to 35 degrees and longitude equal to 200 degrees the surface shows some nice highlights. Be warned: this program can induce a hypnotic state in the unwary user.

Download Now

Did you find this download useful?
4 out of 10 users found this download useful


Broadband Deals? Powered by Top 10 Broadband

150+ broadband packages

Compare 30+ mobile broadband deals

Mobile Broadband »

Download

Trend Micro Worry-Free Business Security Advanced

Trend Micro™ Worry-Free™ Business Security Advanced and Standard 6. #1 for Small Business Security

  • Downloads: 1,249
  • Requirements: Processor: Intel™ Pentium™ or AMD™. RAM: 256MB-1GB (operating system dependant). Disk space: 350MB. Web Browser: Microsoft™ Internet Explorer 6.0 or 7.0.
  • License:
  • Publisher:
  • Size: 0

Download Now

Google Chrome Special Report

All roads lead to Chrome

All roads lead to Chrome

Comment With its new browser, Google has finally taken its gaudy, chrome-plated, futuristic ray gun and pointed it straight at Microsoft's head

More Special Reports


Skip Sub Navigation Links to CNET Brand Links

Help

Become part of the ZDNet community.

Newsletters