/***************************************************************************
 *   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 "GPlanetCategory.h"

#include "GRadiatingAgent.h"
#include "GMoveAgent.h"
#include "GAttractAgent.h"
#include "GEnergyFormAgent.h"

using namespace GCS;

namespace GBE 
{

GPlanetCategory::GPlanetCategory(double range)
: GDynamicGeneratorCategory(range, 0.1, 0.5, false)
{
}


GPlanetCategory::~GPlanetCategory()
{
}


GCS::GForm* GPlanetCategory::createForm(const GCS::GEnergy& energy, const GCS::GVector3& position, Util::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));
  
//   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 GPlanetCategory::postProcess(GCS::GElement* element, Util::PseudoRNG& rng) const
{
  GEnergyFormAgent* efa = new GEnergyFormAgent();
  Q_CHECK_PTR(efa);
  if (efa)
  {
    element->addAgent(efa);
//     efa->initSizeFactor(GCS::GVector3(20,20,20));
    efa->initSizeFactorEnabled(false);
    efa->initAlpha(rng.getNumberDouble()*0.3 + 0.7);
  }
  
//   QPtrList<GAgent> list;
//   GAgent* a = new GReparentAgent();
//   if (a)
//     list.append(a);
    
  //@todo find a useful combination of agents.
    
//   a = new GMoveAgent(0.01,50);
//   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);
    
//   return list;
}

};


syntax highlighted by Code2HTML, v. 0.9.1