//  World.h - handles interactions between a car and its environment.
//
//	Vamos Automotive Simulator
//  Copyright (C) 2001--2004 Sam Varner
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#ifndef _WORLD_H_
#define _WORLD_H_

#include <vamos/body/Car.h>
#include <vamos/geometry/Material.h>
#include <vamos/geometry/Three_Vector.h>
#include <vamos/track/Track.h>
#include <vamos/world/Atmosphere.h>

#include <vector>

namespace Vamos_World
{
  typedef Vamos_Geometry::Material::Material_Type Mat_Type;

  struct Contact_Info
  {
	Contact_Info (Mat_Type car_material_type, Mat_Type track_material_type,
				  double par_speed, double perp_speed)
	  : car_material (car_material_type),
		track_material (track_material_type),
		parallel_speed (par_speed),
		perpendicular_speed (perp_speed)
	{};

	Mat_Type car_material;
	Mat_Type track_material;
	double parallel_speed;
	double perpendicular_speed;
  };

  class World
  {
  protected:
	Vamos_Body::Car* mp_car;
	Vamos_Track::Track* mp_track;
	Atmosphere* mp_atmosphere;

	double m_gravity;

	std::vector <Contact_Info> m_contact_info;

	void reset ();
	void restart ();

  public:
	World (Vamos_Track::Track* track, Atmosphere* atmosphere);
	virtual ~World ();

	void interact (Vamos_Body::Body* body);
	void gravity (double g);
	virtual void set_car (Vamos_Body::Car* car);
  };
}

#endif // not _WORLD_H_
