Differences

This shows you the differences between two versions of the page.

documentation:particlesystem [2011/05/09 07:45]
tim [Class development problems]
documentation:particlesystem [2011/05/09 08:24] (current)
armageddon
Line 2: Line 2:
 ====== Particle System ====== ====== Particle System ======
 ===== General ===== ===== General =====
-Particle System in general is used to create all kinds of visual effects, like Smoke,Fire and Explosions. It's aim is to make Virtual environments more eye-catching and in case of many Games more realistic. +particle system in general is used to create all kinds of visual effects, like smokefire and explosions. It's aim is to make virtual environments more eye-catching and in case of many games more realistic. 
-So what the System is doing to make this possible is basically controlling the movements and looks of many little graphical objects (Particles), usually Quads+So what the system is doing to make this possible is basically controlling the movements and looks of many little graphical objects (particles), usually quads
-In The System which is implemented now are 3 Classes responsible for creating those Visual Effects+In the system which is implemented now are 3 classes responsible for creating those visual effects
-  * The Particle Class which forms one of those little graphical objects.  +  * The Particle class which forms one of those little graphical objects.  
-  * The ParticleEffect Class which currently builds an array of particles and controls their movements and looks. +  * The ParticleEffect class which currently builds an array of particles and controls their movements and looks. 
-  * The Effect Class contains a list of ParticleEffects because often there are more than one particle effect used to create visual effects like explosions e.g. for a simple explosion is fire and smoke needed. +  * The Effect class contains a list of ParticleEffects because often there is more than one particle effect used to create visual effects like explosions e.g. for a simple explosion fire and smoke are needed. 
  
  
Line 13: Line 13:
 ==== Main Tasks ==== ==== Main Tasks ====
  
-  - Ordered List Item Unordered List Item Saving all the attributes that are needed to draw the particle and those who can vary between single particles. +  - Saving all the attributes that are needed to draw the particle and those who can vary between single particles. 
-  - Ordered List Item Unordered List Item Drawing the particle.+  - Drawing the particle. 
 ==== Attributes ==== ==== Attributes ====
-For drawing needed attributes are:+Needed attributes for drawing are:
  
 <code java> <code java>
Line 34: Line 35:
    
 ==== Drawing ==== ==== Drawing ====
-Currently possible drawing Modes are:+Currently possible drawing modes are:
   * No texture drawing   * No texture drawing
   * One texture drawing   * One texture drawing
   * Two textures multi textured drawing   * Two textures multi textured drawing
 +
 === No texture drawing === === No texture drawing ===
-It is just as the mode name says in this mode there is no texture used to draw the particle quads. +It is just as the mode name says in this mode: There is no texture used to draw the particle quads. 
-Instead of that they have got all a color.+Instead of that they are just filled with a color. 
 === One texture drawing === === One texture drawing ===
-In this drawing mode is one texture, the material texture, bind on the quad an used for drawing.+This mode draws the particles using one texture, the material texture. 
 === Two textures multi textured drawing === === Two textures multi textured drawing ===
 Now it's getting interesting because in OpenGL you have the possibility to draw more than one texture over the same graphical object. Now it's getting interesting because in OpenGL you have the possibility to draw more than one texture over the same graphical object.
 OpenGL has different options which define how those textures are mixed together, the option which is used in here is GL_MODULATE. OpenGL has different options which define how those textures are mixed together, the option which is used in here is GL_MODULATE.
-In this option the colors of each particle of the texture are added up to create the final texture on the graphic object. +In this option the colors of each particle of the texture are added up to create the final texture on the graphical object. 
-This makes it possible to use transparency maps witch you can lay on a material texture in order to let the particle look like a quad or star, despite of the fact that the graphical object is a quad. +This makes it possible to use transparency maps which you can lay on a material texture in order to let the particle look like a quad or star, despite of the fact that the graphical object is a quad. 
-This makes it easier to create the particle effect you want.+This makes it easier to create the desired particle effect.
  
    
 ==== Class development problems ==== ==== Class development problems ====
