Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Particle Engine Physics  (Read 1675 times)
0 Members and 1 Guest are viewing this topic.
Offline Slyth2727
« Posted 2013-02-03 19:03:08 »

I am programming a particle engine for the heck of it in Java just to have for future games. I have it at the point where it can handle a decent amount of particles, have multiple gravity wells and toggle ground gravity...

What I would like to do is add a method to see if there are many particles close together make their colors kind of gradient outwards almost like magma.
Also if you can think of a way to make the particles react to eachother such as stacking up in a heap on the ground instead of all going into a flat line.

Help is appreciated, thanks cMp

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 142
Projects: 4
Exp: 3 years



« Reply #1 - Posted 2013-02-03 19:11:11 »

I haven't made a particle engine by myself before but I think you are looking for additive blending.
Offline Slyth2727
« Reply #2 - Posted 2013-02-03 19:12:59 »

Yes thats what I am thinking, but I am not sure how to do this

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Slyth2727
« Reply #3 - Posted 2013-02-03 19:30:26 »

Any ideas? Also if it helps I am rendering it using Graphics but I am not sure if I should convert it to BufferedImage for performance

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 142
Projects: 4
Exp: 3 years



« Reply #4 - Posted 2013-02-03 19:34:12 »

Sorry that I can't help you more but I dug up a few posts:
http://www.java-gaming.org/index.php?topic=19891.0
http://www.java-gaming.org/topics/alpha-additive-blending-with-composide-and-graphics2d/22467/view.html

Although if I recall correctly this sort of blending is not very possible in Java2D...
Offline Slyth2727
« Reply #5 - Posted 2013-02-03 19:37:35 »

Here check this video out, this guy did this in just java the only difference is he renders his in a buffered image

]http://www.youtube.com/watch?v=_F8lbnTR6ew]

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Slyth2727
« Reply #6 - Posted 2013-02-03 19:39:22 »

This is exactly what I am aiming for

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 142
Projects: 4
Exp: 3 years



« Reply #7 - Posted 2013-02-03 19:41:56 »

That guy did post the source - http://pastebin.com/raw.php?i=DSVWBUzy

It appears he's using this for blending:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public int additiveColor(int c1, int c2){ // my additive color blender
       
        int red = (c1 & 0x00ff0000) + (c2 & 0x00ff0000);
        int grn = (c1 & 0x0000ff00) + (c2 & 0x0000ff00);
        int blu = (c1 & 0x000000ff) + (c2 & 0x000000ff);
       
        if( red > 0x00ff0000 )
            red = 0x00ff0000;
       
        if( grn > 0x0000ff00 )
            grn = 0x0000ff00;
       
        if( blu > 0x000000ff )
            blu = 0x000000ff;
       
        return 0xff000000 + red + grn + blu;
    }

Offline Slyth2727
« Reply #8 - Posted 2013-02-03 19:45:28 »

yes I saw that but which variables would I plug in?

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Slyth2727
« Reply #9 - Posted 2013-02-03 20:58:51 »

Ok he posted on a video this:

In my newest version, which is simpler/better than this one I set every pixel on the screen as a zero, and then add one where every particle is. So if 8 particles are overlapping a pixel, the BufferedImage stores a value of 8. The cap is 10, so if more than 10 pixels are overlapping, the value is 10. Then what I do is iterate through the entire BufferedImage, and for every single pixel, the value is mapped to a gradient stored in an array of colors. So the color when value is 3 is = gradient[3];

Can anyone think of a way to do this with Graphics2D? I have played around with it for a while to no avail

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Slyth2727
« Reply #10 - Posted 2013-02-03 22:13:42 »

Right so my last post didnt get a lot of answers at all so I am posting another one BUT its on something else, not colors. I was wondering what the best way would be to make the particles "stack" in piles like sand? When gravity is enabled I would like the particles to fall in a pile instead of all falling flat on the ground?
Thanks, cMp

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 847
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2013-02-03 22:18:43 »

Topics merged for asking the same question twice  Pointing

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline Slyth2727
« Reply #12 - Posted 2013-02-04 00:12:00 »

I really need help with these two things, I have been trying for about 3 and a half hours with no progress Sad

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 142
Projects: 4
Exp: 3 years



« Reply #13 - Posted 2013-02-04 00:19:57 »

I really need help with these two things, I have been trying for about 3 and a half hours with no progress Sad
You do realize 3.5 hours on 2 problems is nothing?
Offline Slyth2727
« Reply #14 - Posted 2013-02-04 00:21:47 »

yes I do I have spent much more time on other things but this seems like such a simple thing to solve and I am starting to feel very stupid.

Was I before Chuang Tzu who dreamt about being a butterfly, or am I now a butterfly who dreams about being Chuang Tzu?
Offline zngga
« Reply #15 - Posted 2013-02-04 04:50:28 »

Pro tip #64: If you want help with code that isn't working how you expect it to work, then showing that code is very helpful.

This does two things for us, the ones helping you. First it shows us what you have already, what you still need to implement, and exposes any logic errors you may have. Second, and in my opinion the most important, showing us your progress proves that you are actually working on solving the issue on your own, and are not just posting in hopes of free copy-paste code.

Pro tip #128: Avoid at all cost the Double-Post-of-Doom  Wink


On a personal aside; expecting a lot of answers to a vague question over the course of 3 hours is a little unreasonable, given that this community if comprised of individuals from all over the World.

Edit: I don't sugar coat anything Smiley

My code never has bugs... it just develops unexpected features!
Offline Varkas
« Reply #16 - Posted 2013-02-04 11:40:16 »

Also if you can think of a way to make the particles react to eachother such as stacking up in a heap on the ground instead of all going into a flat line.

For this you need to assign a size (box or radius) to the particles, and have some collision checking implemented. I think though that the idea of particles was just to have a very simple something which computes efficiently. By adding size and collision detection your particles become real objects and either you'll have to implement a quite efficient collision detections strategy or face a notable slowdown.

IMO keep particles simple. If you need something more detailed, it's not particles anymore and needs different approaches.

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (24 views)
2014-12-23 03:34:11

rwatson462 (54 views)
2014-12-15 09:26:44

Mr.CodeIt (45 views)
2014-12-14 19:50:38

BurntPizza (85 views)
2014-12-09 22:41:13

BurntPizza (110 views)
2014-12-08 04:46:31

JscottyBieshaar (79 views)
2014-12-05 12:39:02

SHC (89 views)
2014-12-03 16:27:13

CopyableCougar4 (97 views)
2014-11-29 21:32:03

toopeicgaming1999 (155 views)
2014-11-26 15:22:04

toopeicgaming1999 (153 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!