1 // $Id: particle.hxx,v 1.16 2003/07/27 18:46:11 grumbel Exp $
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_CONSTRUO_PARTICLE_HXX
21 #define HEADER_CONSTRUO_PARTICLE_HXX
24 #include "lisp_writer.hxx"
25 #include "construo.hxx"
26 #include "zoom_graphic_context.hxx"
27 #include "vector2d.hxx"
32 /** Id of the particle */
36 /** position of the particle */
39 /** velocity of the particle */
43 /** the mass of the particle as 1/mass (FIXME: is this still the
47 /** If true the particle will have a fixed position which cannot be
48 changed, if false the particle reacts to forces as normal. */
51 /** totale force acting on particle (used as temp-var in update() to
53 Vector2d totale_force
;
55 /** Number of connection this particle has to other springs */
58 /** The id of the particle, used for de/serialisation and copying of
59 the World. The id is uniq only for a single world. */
60 inline int get_id () const {
64 void add_force (const Vector2d
& force
)
67 totale_force
+= force
;
72 totale_force
= Vector2d ();
75 void set_fixed (bool f
) {
83 inline float get_mass () const { return mass
; }
85 void update (float delta
);
86 void draw (ZoomGraphicContext
* gc
);
88 /** draws the particle in highlight mode (aka if mouse is over it) */
89 void draw_highlight (ZoomGraphicContext
* gc
);
91 /** draws additional infos to this stop */
92 void draw_infos (ZoomGraphicContext
* gc
);
94 void draw_velocity_vector (ZoomGraphicContext
* gc
);
96 lisp_object_t
* serialize();
98 friend class ParticleFactory
;
101 // Nobody beside the ParticleFactory can create particles
102 Particle (int id_
, const Vector2d
& arg_pos
, const Vector2d
& arg_velocity
, float mass_
, bool fixed_
);
103 Particle (const Particle
&);