-The only problem which occurred while developing this class where problems with OpenGL in the multi textured drawing mode. +The only problem which occurred while developing this class were problems with OpenGL in the multi textured drawing mode. 
-The problem was when I drawed this mode everything except of the particle effect on the screen disappeared, regardless of the fact that the textures were bind properly to the quad. +The problem was when I drawed this mode everything except of the particle effect on the screen disappeared, regardless of the fact that the textures were bound properly to the quad. 
-at that time the code looked like this:+At that time the code looked like this:
 <code java>      <code java>     
              glEnable(GL_TEXTURE_2D);              glEnable(GL_TEXTURE_2D);
Line 87: Line 91:
                 glEnd();                 glEnd();
 </code>  </code> 
-The source of the problem was that graphicards today usually have got 32 places where they can save Textures (OpenGl refers to them with GL_TEXTURE0_ARB to GL_TEXTURE31_ARB),and the first of the is by default used to handle single texturing. But if you want to use multi-texturing you have to use multiple of these places and only the one currently used is activated. The last one I activated in the code above was GL_TEXTURE1_ARB and so all graphic objects which uses single texturing couldn't be drawed since GL_TEXTURE0_ARB was deactivated.+The source of the problem was that graphics cards today usually have got 32 places where they can save textures (OpenGL refers to them as GL_TEXTURE0_ARB through GL_TEXTURE31_ARB), and the first of them is by default used to handle single texturing. But if you want to use multi-texturing you have to use multiple of these places and only the one currently used is activated. The last one I activated in the code above was GL_TEXTURE1_ARB and so all graphical objects using single texturing couldn't be drawn since GL_TEXTURE0_ARB was deactivated.
 The problem was solved by adding those lines: The problem was solved by adding those lines:
 <code java> <code java>
Line 94: Line 98:
                 glActiveTextureARB(GL_TEXTURE0_ARB);                 glActiveTextureARB(GL_TEXTURE0_ARB);
 </code> </code>
 +
 ====== ParticleEffect class ====== ====== ParticleEffect class ======
 ==== Main Tasks ==== ==== Main Tasks ====
-  - build the particles which are used for this effect. +  - Build the particles which are used for this effect. 
-  - control the particle movements and looks though the effect.+  - Control the particle movements and visuals though the effect. 
 ==== Particle building ==== ==== Particle building ====
  
-The Particle building is a crucial thing for the particle effect and it's look. Because you want the particles to vary all in their attributes to make effects like smoke look more realistically. But although you want them not to be to random because if thats the case than you will be unable to design the effect you want.  +The particle building is a crucial thing for the particle effect and it's visuals. Because you want all the particles to vary in their attributes to make effects like smoke look more realistically. But you also don't want them to be too random because then you will be unable to design the effect you want.  
 The methods that can be used to generate those different start attributes are: The methods that can be used to generate those different start attributes are:
 <code java> <code java>
 protected float setRichtung(float Angle, float spannweite){...} protected float setRichtung(float Angle, float spannweite){...}
  
- +//Methods for calculating a random speed value
-//Methoden zur berechnung eines Zufalls Geschwindikeitswerts+
 protected Vector3D setSpeed(float generalSpeed,float angle){...} protected Vector3D setSpeed(float generalSpeed,float angle){...}
  
 protected Vector3D setSpeed(float maxSpeed,float minSpeed, float angle){...} protected Vector3D setSpeed(float maxSpeed,float minSpeed, float angle){...}
  
-//Generiert die Zufalls LebensWerte der Particel+//Generates random life-values of the particles
 protected float setLife(float maxLife,float minLife){...} protected float setLife(float maxLife,float minLife){...}
 protected float setLife(float maxLifep){...} protected float setLife(float maxLifep){...}
  
-//Erstellt die Rotations Geschwindigkeit und Richtung+//creates the rotation speed and direction
 protected float setRotation(){...} protected float setRotation(){...}
 protected float setVRotation(float vRotationGeneral){...} protected float setVRotation(float vRotationGeneral){...}
