1 /* 2 * NodeGeoElevationGrid.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 "GeoNode.h" 25 #include "ProtoMacros.h" 26 #include "Proto.h" 27 #include "NodeAppearance.h" 28 #include "NodeMaterial.h" 29 #include "NodeImageTexture.h" 30 #include "NodeTextureTransform.h" 31 #include "NodeGeoOrigin.h" 32 #include "GeometryNode.h" 33 #include "MeshBasedNode.h" 34 #include "SFMFTypes.h" 35 36 class ProtoGeoElevationGrid : public GeoProto { 37 public: 38 ProtoGeoElevationGrid(Scene *scene); 39 virtual Node *create(Scene *scene); 40 getType()41 virtual int getType() const { return VRML_GEO_ELEVATION_GRID; } getNodeClass()42 virtual int getNodeClass() const { return GEOMETRY_NODE; } 43 isMesh(void)44 virtual bool isMesh(void) { return true; } 45 46 FieldIndex color; 47 FieldIndex normal; 48 FieldIndex texCoord; 49 FieldIndex yScale; 50 FieldIndex yScaleX3D; 51 FieldIndex ccw; 52 FieldIndex colorPerVertex; 53 FieldIndex creaseAngle; 54 FieldIndex creaseAngleX3D; 55 FieldIndex geoGridOrigin; 56 FieldIndex geoGridOriginX3D; 57 FieldIndex height; 58 FieldIndex heightX3D; 59 FieldIndex normalPerVertex; 60 FieldIndex solid; 61 FieldIndex xDimension; 62 FieldIndex xSpacing; 63 FieldIndex xSpacingX3D; 64 FieldIndex zDimension; 65 FieldIndex zSpacing; 66 FieldIndex zSpacingX3D; 67 x3domGeometryCommonFieldIndex() 68 69 virtual int translateField(int field) const; 70 }; 71 72 class NodeGeoElevationGrid : public MeshBasedNode { 73 public: 74 NodeGeoElevationGrid(Scene *scene, Proto *proto); 75 getProfile(void)76 virtual int getProfile(void) const { return PROFILE_INTERCHANGE; } getX3dVersion(void)77 virtual int getX3dVersion(void) const { return 0; } getComponentName(void)78 virtual const char* getComponentName(void) const { return "Geospatial"; } getComponentLevel(void)79 virtual int getComponentLevel(void) const { return 1; } copy()80 virtual Node *copy() const { return new NodeGeoElevationGrid(*this); } 81 82 virtual void draw(); 83 hasTwoSides(void)84 virtual bool hasTwoSides(void) { return true; } isDoubleSided(void)85 virtual bool isDoubleSided(void) { return !solid()->getValue(); } toggleDoubleSided(void)86 virtual void toggleDoubleSided(void) 87 { solid(new SFBool(!solid()->getValue())); } getSolidField()88 virtual int getSolidField() { return solid_Field(); } flipSide(void)89 virtual void flipSide(void) { ccw(new SFBool(!ccw()->getValue())); } 90 91 virtual bool validHandle(int handle); 92 virtual bool checkHandle(int handle); 93 virtual int getMaxHandle(void); 94 getColorNode()95 virtual NodeColor *getColorNode() 96 { return (NodeColor *)color()->getValue(); } getColorRGBANode()97 virtual NodeColorRGBA *getColorRGBANode() 98 { return (NodeColorRGBA *)color()->getValue(); } 99 100 GeometryNodeDeclarationMacros() 101 102 void setField(int index, FieldValue *value, int cf = -1); 103 Node *convert2Vrml(void); 104 showFields()105 virtual bool showFields() { return true; } 106 107 fieldMacros(SFNode, color, ProtoGeoElevationGrid) 108 fieldMacros(SFNode, normal, ProtoGeoElevationGrid) 109 fieldMacros(SFNode, texCoord, ProtoGeoElevationGrid) 110 fieldMacros(SFFloat, yScale, ProtoGeoElevationGrid) 111 fieldMacros(SFFloat, yScaleX3D, ProtoGeoElevationGrid) 112 fieldMacros(MFFloat, height, ProtoGeoElevationGrid) 113 fieldMacros(MFDouble, heightX3D, ProtoGeoElevationGrid) 114 fieldMacros(SFBool, ccw, ProtoGeoElevationGrid) 115 fieldMacros(SFBool, colorPerVertex, ProtoGeoElevationGrid) 116 fieldMacros(SFDouble, creaseAngle, ProtoGeoElevationGrid) 117 fieldMacros(SFDouble, creaseAngleX3D, ProtoGeoElevationGrid) 118 fieldMacros(SFString, geoGridOrigin, ProtoGeoElevationGrid) 119 fieldMacros(SFVec3d, geoGridOriginX3D, ProtoGeoElevationGrid) 120 fieldMacros(SFBool, normalPerVertex, ProtoGeoElevationGrid) 121 fieldMacros(SFBool, solid, ProtoGeoElevationGrid) 122 fieldMacros(SFInt32, xDimension, ProtoGeoElevationGrid) 123 fieldMacros(SFString, xSpacing, ProtoGeoElevationGrid) 124 fieldMacros(SFDouble, xSpacingX3D, ProtoGeoElevationGrid) 125 fieldMacros(SFInt32, zDimension, ProtoGeoElevationGrid) 126 fieldMacros(SFString, zSpacing, ProtoGeoElevationGrid) 127 fieldMacros(SFDouble, zSpacingX3D, ProtoGeoElevationGrid) 128 129 fieldMacros(SFNode, geoOrigin, GeoProto) 130 fieldMacros(MFString, geoSystem, GeoProto) 131 132 133 x3domGeometryCommonFieldMacros(ProtoGeoElevationGrid) 134 135 protected: 136 void createMesh(bool cleanDoubleVertices = true, 137 bool triangulate = true); 138 }; 139 140 141