1 /*
2  * NodePositionChaser2D.h
3  *
4  * Copyright (C) 2009 J. "MUFTI" Scheurich
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program (see the file "COPYING" for details); if
18  * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19  * Cambridge, MA 02139, USA.
20  */
21 
22 #pragma once
23 
24 #include "Node.h"
25 #include "ProtoMacros.h"
26 #include "Proto.h"
27 #include "SFMFTypes.h"
28 #include "ChaserNode.h"
29 
30 class ProtoPositionChaser2D : public ChaserProto {
31 public:
32                     ProtoPositionChaser2D(Scene *scene);
33     virtual Node   *create(Scene *scene);
34 
getType()35     virtual int     getType() const { return X3D_POSITION_CHASER_2D; }
36 
37     FieldIndex initialDestination;
38     FieldIndex initialValue;
39 };
40 
41 class NodePositionChaser2D : public ChaserNode {
42 public:
43                     NodePositionChaser2D(Scene *scene, Proto *proto);
44 
copy()45     virtual Node   *copy() const { return new NodePositionChaser2D(*this); }
46 
47 
48     virtual void    sendChasedEvent(int eventIn, double timestamp,
49                                     FieldValue * value);
50 
51     fieldMacros(SFVec2f, initialDestination, ProtoPositionChaser2D);
52     fieldMacros(SFVec2f, initialValue,       ProtoPositionChaser2D);
53 
54 protected:
55     SFVec2f m_value;
56     Vec2f m_destination;
57     MyArray<Vec2f> m_destinations;
58     MyArray<double> m_event_times;
59     double m_lastTick;
60 
61     int m_initialDestination_Field;
62     int m_initialValue_Field;
63 };
64 
65