Line 122: Line 127:
  
  
-//Methode zur berechnung des Geschwindikeitsvektors eines Partikels.+//Method for calculating the speed vector of a particle
 private Vector3D setSpeedVect(float speed, float angle){...} private Vector3D setSpeedVect(float speed, float angle){...}
 </code> </code>
-==== Controling particle movements and looks (Tick Function)==== 
  
-Only through doing that the particle effect really looks like one.  +==== Controling particle movements and visuals (Tick Function)==== 
-If it wouldn't be done no particle would move, fade over time, rotate, change it's size and so on. + 
-The problem in doing this was to create a construct of methods which are easy to understand, well arranged, and easily adaptable. +Only by doing that the particle effect really looks like one.  
-My current solution is a construct of methods which begins with this tick function:+If it wouldn't be doneno particle would move, fade over time, rotate, change it's size and so on. 
 +The problem in doing this was to create a construct of methods which is easy to understand, well arranged, and easily adaptable. 
 +My current solution is a construct of methods that begins with this tick function: 
 <code java> <code java>
 public void tick(){ public void tick(){
Line 147: Line 154:
 } }
 </code> </code>
-It basically divides the tick in two types the tick of an particle when its "alive" and the tick when it "dies"(when its current life would be grater than its maximal) which leads to the next two functions: + 
-The aliveTick+It basically divides the tick in two types: The tick of particle when its "alive" and the tick when it "dies" (when its current life would be grater than its maximal life) which leads to the next two functions: 
 + 
 +The aliveTick
 <code java> <code java>
 protected void  protected void 
Line 162: Line 172:
 } }
 </code> </code>
-this function only calls up all functions who are changing values when the particle is still alive. So if you got a new variable for the Particle that although has to be changed through the life of the particle, the only thing you have to do is write the changing method and add it here. + 
-The same idea follows the dieTick() function in which all functions are called up which changes particle attributes in case of its "dead" most of them are reset methods:+This function only calls up all functions that are changing values when the particle is still alive. So if you got a new variable for the particle that also has to be changed through the life of the particle, the only thing you have to do is write the changing method and add it here. 
 +The dieTick() function follows the same idea in which all functions are called up which changes particle attributes and in case of its "death" most of them are reset methods: 
 <code java> <code java>
 protected void dieTick(Particle tempParticle){ protected void dieTick(Particle tempParticle){
Line 182: Line 194:
 } }
 </code> </code>
 +
 ==== Class development problems ==== ==== Class development problems ====
-The most difficult thing to write in this class were the functions which controls the attribute changes in each Tick(). +The most difficult thing to write in this class were the functions that control the attribute changes in each Tick(). 
-Thats because some of them have got some difficult algorithm in them.+That is because some of them have got some difficult algorithms in them.
 For example this one: For example this one:
 +
 <code java> <code java>
         Vector3D newV= new Vector3D(tempParticle.getInitial_v().getX()*(1-(speed_decay*tempParticle.getLife())),         Vector3D newV= new Vector3D(tempParticle.getInitial_v().getX()*(1-(speed_decay*tempParticle.getLife())),
Line 191: Line 205:
         return newV;         return newV;
 </code> </code>
 +
 The first algorithm was about 4 times as long as this one and didn't work. The first algorithm was about 4 times as long as this one and didn't work.
 Though there weren't many functions which did the thing I wanted them to do after the first try of writing them. Though there weren't many functions which did the thing I wanted them to do after the first try of writing them.
  
 ===== Effect Class ===== ===== Effect Class =====
-For this class i will keep the Description short because the only thing its needed for is that you can ad as many ParticleEffects to it as you want.+will keep the description short for this class because the only thing it does is managing as many ParticleEffects as you want.
  
 
 documentation/particlesystem.txt · Last modified: 2011/05/09 08:24 by armageddon
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Driven by DokuWiki