Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

particle.hxx Source File
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

particle.hxx

Go to the documentation of this file.
00001 //  $Id: particle.hxx,v 1.13 2003/01/05 20:51:02 grumbel Exp $
00002 // 
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 // 
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_CONSTRUO_PARTICLE_HXX
00021 #define HEADER_CONSTRUO_PARTICLE_HXX
00022 
00023 #include <iostream>
00024 #include "lisp_writer.hxx"
00025 #include "construo.hxx"
00026 #include "zoom_graphic_context.hxx"
00027 #include "vector2d.hxx"
00028 
00029 class Particle
00030 {
00031 private:
00033    int id;
00034 
00035 public:
00037   Vector2d pos;
00038 
00040   Vector2d  velocity;
00041 
00042 private:
00044   float mass;
00045 public:
00046   bool fixed;
00047 
00050   Vector2d totale_force;
00051 
00053   int spring_links;
00054 
00057   int get_id () {
00058     return id;
00059   }
00060 
00061   void add_force (const Vector2d& force)
00062   {
00063     if (fixed) return;
00064     totale_force += force;
00065   }
00066 
00067   void clear_force ()
00068   {
00069     totale_force = Vector2d ();
00070   }
00071 
00072   void set_fixed (bool f) {
00073     fixed = f;
00074   }
00075 
00076   bool get_fixed () {
00077     return fixed;
00078   }  
00079 
00080   inline float get_mass () const { return mass; }
00081 
00082   void update (float delta); 
00083   void draw (ZoomGraphicContext* gc);
00084 
00086   void draw_highlight (ZoomGraphicContext* gc);
00087   
00089   void draw_infos (ZoomGraphicContext* gc);
00090 
00091   void draw_velocity_vector (ZoomGraphicContext* gc);
00092 
00093   lisp_object_t* serialize();
00094 
00095   friend class ParticleFactory;
00096 
00097 private:
00098   // Nobody beside the ParticleFactory can create particles
00099   Particle (int id_, const Vector2d& arg_pos, const Vector2d& arg_velocity, float mass_, bool fixed_);
00100   Particle (const Particle&);
00101 };
00102 
00103 #endif
00104 
00105 /* EOF */

Generated on Thu Jul 24 10:24:30 2003 for Construo by doxygen1.3-rc3