LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Subscribe to Linux Subscribe to Newsletters

Building a Black Hole With OpenGL
Pages: 1, 2, 3, 4, 5

Closing notes

If we were interested, the singularity in this simulation could be eliminated, and a mass value could be added for each particle. By calculating the distance between each particle and the force of gravity each particle's mass exerted upon all the others, accurate n-body predictions could be made. In this way, our simulation would grow from an "m" times 2-body environment to a truly chaotic n-body system.

It is in some ways reassuring to know that the simple algorithm, "foreach (Particle) { P += V; V += GravSum(ParticleList); }", turns out to be the only way to calculate n-body trajectories when "n" grows to be more than (currently) about six; the more direct equations quickly become too complex for we puny humans, or our computers, to solve. In fact, specialized hardware has been built that does nothing but run essentially the n-body version of this algorithm to simulate our solar system at very fine temporal resolution for highly accurate predictions.

In the less abstract, limited term simulations can be used for various effects such as simulated jet exhaust smoke trails, artillery trajectories, or fireworks. By replacing the ourMoveParticle() function, radically different types of simulations can be built such as non-deterministic bird or bee behavioral motion.

Program and Makefile

• bhole.c - The OpenGL black hole simulator.

• Makefile - Simple makefile.

Particle systems can be a wonderful way of adding complexity to an environment with a minimum of programmer effort, providing the hardware can support enough particles to make the aggregate effect convincing. The results can often be mesmerizing, as I found during the construction of this program.

And, of course, no software is finished, only abandoned; there are lots of things that could be added to this program to make it even more interesting. Suggestions include optical warping effects around the black hole of those particles behind it, rendering each particle using a single quad as a true "billboard" facing the observer, and doing some kind of visual effect when a particle is captured. Having a mode where the particle's color is a function of its position or one of its vectors would likely be educational too.

It's your universe; imagine, then create!


Chris Halsall

Chris Halsall is the Managing Director of Ideas 4 Lease (Barbados). Chris is a specialist... at automating information gathering and presentation systems.



Related Articles:

Creating Real Time 3D Graphics With OpenGL

OpenGL Rendering and Drawing

Preparing to Build an OpenGL Application


Discuss this article in the O'Reilly Network Linux Forum.

Return to the Linux DevCenter.

 




Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com