Open Inventor Reference
SoText3.h
Go to the documentation of this file.
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 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | This file defines the SoText3 node class.
48  |
49  | Author(s) : Gavin Bell
50  |
51  ______________ S I L I C O N G R A P H I C S I N C . ____________
52  _______________________________________________________________________
53  */
54 
55 #ifndef _SO_TEXT_3_
56 #define _SO_TEXT_3_
57 
58 #include <Inventor/SbBox.h>
63 #include <Inventor/nodes/SoShape.h>
64 
65 #include <Inventor/system/SbOpenGL.h> // For GLenum declaration
66 
67 
69 #ifndef gluTESSELATOR
70 #define gluTESSELATOR GLUtriangulatorObj
71 #if defined(__glu_h__) && defined(GLU_VERSION_1_2)
72 #define gluTESSELATOR GLUtesselator
73 #else
74 extern "C" struct GLUtriangulatorObj;
75 #endif
76 #endif
77 
78 
79 
80 class SoOutlineFontCache;
81 class SoPrimitiveVertex;
83 
86 
152 
153 class INVENTOR_API SoText3 : public SoShape {
154 
156 
157  public:
160  LEFT = 0x01,
161  RIGHT = 0x02,
162  CENTER = 0x03
163  };
164 
166  enum Part {
167  FRONT = 0x01,
168  SIDES = 0x02,
169  BACK = 0x04,
170  ALL = 0x07
171  };
172 
174 
175 
179 
185 
189 
197 
199 
202 
203  SoEXTENDER public:
204 
216  int stringIndex, int charIndex);
217 
218  virtual void GLRender(SoGLRenderAction *action);
219  virtual void rayPick(SoRayPickAction *action);
220 
221  SoINTERNAL public:
222  static void initClass();
223 
224  protected:
226  virtual void computeBBox(SoAction *action, SbBox3f &box,
227  SbVec3f &center);
228 
230  virtual void generatePrimitives(SoAction *);
231 
232  virtual ~SoText3();
233 
234  private:
236  bool setupFontCache(SoState *state, bool forRender = FALSE);
237 
239  void getFrontBBox(SbBox2f &result);
240 
243  SbVec2f getStringOffset(int line);
244 
247  SbVec2f getCharacterOffset(int line, int whichChar);
248 
250  void renderFront(SoGLRenderAction *action, int line,
251  GLUtriangulatorObj *tobj);
252 
254  void renderSide(SoGLRenderAction *action, int line);
255 
258  const SoPrimitiveVertex *,
259  const SoPrimitiveVertex *,
260  const SoPrimitiveVertex *,
261  SoPickedPoint *);
262 
265  void generateFront(int line);
266 
268  void generateSide(int line);
269 
273  static void generateSideTris(int nPoints, const SbVec3f *p1,
274  const SbVec3f *n1, const SbVec3f *p2,
275  const SbVec3f *n2, const float *sTexCoords,
276  const float *tTexCoords);
277  static void renderSideTris(int nPoints, const SbVec3f *p1,
278  const SbVec3f *n1, const SbVec3f *p2,
279  const SbVec3f *n2, const float *sTexCoords,
280  const float *tTexCoords);
281 
283  static void CALLBACK beginCB(GLenum primType);
284  static void CALLBACK endCB();
285  static void CALLBACK vtxCB(void *vertex);
286 
291  SoOutlineFontCache *myFont;
292 
294  static SoText3 *currentGeneratingNode;
295  static SoPrimitiveVertex *genPrimVerts[3];
296  static SbVec3f genTranslate;
297  static int genWhichVertex;
298  static uint32_t genPrimType;
299  static SoAction *genAction;
300  static bool genBack;
301  static bool genTexCoord;
302  static const SoTextureCoordinateElement *tce;
303 };
304 
305 #endif /* _SO_TEXT_3_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
unsigned int uint32_t
Definition: SbTypeDefs.h:44
#define SO_NODE_HEADER(className)
Non-abstract classes have everything abstract classes have, plus a way to create an instance.
Definition: SoSubNode.h:170
2D box class.
Definition: SbBox.h:372
3D box class.
Definition: SbBox.h:81
2D vector class.
Definition: SbLinear.h:246
3D vector class.
Definition: SbLinear.h:120
Abstract base class for all actions.
Definition: SoAction.h:179
Base class for describing detail information about a shape node.
Definition: SoDetail.h:78
Renders a scene graph using OpenGL.
Multiple-value field containing any number of strings.
Definition: SoMFString.h:80
Represents point on surface of picked object.
Definition: SoPickedPoint.h:89
Represents a vertex of a generated primitive.
Intersects objects with a ray cast into scene.
Single-value field containing a set of bit flags.
Definition: SoSFBitMask.h:99
Field containing an enumerated value.
Definition: SoSFEnum.h:93
Field containing a floating-point value.
Definition: SoSFFloat.h:77
Abstract base class for all shape nodes.
Definition: SoShape.h:101
virtual SoDetail * createTriangleDetail(SoRayPickAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3, SoPickedPoint *pp)
These methods are called during picking to create details representing extra info about a pick inters...
An SoState collects and holds state while traversing a scene graph.
Definition: SoState.h:82
3D text shape node.
Definition: SoText3.h:153
SoSFFloat spacing
Defines the distance (in the negative y direction) between the base points of successive strings,...
Definition: SoText3.h:184
SoText3()
Creates a 3D text node with default settings.
virtual void generatePrimitives(SoAction *)
Generates primitives.
SoSFEnum justification
Indicates placement and alignment of strings.
Definition: SoText3.h:196
Justification
Justification types.
Definition: SoText3.h:159
virtual void rayPick(SoRayPickAction *action)
Implements picking along a ray by intersecting the ray with each primitive generated by subclass.
Part
Justification types.
Definition: SoText3.h:166
static void initClass()
virtual ~SoText3()
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
Computes bounding box of text.
SbBox3f getCharacterBounds(SoState *state, int stringIndex, int charIndex)
Method to get the bounds of the given character in the given string.
SoSFBitMask parts
Which parts of text are visible.
Definition: SoText3.h:188
SoMFString string
The text string(s) to display.
Definition: SoText3.h:178
virtual void GLRender(SoGLRenderAction *action)
Implements rendering by rendering each primitive generated by subclass.
Element storing the current texture coordinates.