| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | * Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 | * |
| 40 | _______________________________________________________________________ |
| 41 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 | | |
| 43 | | $Revision: 1.1.1.1 $ |
| 44 | | |
| 45 | | Classes: |
| 46 | | SoTextureCoordinate2 |
| 47 | | |
| 48 | | Author(s) : John Rohlf, Thad Beier |
| 49 | | |
| 50 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 51 | _______________________________________________________________________ |
| 52 | */ |
| 53 | |
| 54 | #include <Inventor/actions/SoCallbackAction.h> |
| 55 | #include <Inventor/actions/SoGLRenderAction.h> |
| 56 | #include <Inventor/actions/SoPickAction.h> |
| 57 | #include <Inventor/elements/SoGLTextureCoordinateElement.h> |
| 58 | #include <Inventor/nodes/SoTextureCoordinate2.h> |
| 59 | |
| 60 | SO_NODE_SOURCE(SoTextureCoordinate2); |
| 61 | |
| 62 | //////////////////////////////////////////////////////////////////////// |
| 63 | // |
| 64 | // Description: |
| 65 | // Constructor |
| 66 | // |
| 67 | // Use: public |
| 68 | |
| 69 | SoTextureCoordinate2::SoTextureCoordinate2() |
| 70 | // |
| 71 | //////////////////////////////////////////////////////////////////////// |
| 72 | { |
| 73 | SO_NODE_CONSTRUCTOR(SoTextureCoordinate2); |
| 74 | SO_NODE_ADD_FIELD(point, (SbVec2f(0,0))); |
| 75 | point.deleteValues(0); |
| 76 | isBuiltIn = TRUE; |
| 77 | } |
| 78 | |
| 79 | //////////////////////////////////////////////////////////////////////// |
| 80 | // |
| 81 | // Description: |
| 82 | // This initializes the SoTextureCoordinate2 class. |
| 83 | // |
| 84 | // Use: internal |
| 85 | |
| 86 | void |
| 87 | SoTextureCoordinate2::initClass() |
| 88 | // |
| 89 | //////////////////////////////////////////////////////////////////////// |
| 90 | { |
| 91 | SO__NODE_INIT_CLASS(SoTextureCoordinate2, "TextureCoordinate2", SoNode); |
| 92 | |
| 93 | SO_ENABLE(SoCallbackAction, SoTextureCoordinateElement); |
| 94 | SO_ENABLE(SoGLRenderAction, SoGLTextureCoordinateElement); |
| 95 | SO_ENABLE(SoPickAction, SoTextureCoordinateElement); |
| 96 | } |
| 97 | |
| 98 | //////////////////////////////////////////////////////////////////////// |
| 99 | // |
| 100 | // Description: |
| 101 | // Destructor |
| 102 | // |
| 103 | // Use: private |
| 104 | |
| 105 | SoTextureCoordinate2::~SoTextureCoordinate2() |
| 106 | // |
| 107 | //////////////////////////////////////////////////////////////////////// |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | //////////////////////////////////////////////////////////////////////// |
| 112 | // |
| 113 | // Description: |
| 114 | // Handles actions. |
| 115 | // |
| 116 | // Use: extender |
| 117 | |
| 118 | void |
| 119 | SoTextureCoordinate2::doAction(SoAction *action) |
| 120 | // |
| 121 | //////////////////////////////////////////////////////////////////////// |
| 122 | { |
| 123 | SoState *state = action->getState(); |
| 124 | |
| 125 | if (! point.isIgnored() && point.getNum() > 0) |
| 126 | SoTextureCoordinateElement::set2(state, this, |
| 127 | point.getNum(), point.getValues(0)); |
| 128 | } |
| 129 | |
| 130 | //////////////////////////////////////////////////////////////////////// |
| 131 | // |
| 132 | // Description: |
| 133 | // Does callback action thing. |
| 134 | // |
| 135 | // Use: extender |
| 136 | |
| 137 | void |
| 138 | SoTextureCoordinate2::callback(SoCallbackAction *action) |
| 139 | // |
| 140 | //////////////////////////////////////////////////////////////////////// |
| 141 | { |
| 142 | SoTextureCoordinate2::doAction(action); |
| 143 | } |
| 144 | |
| 145 | //////////////////////////////////////////////////////////////////////// |
| 146 | // |
| 147 | // Description: |
| 148 | // Does GL render action. |
| 149 | // |
| 150 | // Use: extender |
| 151 | |
| 152 | void |
| 153 | SoTextureCoordinate2::GLRender(SoGLRenderAction *action) |
| 154 | // |
| 155 | //////////////////////////////////////////////////////////////////////// |
| 156 | { |
| 157 | SoState *state = action->getState(); |
| 158 | |
| 159 | if (! point.isIgnored() && point.getNum() > 0){ |
| 160 | SoGLTextureCoordinateElement::setTexGen(state, this, NULL); |
| 161 | SoTextureCoordinateElement::set2(state, this, |
| 162 | point.getNum(), point.getValues(0)); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | //////////////////////////////////////////////////////////////////////// |
| 167 | // |
| 168 | // Description: |
| 169 | // Does pick action... |
| 170 | // |
| 171 | // Use: protected |
| 172 | |
| 173 | void |
| 174 | SoTextureCoordinate2::pick(SoPickAction *action) |
| 175 | // |
| 176 | //////////////////////////////////////////////////////////////////////// |
| 177 | { |
| 178 | SoTextureCoordinate2::doAction(action); |
| 179 | } |
| 180 |