Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9465

Re: particle container in Java

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From BGB <cr88192@hotmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: particle container in Java
Date Thu, 03 Nov 2011 13:51:38 -0700
Organization albasani.net
Lines 69
Message-ID <j8uutg$dhb$1@news.albasani.net> (permalink)
References <17fed3e9-15e0-466c-bb24-10e74633ea1b@t8g2000yql.googlegroups.com> <hlb5b7pfb0kanf6knl8l813gjr8m4q6ckt@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net GInXu394OuOWXtWx6F+l4c6gnLEtS96ZITJkgt4stvniPbEsbMc267/+hxy0YTeW5R1LHZD8XWmFwwaBpX9xaqvQhunoz6lK0ZDBf+B4Y+J6RsoryTyimy0ccKDJhNZF
NNTP-Posting-Date Thu, 3 Nov 2011 20:52:01 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="0d17gSdqzvmFugtWhi9+HccgC5cAvJGguWb2PmsVvkVXG+aPB2hJzDSaKn7v3w0tBSVIKpCq0yW91v2BkeGO3BJ8iUrUUSgWNhrqcxrRlHMDV68Y14iDNYRuAQj8T/3y"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
In-Reply-To <hlb5b7pfb0kanf6knl8l813gjr8m4q6ckt@4ax.com>
Cancel-Lock sha1:J1LpunopV4LBzVZRMXX7yC9uvio=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9465

Show key headers only | View raw


On 11/3/2011 8:12 AM, Roedy Green wrote:
> On Thu, 3 Nov 2011 01:05:59 -0700 (PDT), bob<bob@coolgroups.com>
> wrote, quoted or indirectly quoted someone who said :
>
>> What is the best data structure to use for a particle container in
>> Java?
>
> Possibly a hanging moss structure.  See
> http://mindprod.com/jgloss/hangingmoss.html
>
> I assume your problem is you have objects larger than a pixel that
> move around in some pseudorandom way and you have to keep computing
> their new positions and rendering the result?
>
> The advantage of hanging moss is you can find objects quickly within a
> region, and you can rapidly find objects close to a given one -- so
> can do collision-rebound logic.

yep...

in my 3D engine (mostly written in plain C) I use a BSP-tree style 
structure.


in this case, it will form an approximate binary tree of all of the 
particles (via an estimated centroid and balance normal, which is used 
to calculate the current division plane), and will occasionally 
re-balance the tree as new particles spawn and die.

the tree can also serve to sort the particles (more or less) from 
back-to-front, allowing drawing them with Z-buffering disabled and 
getting the desired blending effects (if one draws alpha-blended 
particles with Z-buffering enabled, they may clip in nasty looking ways, 
so best results are to disable Z-buffering).

(sadly, particles/models/scene-geometry are not themselves interlaced 
and drawn in proper back-to-front ordering, mostly creating issues with 
alpha-blended objects/particles/sprites/... interacting badly with windows).


I had before experimented with adding inter-particle interactions 
(attractive and repulsive forces), but this dropped the framerate too 
much and caused lots of funky behavior, so generally particles don't 
interact (most particle effects neither really need nor benefit from 
inter-particle forces).

the issue is mostly the large numbers of particles needed to make things 
like like fire effects, ... look decent.


I also have some particle effects which use fragment shaders (such as 
trying to fake flowing water), but sadly particles+shaders does bad 
things to the framerate (so, presently each is drawn as a largish disk). 
it looked better with spheres, but this did too much damage to the 
framerate.

sadly, making "realistic" flowing water which is more than simply a 
visual effect (IOW: has physics, interacts with the player, ...) would 
be a somewhat more complex problem.

the more "traditional" way of representing fluids is by using large 
brushes/polyhedra representing the fluid (giant cubes of "water" and 
similar). however, these can't "flow", and although particle-based water 
can flow, it is much more computationally expensive and expensive to 
render. in this case, fluids would likely exist as semi-solid 
frictionless spheres.


or such...

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

particle container in Java bob <bob@coolgroups.com> - 2011-11-03 01:05 -0700
  Re: particle container in Java Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-03 08:33 +0000
  Re: particle container in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-11-03 08:12 -0700
    Re: particle container in Java BGB <cr88192@hotmail.com> - 2011-11-03 13:51 -0700
      Re: particle container in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-11-04 15:54 -0700
        Re: particle container in Java BGB <cr88192@hotmail.com> - 2011-11-04 19:48 -0700
          Re: particle container in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-11-05 06:42 -0700
  Re: particle container in Java Giovanni Azua <bravegag@hotmail.com> - 2011-11-03 23:38 +0100
    Re: particle container in Java BGB <cr88192@hotmail.com> - 2011-11-03 22:41 -0700
      Re: particle container in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-11-05 06:49 -0700
        Re: particle container in Java BGB <cr88192@hotmail.com> - 2011-11-05 09:16 -0700
          Re: particle container in Java Roedy Green <see_website@mindprod.com.invalid> - 2011-11-06 03:07 -0800
            Re: particle container in Java Giovanni Azua <bravegag@hotmail.com> - 2011-11-06 15:15 +0100
              Re: particle container in Java BGB <cr88192@hotmail.com> - 2011-11-06 11:06 -0700
  Re: particle container in Java Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 19:03 -0400

csiph-web