本文整理汇总了Java中javax.media.j3d.Text3D类的典型用法代码示例。如果您正苦于以下问题:Java Text3D类的具体用法?Java Text3D怎么用?Java Text3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Text3D类属于javax.media.j3d包,在下文中一共展示了Text3D类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addScaleBarToSceneGraph
import javax.media.j3d.Text3D; //导入依赖的package包/类
/**
* add a 100 µm scale bar to the BranchGroup
*
* @param scene
* the BranchGroup
*/
public static void addScaleBarToSceneGraph(TransformGroup scene, Point3f scaleBarPos, float scale) {
if (scaleBarPos == null) {
scaleBarPos = new Point3f();
}
float barPos = -150.0f * scale;
float hight = 100.0f * scale;
//logger.info("scaleBarPos: " + scaleBarPos.toString());
LineArray la = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
//la.setCoordinate(0, new Point3f(scaleBarPos.x + 0.7f, scaleBarPos.y + 0.0f, scaleBarPos.z + 0.9f));
//la.setCoordinate(1, new Point3f(scaleBarPos.x + 0.7f, scaleBarPos.y + 0.0f, scaleBarPos.z + 1.0f));
la.setCoordinate(0, new Point3f(barPos, scaleBarPos.y, scaleBarPos.z));
la.setCoordinate(1, new Point3f(barPos, scaleBarPos.y, scaleBarPos.z + hight));
for (int i = 0; i < 2; ++i) {
la.setColor(i, grey);
}
scene.addChild(new Shape3D(la));
Text3D text3d = new Text3D(new Font3D(new Font("plain", java.awt.Font.PLAIN, 1), new FontExtrusion()), "100 µm");
text3d.setAlignment(Text3D.ALIGN_LAST);
Shape3D text3dShape3d = new Shape3D(text3d);
Appearance appearance = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(grey);
appearance.setColoringAttributes(ca);
text3dShape3d.setAppearance(appearance);
TransformGroup tg = new TransformGroup();
Transform3D t3d = new Transform3D();
t3d.rotX(Math.PI / 2);
float textScale = 30f * scale;
//t3d.setScale(0.025);
t3d.setScale(textScale);
t3d.setTranslation(new Vector3f((barPos + (barPos/10.0f)), scaleBarPos.y, scaleBarPos.z + hight/2.0f));
tg.setTransform(t3d);
tg.addChild(text3dShape3d);
scene.addChild(tg);
// scene.addChild(text3dShape3d);
}
示例2: addText3D
import javax.media.j3d.Text3D; //导入依赖的package包/类
public static void addText3D(TransformGroup bg, String text, Vector3f vPos, float scale, Color3f color) {
Text3D text3d = new Text3D(new Font3D(new Font("plain", java.awt.Font.PLAIN, 1), new FontExtrusion()), text);
Shape3D text3dShape3d = new Shape3D(text3d);
Appearance appearance = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(color);
appearance.setColoringAttributes(ca);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.3f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
appearance.setTransparencyAttributes(myTA);
text3dShape3d.setAppearance(appearance);
TransformGroup tg = new TransformGroup();
Transform3D t3d = new Transform3D();
t3d.rotX(Math.PI / 2);
t3d.setTranslation(vPos);
t3d.setScale(scale * 15.0f);
tg.setTransform(t3d);
tg.addChild(text3dShape3d);
bg.addChild(tg);
}
示例3: createCompassPoint
import javax.media.j3d.Text3D; //导入依赖的package包/类
/**
* Create a text object for compass point, N S E or W
* @param text text to display
* @param locn position at which to display
* @param font 3d font to use
* @return Shape3D object
*/
private Shape3D createCompassPoint(String inText, Point3f inLocn, Font3D inFont)
{
Text3D txt = new Text3D(inFont, inText, inLocn, Text3D.ALIGN_FIRST, Text3D.PATH_RIGHT);
Material mat = new Material(new Color3f(0.5f, 0.5f, 0.55f),
new Color3f(0.05f, 0.05f, 0.1f), new Color3f(0.3f, 0.4f, 0.5f),
new Color3f(0.4f, 0.5f, 0.7f), 70.0f);
mat.setLightingEnable(true);
Appearance app = new Appearance();
app.setMaterial(mat);
Shape3D shape = new Shape3D(txt, app);
return shape;
}
示例4: generateLabel
import javax.media.j3d.Text3D; //导入依赖的package包/类
/**
* Fonction permettant de créer un label
*
* @param x
* @param y
* @param text
* @param color
* @param distance distance d'apparition
* @param textSize taille du texte
* @return distance à partir de laquelle apparaitra l'objet
*/
private static Group generateLabel(double x, double y, String text,
Color color, float distance, int textSize) {
// On prend une font de type Arial
Font3D f3d = new Font3D(new Font("Arial", Font.PLAIN, 1),
new FontExtrusion());
// On crée le texte 3D
Text3D t = new Text3D(f3d, text, new Point3f(0, 0, 0), Text3D.ALIGN_CENTER,
Text3D.PATH_RIGHT);
// On le dimensionne
Transform3D trans1 = new Transform3D();
trans1.setScale(new Vector3d(textSize, textSize, textSize / 3));
TransformGroup tg = new TransformGroup(trans1);
// On le place au bon endroit
Transform3D trans = new Transform3D();
trans.setTranslation(new Vector3d(x, y, 0));
TransformGroup tg2 = new TransformGroup(trans);
// On lui applique une apparence
Appearance ap = Level.generateApparence(color, 1, true);
Shape3D s = new Shape3D(t, ap);
// Create the transformgroup used for the billboard
TransformGroup billBoardGroup = new TransformGroup();
// Set the access rights to the group
billBoardGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// Add the cube to the group
billBoardGroup.addChild(s);
// Gestion du Billboard pour le voir toujours de face
Billboard myBillboard = new Billboard(billBoardGroup,
Billboard.ROTATE_ABOUT_POINT, new Vector3f());
myBillboard.setSchedulingBounds(billBoardGroup.getBounds());
tg.addChild(billBoardGroup);
tg.addChild(myBillboard);
// Création d'un switch permettant de gérer le LOD (disparition lorsque
// l'objet est trop loin)
Switch targetSwitch = new Switch();
targetSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
// add visual objects to the target switch
targetSwitch.addChild(tg);
BoundingSphere bounds = new BoundingSphere();
// create DistanceLOD object
float[] distances = { distance };
DistanceLOD dLOD = new DistanceLOD(distances);
dLOD.setSchedulingBounds(bounds);
dLOD.addSwitch(targetSwitch);
tg2.addChild(targetSwitch);
tg2.addChild(dLOD);
return tg2;
}