/***************************************************************************
* Copyright (C) 2004 by Raphael Langerhorst *
* raphael-langerhorst@gmx.at *
* *
* Permission is hereby granted, free of charge, to any person obtaining *
* a copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to *
* the following conditions: *
* *
* The above copyright notice and this permission notice shall be *
* included in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
* OTHER DEALINGS IN THE SOFTWARE. *
***************************************************************************/
#include "GSolarsystemCategory.h"
#include "GRadiatingAgent.h"
#include "GMoveAgent.h"
#include "GAttractAgent.h"
#include "GEnergyFormAgent.h"
#include "GDynamicGeneratorAgent.h"
#include "GPlanetCategory.h"
using namespace GCS;
using namespace GBE::Util;
namespace GBE {
GSolarsystemCategory::GSolarsystemCategory(double range)
: GDynamicGeneratorCategory(range, 20, 50, FALSE)
{
}
GSolarsystemCategory::~GSolarsystemCategory()
{
}
// GCS::GElement* GSolarsystemCategory::createElement(GCS::GEnergy* energy, const GCS::GVector3& position, double seconds_passed, unsigned long seed)
// {
// PseudoRNG rng;
// rng.setNumber(seed);
// double size_rand = rng.getNumberDouble();
// double size_rand = this->SizeMin + size_rand*(this->SizeMax - this->SizeMin);
//
// GOpenGLForm* form = new GOpenGLForm(position,GVector3(rng.getNumberDouble()*3.14,rng.getNumberDouble()*3.14,rng.getNumberDouble()*3.14),size_rand);
// form->RGBA[0] = rng.getNumberDouble();
// form->RGBA[1] = rng.getNumberDouble();
// form->RGBA[2] = rng.getNumberDouble();
// form->RGBA[3] = 0.5 + rng.getNumberDouble()*0.5;
//
// // GObject* object = new GObject(
// }
GForm* GSolarsystemCategory::createForm(const GEnergy& energy, const GVector3& position, PseudoRNG& rng) const
{
double radius_rand = rng.getNumberDouble();
radius_rand = this->RadiusMin + radius_rand*(this->RadiusMax - this->RadiusMin);
GForm* form = new GForm( position,GVector3(rng.getNumberDouble()*3.14,rng.getNumberDouble()*3.14,rng.getNumberDouble()*3.14),GVector3(radius_rand,radius_rand,radius_rand));
if (form==NULL)
{
return NULL;
}
// form->RGBA[0] = rng.getNumberDouble();
// form->RGBA[1] = rng.getNumberDouble();
// form->RGBA[2] = rng.getNumberDouble();
// form->RGBA[3] = 0.5 + rng.getNumberDouble()*0.5;
return form;
}
void GSolarsystemCategory::postProcess(GCS::GElement* element, Util::PseudoRNG& rng) const
{
// QPtrList<GAgent> list;
// GAgent* a = new GReparentAgent();
// if (a)
// list.append(a);
//@todo find a useful combination of agents
// a = new GMoveAgent(0.01,100);
// if (a)
// list.append(a);
//
// a = new GAttractAgent();
// if (a)
// list.append(a);
//
// a = new GRadiatingAgent(0.01,energy.amount()*0.1,energy.amount()*10,1000);
// if (a)
// list.append(a);
GPlanetCategory* planets = new GPlanetCategory(0.01);
Q_CHECK_PTR(planets);
if (planets)
{
GDynamicGeneratorAgent* generator = new GDynamicGeneratorAgent();
Q_CHECK_PTR(generator);
// rng.getNumberInt(),category_list,QDateTime::currentDateTime(),3,true)
element->addAgent(generator);
generator->initRandomSeed(rng.getNumberInt());
generator->initCategory(planets);
generator->initCreationTime(QDateTime::currentDateTime());
generator->initDensity(3);
generator->initAllAtOnce(true);
}
GEnergyFormAgent* efa = new GEnergyFormAgent();
Q_CHECK_PTR(efa);
if (efa)
{
element->addAgent(efa);
efa->initAlpha(rng.getNumberDouble()*0.5+0.3);
efa->initSizeFactorEnabled(false);
}
// return list;
}
}
syntax highlighted by Code2HTML, v. 0.9.1