Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | This file defines the SoTextureCoordinateElement class. 00048 | TextureCoordinates can be specified in several different ways, 00049 | from several different nodes: they can be explicitly given by 00050 | TextureCoordinate2/4 nodes, they can be automatically generated 00051 | (the TextureCoordinateFunction nodes), or they can be DEFAULT, 00052 | meaning that each shape must generate its own texture 00053 | coordinates (can be set by TextureCoordinateFunctionDefault 00054 | node). 00055 | 00056 | Shapes will have to call TextureCoordinateElement::getType() and 00057 | then call either generate default texture coordinates if it 00058 | returns DEFAULT, call get2/get4 if it returns EXPLICIT, or call 00059 | get(point, normal) if it returns FUNCTION. 00060 | 00061 | Author(s) : Gavin Bell 00062 | 00063 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00064 _______________________________________________________________________ 00065 */ 00066 00067 #ifndef _SO_TEXTURE_COORDINATE_ELEMENT 00068 #define _SO_TEXTURE_COORDINATE_ELEMENT 00069 00070 #include <Inventor/SbLinear.h> 00071 #include <Inventor/elements/SoReplacedElement.h> 00072 00081 00085 typedef const SbVec4f & 00086 SoTextureCoordinateFunctionCB(void *userdata, const SbVec3f &point, 00087 const SbVec3f &normal); 00088 00089 SoEXTENDER class INVENTOR_API SoTextureCoordinateElement : public SoReplacedElement { 00090 00091 SO_ELEMENT_HEADER(SoTextureCoordinateElement); 00092 00093 public: 00096 enum CoordType { 00097 EXPLICIT = 1, 00098 FUNCTION = 2 00099 }; 00100 00102 virtual void init(SoState *state); 00103 00106 static void setDefault(SoState *state, SoNode *node); 00107 00109 static void setFunction(SoState *state, SoNode *node, 00110 SoTextureCoordinateFunctionCB *func, 00111 void *userData); 00113 static void set2(SoState *state, SoNode *node, 00114 int32_t numCoords, const SbVec2f *coords); 00115 static void set4(SoState *state, SoNode *node, 00116 int32_t numCoords, const SbVec4f *coords); 00117 00119 static CoordType getType(SoState *state); 00120 virtual CoordType getType() const; 00121 00126 static const SoTextureCoordinateElement * getInstance(SoState *state); 00127 00129 00133 const SbVec4f & get(const SbVec3f &point, const SbVec3f &normal) const; 00134 00136 00138 int32_t getNum() const { return numCoords; } 00139 00140 SbBool is2D() const { return coordsAre2D; } 00141 00144 const SbVec2f & get2(int index) const; 00145 const SbVec4f & get4(int index) const; 00146 00147 virtual void print(FILE *fp) const; 00148 00149 SoINTERNAL public: 00151 static void initClass(); 00152 00153 protected: 00155 CoordType whatKind; 00156 00158 SoTextureCoordinateFunctionCB *funcCB; 00159 void *funcCBData; 00160 00162 int32_t numCoords; 00163 const SbVec2f *coords2; 00164 const SbVec4f *coords4; 00165 SbBool coordsAre2D; 00166 00167 virtual ~SoTextureCoordinateElement(); 00168 00169 private: 00170 SbVec2f convert2; 00171 SbVec4f convert4; 00172 }; 00173 00174 #endif /* _SO_TEXTURE_COORDINATE_ELEMENT */