Particle

2025-12-07 0 418

The Particle System API

Since 1999, using C++, OpenGL, GLUT, and CMake

by David McAllister
version 3.0.0
April 18, 2022

Hosted at https://g**ithub.com*/davemc0/Particle.git.
(Previously hosted for 15 years at: http://www.particlesystem*s.o*r*g.)

Documentation is here.

Change log is here.

Future work is here.

Welcome back to the Particle System API!

The Particle System API has served as a resource for building all sorts of interesting particle system-based special effects, mostly for games and other interactive 3D graphics.
Version 2.2 was used in projects by over 600 developers. I dropped maintenance of the library in 2009 when my life switched to ray tracing, but I didn\’t effectively host the library publicly, so it largely died out.

I have recently revisited the API and added many enhancements. The most important is the inline action mode. The actions are now implemented in inline functions that apply to one particle. The application owns the loop over the particles, allowing a single pass over a particle to perform all actions. Performance is massively faster because of this for three main reasons:

  1. The compiler can optimize computations across all the actions on a particle,
  2. The particle is only loaded into memory once per time step, and
  3. The particle computations are trivially parallelized across cores, and potentially SIMD lanes by using std::for_each with a parallel execution policy on C++17.
    Performance is now at around 30 million particle updates per second on my laptop with a moderate CPU. And the inline actions should be usable in CUDA kernels for a major GPU speedup.

A few other notable updates:

  • The build system is now based on CMake.
  • The project is hosted on GitHub. Your collaboration is invited.
  • The sample effects are much more elegant and unified and are frame rate independent by varying dt with frame time.
  • There is a good flocking behavior effect, based on Craig Reynolds\’ Boids.

Building the Program

Building ParticleLib can be accomplished using just this code, CMake, and a C++ compiler.
It has no external dependencies.

However, the examples and demos also depend on DMcTools: https://gith*ub.*c*om/davemc0/DMcTools.git

DMcTools has my collection of graphics tools – matrix class, image stuff,
3D vector class, random numbers, timer, 3D model loader, etc.
It is only needed by the PSpray and ParBench demo, not the API or the Example demo.
DMcTools is copyright by me, and maybe others.

To build everything you will also need:

  • CMake 3.20 or newer. (You could try an older one, but no guarantees.)
  • FreeGLUT. I use 3.2.2.
  • GLEW. I use 2.2.0.

I set environment variables for GLUT_HOME and GLEW_HOME on Windows. This shouldn\’t be necessary on Linux or Mac.

How to build

In the main directory, do something like:

mkdir build
cd build
cmake .. -G \"Visual Studio 16 2019\" -A x64
cd ..

Then you can build from the command line:

cmake --build build/ --config Release

or launch build/ParticleSolution.sln in Visual Studio.

Example Code

Example

An OpenGL and GLUT-based example of particle systems used to render a fountain

Playground

Double-click to start the program.

Press \’f\’ to make it full screen.

Right-click in the window to pop up the menu.
The keyboard shortcuts are listed on the menu.

If you don\’t touch it, it will randomly go through the demos. This should provide hours of family fun.
If you get bored, press \’space\’ to cause an explosion.
Press \’m\’ to make cool motion blur.
Press \’s\’ to sort the particles back-to-front for more correct but slower rendering.
Press \’p\’ to change what each particle is rendered as.

Benchmark

This one runs all the same demo effects as Playground does,
but it doesn\’t do any graphics. It doesn\’t use OpenGL or GLUT.

Final Notes

If the demos don\’t work for you, I\’d be happy to try to help. Please include as much detail as
you can about your system and the nature of the problem.

If you have any questions, code contributions or suggestions use github issues or contact me however.

下载源码

通过命令行克隆项目:

git clone https://github.com/davemc0/Particle.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 开发教程 Particle https://www.zuozi.net/31251.html

front end
上一篇: front end
CyberEye
下一篇: CyberEye
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务