Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

p_system.cpp

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:15 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: p_system.cpp,v 1.1.1.1 2002/12/07 19:02:15 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: p_system.cpp,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:15  kolrabi
00031   initial release
00032 
00033 
00034 */
00035 
00040 #include            "omicron/internal.h"
00041 #include            "omicron/render.h"
00042 #include            "omicron/particle.h"
00043 #include            "omicron/array.h"
00044  
00045 /**************************************************************************** 
00046  **************************************************************************** 
00047  * PARTICLE SYSTEM ********************************************************** 
00048  **************************************************************************** 
00049  ****************************************************************************/ 
00050  
00051 particle_system_c::particle_system_c()
00052 {
00053     emitters = new array_c<particle_emitter_c>;
00054     types    = new array_c<particle_type_c>;
00055 }
00056 
00057 particle_system_c::~particle_system_c()
00058 {
00059     remove_all_emitters();
00060     remove_all_types();
00061 
00062     SafeDelete(emitters);
00063     SafeDelete(types);
00064 }
00065 
00066 void
00067 particle_system_c::remove_all_emitters
00068 ()
00069 {
00070     for (int i=0; i<emitters->get_count(); i++)
00071     {
00072         particle_emitter_c *pe = emitters->get(i);
00073         if (pe)
00074         {
00075             emitters->remove(i);
00076             SafeDelete(pe);
00077         }
00078     }
00079 }
00080 
00081 void
00082 particle_system_c::remove_all_types
00083 ()
00084 {
00085     for (int i=0; i<types->get_count(); i++)
00086     {
00087         particle_type_c *pt = types->get(i);
00088         if (pt)
00089         {
00090             types->remove(i);
00091             SafeDelete(pt);
00092         }
00093     }
00094 }
00095 
00096 slong
00097 particle_system_c::add_emitter
00098 (
00099         particle_emitter_c *e                           
00100 )
00101 {
00102     AssertReturnValue2(e, emitters, INVALID_INDEX);
00103 
00104     e->psystem = this;
00105     return emitters->add(e);
00106 }
00107 
00108 void
00109 particle_system_c::remove_emitter
00110 (
00111         particle_emitter_c *e                           
00112 )
00113 {
00114     AssertReturn2(e, emitters);
00115 
00116     emitters->remove_ptr(e);
00117 }
00118 
00119 slong
00120 particle_system_c::add_type
00121 (
00122         particle_type_c *t                                      
00123 )
00124 {
00125     AssertReturnValue2(t, types, INVALID_INDEX);
00126 
00127     t->psystem = this;
00128     return types->add(t);
00129 }
00130 
00131 void
00132 particle_system_c::update
00133 ()
00134 {
00135     int i;
00136 
00137     for (i=0; i<emitters->get_count(); i++)
00138     {
00139         particle_emitter_c *pe = emitters->get(i);
00140         if (pe)
00141             pe->update();
00142     }
00143 
00144     for (i=0; i<types->get_count(); i++)
00145     {
00146         particle_type_c *pt = types->get(i);
00147         if (pt)
00148             pt->update();
00149     }
00150 }
00151 
00152 void
00153 particle_system_c::draw
00154 ()
00155 {
00156     for (int i=0; i<types->get_count(); i++)
00157     {
00158         particle_type_c *pt = types->get(i);
00159         if (pt)
00160             pt->draw();
00161     }
00162 }
00163 
00164 particle_s::particle_s()
00165 {
00166     pos.clear();
00167     speed.clear();
00168     accel.clear();
00169 
00170     color.set(1, 1, 1, 1);
00171 
00172     size.set(1,1);
00173 
00174     angle           = 0;
00175     dir.clear();
00176 
00177     birthtime       = 0;
00178 
00179 //    alignmotiondone = false;
00180     alife           = false;
00181 }

Generated on Wed Dec 18 15:48:47 2002 for omicron engine by doxygen1.2.18