1 /*
2  * NodeSwitch.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 
29 class ProtoSwitch : public WonderlandExportProto {
30 public:
31                     ProtoSwitch(Scene *scene);
32     virtual Node   *create(Scene *scene);
33 
getType()34     virtual int     getType() const { return VRML_SWITCH; }
getNodeClass()35     virtual int     getNodeClass() const { return GROUPING_NODE |
36                                                   CHILD_NODE |
37                                                   BOUNDED_OBJECT_NODE; }
38 
isDeclaredInRwd_h()39     virtual bool    isDeclaredInRwd_h() { return true; }
40 
41     FieldIndex choice;
42     FieldIndex whichChoice;
43     FieldIndex bboxCenter;
44     FieldIndex bboxSize;
45     FieldIndex render;
46 };
47 
48 class NodeSwitch : public Node {
49 public:
50                     NodeSwitch(Scene *scene, Proto *proto);
51 
getProfile(void)52     virtual int     getProfile(void) const { return PROFILE_INTERACTIVE; }
getX3dVersion(void)53     virtual int     getX3dVersion(void) const { return 0; }
copy()54     virtual Node   *copy() const { return new NodeSwitch(*this); }
55 
countPolygons(void)56     virtual int     countPolygons(void)
57                        { return choice()->countPolygons(); }
countPrimitives(void)58     virtual int     countPrimitives(void)
59                        { return choice()->countPrimitives(); }
60 
countPolygons1Sided(void)61     virtual int     countPolygons1Sided(void)
62                        { return choice()->countPolygons1Sided(); }
countPolygons2Sided(void)63     virtual int     countPolygons2Sided(void)
64                        { return choice()->countPolygons2Sided(); }
65 
66     virtual void    flip(int index);
67     virtual void    swap(int fromTo);
68 
69     virtual void    preDraw();
70     virtual void    draw(int pass);
71 
72     virtual int     writeAc3d(int filedes, int indent);
73     virtual int     writeRib(int filedes, int indent);
74     virtual int     writeCattGeo(int filedes, int indent);
75 
76     int accountWhich();
77 
getChildrenField(void)78     virtual int     getChildrenField(void) const { return choice_Field(); }
79 
80     fieldMacros(MFNode,  choice,      ProtoSwitch)
81     fieldMacros(SFInt32, whichChoice, ProtoSwitch)
82     fieldMacros(SFVec3f, bboxCenter,  ProtoSwitch)
83     fieldMacros(SFVec3f, bboxSize,    ProtoSwitch)
84     fieldMacros(SFBool,  render,      ProtoSwitch)
85 };
86 
87