| 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 |
| SoNormal |
| 47 |
| |
| 48 |
| Author(s) : Paul S. Strauss |
| 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/SoGLNormalElement.h> |
| 58 |
#include <Inventor/nodes/SoNormal.h> |
| 59 |
|
| 60 |
SO_NODE_SOURCE(SoNormal); |
| 61 |
|
| 62 |
//////////////////////////////////////////////////////////////////////// |
| 63 |
// |
| 64 |
// Description: |
| 65 |
// Constructor |
| 66 |
// |
| 67 |
// Use: public |
| 68 |
|
| 69 |
SoNormal::SoNormal() |
| 70 |
// |
| 71 |
//////////////////////////////////////////////////////////////////////// |
| 72 |
{ |
| 73 |
SO_NODE_CONSTRUCTOR(SoNormal); |
| 74 |
SO_NODE_ADD_FIELD(vector, (SbVec3f(0,0,0))); |
| 75 |
vector.deleteValues(0); // Nuke bogus normal |
| 76 |
isBuiltIn = TRUE; |
| 77 |
} |
| 78 |
|
| 79 |
//////////////////////////////////////////////////////////////////////// |
| 80 |
// |
| 81 |
// Description: |
| 82 |
// This initializes the SoNormal class. |
| 83 |
// |
| 84 |
// Use: internal |
| 85 |
|
| 86 |
void |
| 87 |
SoNormal::initClass() |
| 88 |
// |
| 89 |
//////////////////////////////////////////////////////////////////////// |
| 90 |
{ |
| 91 |
SO__NODE_INIT_CLASS(SoNormal, "Normal", SoNode); |
| 92 |
|
| 93 |
// Enable elements for appropriate actions: |
| 94 |
SO_ENABLE(SoGLRenderAction, SoGLNormalElement); |
| 95 |
SO_ENABLE(SoCallbackAction, SoNormalElement); |
| 96 |
SO_ENABLE(SoPickAction, SoNormalElement); |
| 97 |
} |
| 98 |
|
| 99 |
//////////////////////////////////////////////////////////////////////// |
| 100 |
// |
| 101 |
// Description: |
| 102 |
// Destructor |
| 103 |
// |
| 104 |
// Use: private |
| 105 |
|
| 106 |
SoNormal::~SoNormal() |
| 107 |
// |
| 108 |
//////////////////////////////////////////////////////////////////////// |
| 109 |
{ |
| 110 |
} |
| 111 |
|
| 112 |
//////////////////////////////////////////////////////////////////////// |
| 113 |
// |
| 114 |
// Description: |
| 115 |
// Handles most actions, |
| 116 |
// |
| 117 |
// Use: extender |
| 118 |
|
| 119 |
void |
| 120 |
SoNormal::doAction(SoAction *action) |
| 121 |
// |
| 122 |
//////////////////////////////////////////////////////////////////////// |
| 123 |
{ |
| 124 |
if (! vector.isIgnored()) |
| 125 |
SoNormalElement::set(action->getState(), this, |
| 126 |
vector.getNum(), vector.getValues(0)); |
| 127 |
} |
| 128 |
|
| 129 |
//////////////////////////////////////////////////////////////////////// |
| 130 |
// |
| 131 |
// Description: |
| 132 |
// Does callback action thing. |
| 133 |
// |
| 134 |
// Use: extender |
| 135 |
|
| 136 |
void |
| 137 |
SoNormal::callback(SoCallbackAction *action) |
| 138 |
// |
| 139 |
//////////////////////////////////////////////////////////////////////// |
| 140 |
{ |
| 141 |
SoNormal::doAction(action); |
| 142 |
} |
| 143 |
|
| 144 |
//////////////////////////////////////////////////////////////////////// |
| 145 |
// |
| 146 |
// Description: |
| 147 |
// Does GL render action. |
| 148 |
// |
| 149 |
// Use: extender |
| 150 |
|
| 151 |
void |
| 152 |
SoNormal::GLRender(SoGLRenderAction *action) |
| 153 |
// |
| 154 |
//////////////////////////////////////////////////////////////////////// |
| 155 |
{ |
| 156 |
SoNormal::doAction(action); |
| 157 |
} |
| 158 |
|
| 159 |
//////////////////////////////////////////////////////////////////////// |
| 160 |
// |
| 161 |
// Description: |
| 162 |
// Does pick action... |
| 163 |
// |
| 164 |
// Use: extender |
| 165 |
|
| 166 |
void |
| 167 |
SoNormal::pick(SoPickAction *action) |
| 168 |
// |
| 169 |
//////////////////////////////////////////////////////////////////////// |
| 170 |
{ |
| 171 |
SoNormal::doAction(action); |
| 172 |
} |