GDynamicGeneratorAgent.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 - 2004 Martin Reinsprecht                          *
00003  *   martin.reinsprecht@activenet.at                                       *
00004  *   Copyright (C) 2004 - 2006 by Raphael Langerhorst                      *
00005  *   raphael-langerhorst@gmx.at                                            *
00006  *                                                                         *
00007  *   Permission is hereby granted, free of charge, to any person obtaining *
00008  *   a copy of this software and associated documentation files (the       *
00009  *   "Software"), to deal in the Software without restriction, including   *
00010  *   without limitation the rights to use, copy, modify, merge, publish,   *
00011  *   distribute, sublicense, and/or sell copies of the Software, and to    *
00012  *   permit persons to whom the Software is furnished to do so, subject to *
00013  *   the following conditions:                                             *
00014  *                                                                         *
00015  *   The above copyright notice and this permission notice shall be        *
00016  *   included in all copies or substantial portions of the Software.       *
00017  *                                                                         *
00018  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
00019  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
00020  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
00021  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
00022  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
00023  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
00024  *   OTHER DEALINGS IN THE SOFTWARE.                                       *
00025  ***************************************************************************/
00026 
00027 #ifndef GBEGDYNAMICGENERATORAGENTH
00028 #define GBEGDYNAMICGENERATORAGENTH
00029 
00030 #include "PseudoRNG.h"
00031 
00032 #include "GDynamicGeneratorCategory.h"
00033 
00034 #include <GElementInfluence.h>
00035 #include <GAgent.h>
00036 #include <GElement.h>
00037 #include <GEnergy.h>
00038 #include <GVector3.h>
00039 
00040 #include <QDateTime>
00041 #include <QList>
00042 
00043 namespace GBE
00044 {
00045 
00046 
00047 //this is defined in the implementation file as it is specifically created for this agent
00048 class GDynamicGeneratorOctreeNode;
00049 
00050 
00134 class GDynamicGeneratorAgent : public GCS::GAgent
00135 {
00136   Q_OBJECT
00137 
00138   private:
00139 
00147     double EnergyFractionChildCreation;
00148 
00153     bool EnergyFractionDirtyFlag;
00154     
00155   protected:
00156 
00167     bool DataLoaded;
00168   
00172     unsigned long RandomSeed;
00173     
00183     QList<GDynamicGeneratorCategory*> Categories;
00184   
00189     QDateTime CreationTime;
00190     
00199     unsigned short Density;
00200     
00209     bool CreateAllAtOnce;
00210     
00217     double CreationRangeFactor;
00218     
00222     Util::PseudoRNG RNG;
00223     
00227     GDynamicGeneratorOctreeNode* TopNode;
00228     
00229   protected:
00230   
00237     void generateInArea(const GCS::GVector3& position, double radius);
00238     
00249     void recursiveGeneration(GDynamicGeneratorOctreeNode* node, const GCS::GVector3& position, double radius, short unsigned depth);
00250     
00264     virtual bool checkGenerationPlausibility(const GDynamicGeneratorCategory& category, const GCS::GVector3& position);
00265     
00270     virtual GCS::GElement* createElement(const GDynamicGeneratorCategory& category, const GCS::GVector3& position);
00271 
00272 
00280     virtual void loadData(bool force = false);
00281   
00282   public:
00288     GDynamicGeneratorAgent();
00289 
00293     virtual ~GDynamicGeneratorAgent();
00294 
00302     virtual void receiveInfluence(const GCS::GElementInfluence& influence);
00303 
00304 
00305     //BEGIN XML Element Data initialization
00306 
00307     //see also loadData()
00308 
00314     virtual void initRandomSeed(unsigned long random_seed);
00315 
00320     virtual void initCreationTime(QDateTime creation_time = QDateTime::currentDateTime());
00321 
00330     virtual void initDensity(unsigned short density);
00331 
00340     virtual void initAllAtOnce(bool create_all_at_once);
00341     
00345     virtual void initCreationRangeFactor(double range_factor);
00346 
00360     virtual void initCategory(GDynamicGeneratorCategory* category);
00361 
00362     //END XML Element Data initialization
00363 };
00364 
00365 }
00366 
00367 #endif

Generated on Thu Nov 16 07:49:12 2006 for G System by  doxygen 1.4.7