< Zurück | Inhalt | Weiter >

From Text3DTest.java

//describe the FontExtrusion contour using X,Y coordinates

//that in mathematical parlance are “monotonic in X” double X1 = 0;

double Y1 = 0; double X2 = 3; double Y2 = 0;

Shape extrusionShape = new java.awt.geom.Line2D.Double(X1, Y1, X2, Y2); FontExtrusion fontEx = new FontExtrusion( extrusionShape) ;

Font3D f3d = new Font3D( new Font( "TimesRoman",

Font.PLAIN, nSize),

fontEx);


image


This example will create a Text3D object that is 3 units deep instead of the default 0.2 units.

Unfortunately, there are serious usability issues that may influence your decision to use a Text3D object. These are described in the following subsections.


8.6.1 Complex geometry

Text3D objects can contain many hundreds of vertices. Creating lots of Text3D objects may quickly consume memory and impact performance. The number of vertices created is proportional to the pitch of the font used, as well to the font itself. Using small sans serif fonts will generate fewer vertices than large serif fonts. This is particularly relevant if your application uses the Java 3D collision detection methods; internally Text3D creates a GeometryArray object for each letter. If you create many Text3D objects with many letters, each containing many vertices, collision detection will quickly consume all available processor time.


Text3D objects generate vertex coordinates and Normal vectors for their geometry. This implies that they can be displayed and lighted, but cannot have a texture image applied to them.