1 /*
2  * NodeVrmlCut.h
3  *
4  * Copyright (C) 1999 Stephen F. White
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 "CommandList.h"
29 #include "DynamicFieldsNode.h"
30 
31 #define BEGIN_VRML_CUT_SCRIPT "BEGIN VrmlCut Script"
32 #define END_VRML_CUT_SCRIPT   "END VrmlCut Script"
33 
34 class ProtoVrmlCut : public DynamicFieldsProto {
35 public:
36                     ProtoVrmlCut(Scene *scene);
37     virtual Node   *create(Scene *scene);
38 
getType()39     virtual int     getType() const { return DUNE_VRML_CUT; }
40 
41     FieldIndex sceneLengths;
42     FieldIndex sceneDelays;
43     FieldIndex sceneNumber;
44     FieldIndex scenes;
45     FieldIndex numberPreviousScenes;
46     FieldIndex numberNextScenes;
47 
isScriptedProto(void)48     virtual bool    isScriptedProto(void) { return true; }
49 
getFirstDynamicEventOut()50     int getFirstDynamicEventOut() { return m_firstDynamicEventOut; }
51 protected:
52     int m_firstDynamicEventOut;
53 };
54 
55 class NodeVrmlCut : public DynamicFieldsNode {
56 public:
57                     NodeVrmlCut(Scene *scene, Proto* proto);
NodeVrmlCut(Node * node,Proto * proto)58                     NodeVrmlCut(Node *node, Proto* proto) :
59                                DynamicFieldsNode(node, proto)
60                        { initialize(); }
61 
62     void            initialize(void);
63 
getProfile(void)64     virtual int     getProfile(void) const { return PROFILE_IMMERSIVE; }
getX3dVersion(void)65     virtual int     getX3dVersion(void) const { return -1; }
copy()66     virtual Node   *copy() const { return new NodeVrmlCut(*this); }
67 
hasNumbers4kids(void)68     virtual bool    hasNumbers4kids(void) { return true; }
69 
70     virtual int     write(int filedes, int indent, bool avoidUse = false)
71                        {
72                        writeProto(filedes);
73                        return DynamicFieldsNode::write(filedes, indent,
74                                                        avoidUse);
75                        }
76 
77     virtual int     writeXml(int filedes, int indent,
78                              int containerField = -1, bool avoidUse = false);
79 
80     int             writeX3domScript(int filedes, int indent);
81 
82     virtual int     writeRib(int filedes, int indent);
83     virtual int     writeProto(int filedes);
84     virtual int     writeXmlProto(int filedes);
85     virtual int     writeJavaScript(int filedes);
86 
87     virtual void    updateTime(void);
88 
89     virtual void    preDraw();
90     virtual void    draw(int pass);
91 
flip(int index)92     virtual void    flip(int index) { scenes()->flip(index); }
swap(int fromTo)93     virtual void    swap(int fromTo) { scenes()->swap(fromTo); }
94 
countPolygons(void)95     virtual int     countPolygons(void)
96                        { return scenes()->countPolygons(); }
countPrimitives(void)97     virtual int     countPrimitives(void)
98                        { return scenes()->countPrimitives(); }
99 
countPolygons1Sided(void)100     virtual int     countPolygons1Sided(void)
101                        { return scenes()->countPolygons1Sided(); }
countPolygons2Sided(void)102     virtual int     countPolygons2Sided(void)
103                        { return scenes()->countPolygons2Sided(); }
104 
showFields()105     virtual bool    showFields() { return true; }
106 
107     virtual void    setField(int index, FieldValue *value, int cf = -1);
108 
109     virtual void    update();
110     void            updateCycleInterval(Node *vrmlScene, SFTime *interval);
111     void            updateSelection(void);
112 
getEventOutsInitialised(void)113     bool            getEventOutsInitialised(void)
114                         { return m_eventOutsInitialised; }
setEventOutsInitialised(void)115     void            setEventOutsInitialised(void)
116                         { m_eventOutsInitialised = true; }
117 
118     fieldMacros(MFTime,  sceneLengths,         ProtoVrmlCut)
119     fieldMacros(MFTime,  sceneDelays,          ProtoVrmlCut)
120     fieldMacros(SFInt32, sceneNumber,          ProtoVrmlCut)
121     fieldMacros(MFNode,  scenes,               ProtoVrmlCut)
122     fieldMacros(SFInt32, numberPreviousScenes, ProtoVrmlCut)
123     fieldMacros(SFInt32, numberNextScenes,     ProtoVrmlCut)
124 
125 protected:
126     virtual        ~NodeVrmlCut();
127 
128     char           *newStartTimeName(void);
129     void            startNextScene(int currentScene, double time);
130     int             accountWhich(void);
131     int             getVrmlSceneWhich(void);
132 
133     void            accountAllSceneLengths();
134 
135 protected:
136     int            m_firstScene;
137     int            m_lastScene;
138     int            m_currentScene;
139     int            m_selectionWhich;
140     double         m_allSceneLengths;
141     bool           m_eventOutsInitialised;
142 };
143 
144