1 /*
2  * IndexedTriangleSetNode.h
3  *
4  * Copyright (C) 1999 Stephen F. White, 2008 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 "MeshBasedNode.h"
25 #include "ProtoMacros.h"
26 #include "Proto.h"
27 #include "DuneApp.h"
28 #include "MyMesh.h"
29 #include "Vec3f.h"
30 #include "NodeCoordinate.h"
31 #include "SFMFTypes.h"
32 #include "ComposedGeometryMacros.h"
33 
34 class IndexedTriangleSetProto : public GeometryProto {
35 public:
36                     IndexedTriangleSetProto(Scene *scene);
37                     IndexedTriangleSetProto(Scene *scene, const char *name);
38 
39     FieldIndex color;
40     FieldIndex coord;
41     FieldIndex normal;
42     FieldIndex texCoord;
43     FieldIndex ccw;
44     FieldIndex colorPerVertex;
45     FieldIndex normalPerVertex;
46     FieldIndex solid;
47     FieldIndex index;
48     ComposedGeometryProtoMacro()
49 };
50 
51 class IndexedTriangleSetNode : public MeshBasedNode {
52 public:
53                     IndexedTriangleSetNode(Scene *scene, Proto *proto);
54 
55 protected:
56     virtual        ~IndexedTriangleSetNode();
57 
58 public:
getComponentName(void)59     virtual const char* getComponentName(void) const
60                            { return "Rendering"; }
getComponentLevel(void)61     virtual int         getComponentLevel(void) const { return 3; }
62 
63     virtual void    setField(int index, FieldValue *value, int cf = -1);
64 
65     virtual void    draw();
66 
67     virtual void    flip(int index);
68     virtual void    swap(int fromTo);
69 
hasTwoSides(void)70     virtual bool    hasTwoSides(void) { return true; }
isDoubleSided(void)71     virtual bool    isDoubleSided(void) { return !solid()->getValue(); }
toggleDoubleSided(void)72     virtual void    toggleDoubleSided(void)
73                        { solid(new SFBool(!solid()->getValue())); }
getSolidField()74     virtual int     getSolidField() { return solid_Field(); }
flipSide(void)75     virtual void    flipSide(void) { ccw(new SFBool(!ccw()->getValue())); }
76 
maySetDefault(void)77     virtual bool    maySetDefault(void) { return false; }
78 
getColorNode()79     virtual NodeColor *getColorNode()
80                        { return (NodeColor *)color()->getValue(); }
getColorRGBANode()81     virtual NodeColorRGBA *getColorRGBANode()
82                        { return (NodeColorRGBA *)color()->getValue(); }
83 
84     fieldMacros(SFNode,  color,           IndexedTriangleSetProto)
85     fieldMacros(SFNode,  coord,           IndexedTriangleSetProto)
86     fieldMacros(SFNode,  normal,          IndexedTriangleSetProto)
87     fieldMacros(SFNode,  texCoord,        IndexedTriangleSetProto)
88     fieldMacros(SFBool,  ccw,             IndexedTriangleSetProto)
89     fieldMacros(SFBool,  normalPerVertex, IndexedTriangleSetProto)
90     fieldMacros(SFBool,  colorPerVertex,  IndexedTriangleSetProto)
91     fieldMacros(SFBool,  solid,           IndexedTriangleSetProto)
92     fieldMacros(MFInt32, index,           IndexedTriangleSetProto)
93     ComposedGeometryFieldMacros(IndexedTriangleSetProto)
94 
95 protected:
96     MFInt32        *m_coordIndex;
97 };
98 
99