本文整理汇总了Java中javax.media.j3d.Shape3D.setAppearance方法的典型用法代码示例。如果您正苦于以下问题:Java Shape3D.setAppearance方法的具体用法?Java Shape3D.setAppearance怎么用?Java Shape3D.setAppearance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.Shape3D
的用法示例。
在下文中一共展示了Shape3D.setAppearance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Ground3D
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
/**
* Creates a 3D ground for the given <code>home</code>.
*/
public Ground3D(Home home, float originX, float originY, float width, float depth, boolean waitTextureLoadingEnd)
{
setUserData(home);
this.originX = originX;
this.originY = originY;
this.width = width;
this.depth = depth;
Appearance groundAppearance = new Appearance();
groundAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
groundAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
TextureAttributes textureAttributes = new TextureAttributes();
textureAttributes.setTextureMode(TextureAttributes.MODULATE);
groundAppearance.setTextureAttributes(textureAttributes);
groundAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
groundAppearance.setTransparencyAttributes(transparencyAttributes);
final Shape3D groundShape = new Shape3D();
groundShape.setAppearance(groundAppearance);
groundShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
groundShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
groundShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
setCapability(ALLOW_CHILDREN_READ);
addChild(groundShape);
update(waitTextureLoadingEnd);
}
示例2: createWallPartShape
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
/**
* Returns a new wall part shape with no geometry
* and a default appearance with a white material.
*/
private Node createWallPartShape(boolean outline)
{
Shape3D wallShape = new Shape3D();
// Allow wall shape to change its geometry
wallShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
wallShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
wallShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
Appearance wallAppearance = new Appearance();
wallShape.setAppearance(wallAppearance);
wallAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
wallAppearance.setTransparencyAttributes(transparencyAttributes);
wallAppearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
wallAppearance.setRenderingAttributes(renderingAttributes);
if (outline)
{
wallAppearance.setColoringAttributes(Object3DBranch.OUTLINE_COLORING_ATTRIBUTES);
wallAppearance.setPolygonAttributes(Object3DBranch.OUTLINE_POLYGON_ATTRIBUTES);
wallAppearance.setLineAttributes(Object3DBranch.OUTLINE_LINE_ATTRIBUTES);
}
else
{
wallAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
wallAppearance.setMaterial(DEFAULT_MATERIAL);
wallAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
wallAppearance.setCapability(Appearance.ALLOW_TEXTURE_READ);
// Mix texture and wall color
wallAppearance.setTextureAttributes(MODULATE_TEXTURE_ATTRIBUTES);
}
return wallShape;
}
示例3: createRoomPartShape
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
/**
* Returns a new room part shape with no geometry
* and a default appearance with a white material.
*/
private Node createRoomPartShape()
{
Shape3D roomShape = new Shape3D();
// Allow room shape to change its geometry
roomShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
roomShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
roomShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
Appearance roomAppearance = new Appearance();
roomShape.setAppearance(roomAppearance);
roomAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
roomAppearance.setTransparencyAttributes(transparencyAttributes);
roomAppearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
roomAppearance.setRenderingAttributes(renderingAttributes);
roomAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
roomAppearance.setMaterial(DEFAULT_MATERIAL);
roomAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
roomAppearance.setCapability(Appearance.ALLOW_TEXTURE_READ);
// Mix texture and room color
roomAppearance.setTextureAttributes(MODULATE_TEXTURE_ATTRIBUTES);
return roomShape;
}
示例4: addScaleBarToSceneGraph
import javax.media.j3d.Shape3D; //导入方法依赖的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);
}
示例5: addText3D
import javax.media.j3d.Shape3D; //导入方法依赖的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);
}
示例6: createLine
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
/**
* Erzeugt eine Linie auf dem Boden Alle Postionen sind keine
* Weltkoordinaten, sondern ganzen Einheiten, wie sie aus dem ASCII-File
* kommen
*
* @param x
* Position in X-Richtung
* @param y
* Position in Y-Richtung
* @param points
* Punkte der Linie
* @param appearance
* Art der Linie
*/
private void createLine(int x, int y, float[] points, Appearance appearance) {
// zwei Polygone (Deckel und Boden) mit N Ecken
float[] p = new float[points.length];
int stripCounts[] = { points.length / 3 };
// Zaehler
int n = 0;
for (n = 0; n < points.length; n++) {
p[n] = points[n] * parcours.getBlockSizeInM();
}
createFloor(x, y, getAppearance(' '));
// Polygone in darstellbare Form umwandeln
GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(p);
gi.setStripCounts(stripCounts);
NormalGenerator ng = new NormalGenerator();
ng.generateNormals(gi);
gi.recomputeIndices();
Stripifier st = new Stripifier();
st.stripify(gi);
gi.recomputeIndices();
// Hinzufuegen der Ober- und Unterseite des Linien-Shape3D
Shape3D ls = new Shape3D();
ls.addGeometry(gi.getGeometryArray());
ls.setAppearance(appearance);
parcours.addFloor(ls, x + 0.5f, y + 0.5f, 0.002f);
}
示例7: getAppearance
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
static Appearance getAppearance( Shape3D s3D )
{
Appearance app = s3D.getAppearance( );
if( app == null )
{
s3D.setAppearance( app = new Appearance( ) );
}
return app;
}
示例8: NeuGenVisualization
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
public NeuGenVisualization(VisualizationTask task, BranchGroup bg, int zoom,
VisualizationDialog.VisualMethod visMethod, boolean loadedGraph) {
this.task = task;
this.sceneBG = bg;
this.scale = 1f;
this.visMethod = visMethod;
//this.scale *= zoom;
//retrieve the Shape3D object from the scene
if (loadedGraph) {
init1();
init2();
} else {
Shape3D shape = (Shape3D) sceneBG.getChild(0);
//create an Appearance and Material
Appearance app = new Appearance();
app.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
app.setCapability(Appearance.ALLOW_MATERIAL_READ);
switch (visMethod) {
case WIRE: {
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f);
Material mat = new Material(objColor, black, objColor, black, 80.0f);
app.setMaterial(mat);
PolygonAttributes pa = new PolygonAttributes();
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
app.setPolygonAttributes(pa);
ColoringAttributes colorAtt = new ColoringAttributes();
colorAtt.setShadeModel(ColoringAttributes.SHADE_GOURAUD);
app.setColoringAttributes(colorAtt);
TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.NICEST, 0.5f);
app.setTransparencyAttributes(ta);
shape.setAppearance(app);
}
}
init1();
spinner = createSpinner();
sceneBG.addChild(spinner);
setLightingRecon(spinner);
addBackground(sceneBG);
addKeyNavigator(sceneBG);
init2();
}
}
示例9: addAxons
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addAxons(TransformGroup objRoot) {
ngView.outPrintln(" processing axons geometry\n");
task.setMyProgress(0.3f);
Appearance appearance = new Appearance();
/*
float width = 1.0f;
boolean antialias = false;
appearance.setLineAttributes(new LineAttributes(width, LineAttributes.PATTERN_SOLID, antialias));
*/
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.2f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
appearance.setTransparencyAttributes(myTA);
axonsShape3D = new Shape3D();
//axonsShape3D.removeGeometry(0);
axonsShape3D.removeAllGeometries();
axonsShape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
axonsShape3D.setAppearance(appearance);
int cAx = 0, totalNumberOfAxonalSegments;
totalNumberOfAxonalSegments = net.getTotalNumOfAxonalSegments();
//logger.debug("totalNumberOfAxonalSegments: " + totalNumberOfAxonalSegments);
for (Neuron neuron : net.getNeuronList()) {
if (!neuron.collide() && collide) {
continue;
}
Section firstSection = neuron.getAxon().getFirstSection();
if (firstSection != null) {
Section.Iterator secIterator = firstSection.getIterator();
while (secIterator.hasNext()) {
Section section = secIterator.next();
Section.SectionType secType = section.getSectionType();
for (Segment segment : section.getSegments()) {
Point3f segStart = new Point3f(segment.getStart());
segStart.scale(scale);
Point3f segEnd = new Point3f(segment.getEnd());
segEnd.scale(scale);
LineArray la = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la.setCoordinate(0, segStart);
la.setCoordinate(1, segEnd);
/* old color
la.setColor(0, new Color3f(0.25f, 0.41f, 0.88f));
la.setColor(1, new Color3f(0.25f, 0.41f, 0.88f));
*/
Color3f color;// = Utils3D.darkgreyblue;
if (secType == Section.SectionType.MYELINIZED) {
//color = Utils3D.darkgreyblue;
color = Utils3D.darkOrange;
} else {
//color = Utils3D.turquoise1;
color = Utils3D.darkSalmon;
}
la.setColor(0, color);
la.setColor(1, color);
//lineArrayList.add(la);
axonsShape3D.addGeometry(la);
cAx++;
if (totalNumberOfAxonalSegments > 0) {
task.setMyProgress(0.3f + cAx * 0.2f / totalNumberOfAxonalSegments);
}
}
}
}
}
objRoot.addChild(axonsShape3D);
}
示例10: addDendrites
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
private void addDendrites(TransformGroup objRoot) {
ngView.outPrintln(" processing dendrites geometry\n");
Appearance appearance = new Appearance();
//float width = 1.0f * scale;
//boolean antialias = true;
//appearance.setLineAttributes(new LineAttributes(width, LineAttributes.PATTERN_SOLID, antialias));
dendritesShape3D = new Shape3D();
dendritesShape3D.removeAllGeometries();
dendritesShape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
//dendritesShape3D.removeGeometry(0);
//dendritesShape3D.setAppearance(appearance);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.2f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
appearance.setTransparencyAttributes(myTA);
dendritesShape3D.setAppearance(appearance);
int cDen = 0, totalNumberOfDenSegments;
totalNumberOfDenSegments = net.getTotalNumOfDenSegments();
//logger.info("total number of dendrite segments: " + totalNumberOfDenSegments);
task.setMyProgress(0.5f);
for (Neuron neuron : net.getNeuronList()) {
if (!neuron.collide() && collide) {
continue;
}
for (Dendrite dendrite : neuron.getDendrites()) {
Section firstSection = dendrite.getFirstSection();
if (firstSection != null) {
Section.Iterator secIterator = firstSection.getIterator();
while (secIterator.hasNext()) {
Section section = secIterator.next();
Section.SectionType secType = section.getSectionType();
for (Segment segment : section.getSegments()) {
Point3f segStart = new Point3f(segment.getStart());
segStart.scale(scale);
Point3f segEnd = new Point3f(segment.getEnd());
segEnd.scale(scale);
LineArray la = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la.setCoordinate(0, segStart);
la.setCoordinate(1, segEnd);
Color3f denColor = Utils3D.darkOliveGreen3;
if (secType != null) {
if (secType.equals(Section.SectionType.APICAL)) {
//logger.info("this is an apical section");
denColor = Utils3D.magenta;
} else if (secType.equals(Section.SectionType.BASAL)) {
//logger.info("this is a basal section");
//denColor = Utils3D.mediumSpringGreen;
denColor = Utils3D.yellow;
} else if (secType.equals(Section.SectionType.OBLIQUE)) {
//logger.info("this is an oblique section");
denColor = Utils3D.brown1;
}
}
la.setColor(0, denColor);
la.setColor(1, denColor);
//lineArrayList.add(la);
/* old color
la.setColor(0, new Color3f(0.93f, 0.87f, 0.51f));
la.setColor(1, new Color3f(0.93f, 0.87f, 0.51f));
*/
dendritesShape3D.addGeometry(la);
cDen++;
if (totalNumberOfDenSegments > 0 && !Float.isInfinite(totalNumberOfDenSegments)) {
task.setMyProgress(0.5f + cDen * 0.3f / totalNumberOfDenSegments);
}
}
}
}
}
}
objRoot.addChild(dendritesShape3D);
}
示例11: manifestationAdded
import javax.media.j3d.Shape3D; //导入方法依赖的package包/类
@Override
public void manifestationAdded( RenderedManifestation rm )
{
// int[] /* AlgebraicVector */location = rm.getManifestation().getLocation();
// if ( location == null )
// location = rm.getShape().getField().origin( 3 );
RealVector loc = rm .getLocation();
if ( loc == null )
loc = new RealVector( 0d, 0d, 0d );
Appearance appearance = mFactory .getAppearance( rm.getColor(), rm.getGlow() > 0f, rm.getTransparency() > 0f );
Geometry geom = mFactory .makeSolidGeometry( rm );
if ( logger .isLoggable( Level.FINEST )
&& rm .getManifestation() == null )
{
Direction orbit = rm .getShape() .getOrbit();
String shape = ( orbit == null )? "BALL" : orbit .getName() + " strut";
logger .finest( shape + " at " + loc );
}
// if we rendering wireframe, we're using absolute coordinates
if ( ( geom instanceof PointArray ) || ( geom instanceof LineArray ) )
// location = rm.getShape().getField().origin( 3 );
loc = new RealVector( 0d, 0d, 0d );
Shape3D solidPolyhedron = new Shape3D( geom );
solidPolyhedron .setCapability( Shape3D.ALLOW_APPEARANCE_WRITE );
solidPolyhedron .setAppearance( appearance );
solidPolyhedron .setUserData( rm );
// omit this if trying to pre-optimize with makeGeometryAt
Transform3D move = new Transform3D();
move.setTranslation( new Vector3d( loc.x, loc.y, loc.z ) );
TransformGroup tg = new TransformGroup( move );
tg.setCapability( Group.ALLOW_CHILDREN_EXTEND );
tg.setCapability( Group.ALLOW_CHILDREN_READ );
tg.setCapability( Group.ALLOW_CHILDREN_WRITE );
tg.setCapability( BranchGroup.ALLOW_DETACH );
tg.setCapability( Shape3D.ENABLE_PICK_REPORTING );
tg.setPickable( true );
tg.addChild( solidPolyhedron );
if ( drawOutlines ) {
geom = mFactory .makeOutlineGeometry( rm );
Shape3D outlinePolyhedron = new Shape3D( geom );
outlinePolyhedron .setAppearance( mFactory .getOutlineAppearance() );
tg .addChild( outlinePolyhedron );
}
// Create a Text2D leaf node, add it to the scene graph.
// Text2D text2D = new Text2D( " label", new Color3f( 0.9f, 1.0f,
// 0.0f),
// "Helvetica", 36, Font.ITALIC );
// text2D .setRectangleScaleFactor( 0.02f );
// text2D .getGeometry() .setCapability( Geometry .ALLOW_INTERSECT );
// OrientedShape3D os3D = new OrientedShape3D();
// os3D .setGeometry( text2D.getGeometry() );
// os3D .setAppearance( text2D.getAppearance() );
// os3D .setAlignmentMode( OrientedShape3D.ROTATE_ABOUT_POINT );
// tg .addChild( os3D );
BranchGroup group = new BranchGroup();
group.setCapability( Group.ALLOW_CHILDREN_EXTEND );
group.setCapability( Group.ALLOW_CHILDREN_READ );
group.setCapability( Group.ALLOW_CHILDREN_WRITE );
group.setCapability( Node.ENABLE_PICK_REPORTING );
group.setCapability( BranchGroup.ALLOW_DETACH );
group.addChild( tg );
mScene.addChild( group );
if ( this .isSticky )
rm.setGraphicsObject( group );
}