AWT Shape Extruder


AWT Shape Extruder
API Specification 3.0

AWT Shape Extruder converts a Java 2D™ Shape, called here AWT Shape, or a text string to a GeometryArray, a 3D geometry object for Java 3D™.

See:
          Description

Packages
com.interactivemesh.j3d.community.utils.geometry Geometry utilities.

 

AWT Shape Extruder converts a Java 2D™ Shape, called here AWT Shape, or a text string to a GeometryArray, a 3D geometry object for Java 3D™.

This API is a derived work of the Java 3D™ classes Font3D, FontExtrusion, and Text3D. The classes AWTShapeExtruder and AWTShapeExtrusion are generalized versions of javax.media.j3d.Font3D respectively of javax.media.j3d.FontExtrusion. The class String3D is a generalized version of javax.media.j3d.Text3D.

Currently targeted improvements:

Known issues:


Sample Code AWTShapeExtruder:

import java.awt.geom.Arc2D;
import javax.media.j3d.GeometryArray;
import com.interactivemesh.j3d.community.utils.geometry.AWTShapeExtruder;
import com.interactivemesh.j3d.community.utils.geometry.AWTShapeExtrusion;

AWTShapeExtrusion shapeExtrusion = new AWTShapeExtrusion(5);
AWTShapeExtruder  shapeExtruder  = new AWTShapeExtruder(shapeExtrusion);

Arc2D.Float arcPieYel = new Arc2D.Float(0, 0, 1, 1, 45, 270, Arc2D.PIE);
Arc2D.Float arcPieRed = new Arc2D.Float(0, 0, 1, 1, 315, 90, Arc2D.PIE);

GeometryArray geomArrayPieYel = shapeExtruder.getGeometry(arcPieYel, null);
GeometryArray geomArrayPieRed = shapeExtruder.getGeometry(arcPieRed, null);

Sample Code String3D:

import javax.media.j3d.GeometryArray;
import javax.media.j3d.Transform3D
import javax.vecmath.AxisAngle4d;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import com.interactivemesh.j3d.community.utils.geometry.AWTShapeExtruder;
import com.interactivemesh.j3d.community.utils.geometry.AWTShapeExtrusion;
import com.interactivemesh.j3d.community.utils.geometry.String3D;

String text = "Hello String 3D !";

AWTShapeExtrusion shapeExtrusion = new AWTShapeExtrusion(1); 
AWTShapeExtruder  shapeExtruder  = new AWTShapeExtruder(shapeExtrusion);

shapeExtruder.setCreaseAngle(Math.toRadians(15));
shapeExtruder.setTessellationTolerance(0.1);

String3D string3D = new String3D();

string3D.setFont(new Font("Serif", Font.PLAIN, 100));
string3D.setExtruder(shapeExtruder);
string3D.setCharacterSpacing(5f);
string3D.setAlignment(String3D.Alignment.CENTER);
string3D.setPath(String3D.Path.DOWN_LEFT);

BoundingBox bounds = new BoundingBox();

string3D.getGeometryBounds(text, bounds);

Point3d lower = new Point3d();
Point3d upper = new Point3d();
bounds.getLower(lower);
bounds.getUpper(upper);

double maxWidth = upper.x - lower.x;
double xyScale = 1.0/maxWidth;

Transform3D t3D = new Transform3D();
t3D.setScale(new Vector3d(xyScale, xyScale, 1.0));
t3D.setRotation(new AxisAngle4d(0, 0, 1, Math.toRadians(90)));
t3D.setTranslation(new Vector3d(0, 0.5, -0.5));

shapeExtruder.setGeometryTransform(t3D);

GeometryArray geom = string3D.getStringGeometry(text);

Image missing.

Version: 3.0
Date: 2008/12/19

Author:
August Lammersdorf, InteractiveMesh e.K.
Kolomanstrasse 2a, 85737 Ismaning
Germany / Munich Area
www.InteractiveMesh.com/org


License:

Redistribution and use are permitted according to the following license notice.

Font3D.java, FontExtrusion.java, Text3D.java

Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 only, as published by the Free Software Foundation. Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the LICENSE_GPL_CLASSPATH file that accompanied this code.

This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more details (a copy is included in the LICENSE_GPL_CLASSPATH file that accompanied this code).

You should have received a copy of the GNU General Public License version 2 along with this work; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, CA 95054 USA or visit www.sun.com if you need additional information or have any questions.

Revision: 1.6
Date: 2008/02/28 20:17:21
State: Exp


Trademarks:

Java, Java 2D, and Java 3D are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.



AWT Shape Extruder