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 SoText3 node class. 00048 | 00049 | Author(s) : Gavin Bell 00050 | 00051 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00052 _______________________________________________________________________ 00053 */ 00054 00055 #ifndef _SO_TEXT_3_ 00056 #define _SO_TEXT_3_ 00057 00058 #include <Inventor/SbBox.h> 00059 #include <Inventor/fields/SoMFString.h> 00060 #include <Inventor/fields/SoSFEnum.h> 00061 #include <Inventor/fields/SoSFBitMask.h> 00062 #include <Inventor/fields/SoSFFloat.h> 00063 #include <Inventor/nodes/SoShape.h> 00064 00065 #include <Inventor/system/SbOpenGL.h> // For GLenum declaration 00066 00067 00069 #ifndef gluTESSELATOR 00070 #define gluTESSELATOR GLUtriangulatorObj 00071 #if defined(__glu_h__) && defined(GLU_VERSION_1_2) 00072 #define gluTESSELATOR GLUtesselator 00073 #else 00074 extern "C" struct GLUtriangulatorObj; 00075 #endif 00076 #endif 00077 00078 00079 00080 class SoOutlineFontCache; 00081 class SoPrimitiveVertex; 00082 class SoTextureCoordinateElement; 00083 00086 00151 00152 00153 class INVENTOR_API SoText3 : public SoShape { 00154 00155 SO_NODE_HEADER(SoText3); 00156 00157 public: 00159 enum Justification { 00160 LEFT = 0x01, 00161 RIGHT = 0x02, 00162 CENTER = 0x03 00163 }; 00164 00166 enum Part { 00167 FRONT = 0x01, 00168 SIDES = 0x02, 00169 BACK = 0x04, 00170 ALL = 0x07 00171 }; 00172 00174 00175 00178 SoMFString string; 00179 00184 SoSFFloat spacing; 00185 00188 SoSFBitMask parts; 00189 00196 SoSFEnum justification; 00197 00199 00201 SoText3(); 00202 00203 SoEXTENDER public: 00204 00215 SbBox3f getCharacterBounds(SoState *state, 00216 int stringIndex, int charIndex); 00217 00218 virtual void GLRender(SoGLRenderAction *action); 00219 virtual void rayPick(SoRayPickAction *action); 00220 00221 SoINTERNAL public: 00222 static void initClass(); 00223 00224 protected: 00226 virtual void computeBBox(SoAction *action, SbBox3f &box, 00227 SbVec3f ¢er); 00228 00230 virtual void generatePrimitives(SoAction *); 00231 00232 virtual ~SoText3(); 00233 00234 private: 00236 SbBool setupFontCache(SoState *state, SbBool forRender = FALSE); 00237 00239 void getFrontBBox(SbBox2f &result); 00240 00243 SbVec2f getStringOffset(int line); 00244 00247 SbVec2f getCharacterOffset(int line, int whichChar); 00248 00250 void renderFront(SoGLRenderAction *action, int line, 00251 GLUtriangulatorObj *tobj); 00252 00254 void renderSide(SoGLRenderAction *action, int line); 00255 00257 SoDetail * createTriangleDetail(SoRayPickAction *, 00258 const SoPrimitiveVertex *, 00259 const SoPrimitiveVertex *, 00260 const SoPrimitiveVertex *, 00261 SoPickedPoint *); 00262 00265 void generateFront(int line); 00266 00268 void generateSide(int line); 00269 00273 static void generateSideTris(int nPoints, const SbVec3f *p1, 00274 const SbVec3f *n1, const SbVec3f *p2, 00275 const SbVec3f *n2, const float *sTexCoords, 00276 const float *tTexCoords); 00277 static void renderSideTris(int nPoints, const SbVec3f *p1, 00278 const SbVec3f *n1, const SbVec3f *p2, 00279 const SbVec3f *n2, const float *sTexCoords, 00280 const float *tTexCoords); 00281 00283 static void CALLBACK beginCB(GLenum primType); 00284 static void CALLBACK endCB(); 00285 static void CALLBACK vtxCB(void *vertex); 00286 00291 SoOutlineFontCache *myFont; 00292 00294 static SoText3 *currentGeneratingNode; 00295 static SoPrimitiveVertex *genPrimVerts[3]; 00296 static SbVec3f genTranslate; 00297 static int genWhichVertex; 00298 static uint32_t genPrimType; 00299 static SoAction *genAction; 00300 static SbBool genBack; 00301 static SbBool genTexCoord; 00302 static const SoTextureCoordinateElement *tce; 00303 }; 00304 00305 #endif /* _SO_TEXT_3_ */