本文整理汇总了Java中javax.media.j3d.RenderingAttributes类的典型用法代码示例。如果您正苦于以下问题:Java RenderingAttributes类的具体用法?Java RenderingAttributes怎么用?Java RenderingAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenderingAttributes类属于javax.media.j3d包,在下文中一共展示了RenderingAttributes类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DebugVector
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
public DebugVector( Point3f location , Vector3f extent , Color3f color )
{
ColoringAttributes ca = new ColoringAttributes( );
ca.setCapability( ColoringAttributes.ALLOW_COLOR_WRITE );
RenderingAttributes ra = new RenderingAttributes( );
ra.setCapability( RenderingAttributes.ALLOW_VISIBLE_WRITE );
TransparencyAttributes ta = new TransparencyAttributes( );
ta.setTransparency( 0.3f );
Appearance app = new Appearance( );
app.setColoringAttributes( ca );
app.setCapability( Appearance.ALLOW_COLORING_ATTRIBUTES_READ );
app.setRenderingAttributes( ra );
app.setCapability( Appearance.ALLOW_RENDERING_ATTRIBUTES_READ );
shape.setAppearance( app );
shape.setCapability( Shape3D.ALLOW_APPEARANCE_READ );
shape.setCapability( Shape3D.ALLOW_GEOMETRY_WRITE );
setVector( location , extent );
setColor( color );
addChild( shape );
}
示例2: maskAppearance
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
public static Appearance maskAppearance( )
{
final Appearance app = new Appearance( );
final TransparencyAttributes ta = new TransparencyAttributes( );
ta.setTransparencyMode( TransparencyAttributes.BLENDED );
ta.setSrcBlendFunction( TransparencyAttributes.BLEND_ZERO );
ta.setDstBlendFunction( TransparencyAttributes.BLEND_ONE );
app.setTransparencyAttributes( ta );
final ColoringAttributes ca = new ColoringAttributes( );
ca.setColor( new Color3f( 0 , 0 , 0 ) );
app.setColoringAttributes( ca );
final RenderingAttributes ra = new RenderingAttributes( );
ra.setDepthBufferWriteEnable( true );
app.setRenderingAttributes( ra );
return app;
}
示例3: getVertexCount
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
/**
* Returns the total count of vertices in all geometries.
*/
private int getVertexCount(Node node)
{
int count = 0;
if (node instanceof Group)
{
// Enumerate all children
Enumeration<?> enumeration = ((Group) node).getAllChildren();
while (enumeration.hasMoreElements())
{
count += getVertexCount((Node) enumeration.nextElement());
}
}
else if (node instanceof Link)
{
count = getVertexCount(((Link) node).getSharedGroup());
}
else if (node instanceof Shape3D)
{
Shape3D shape = (Shape3D) node;
Appearance appearance = shape.getAppearance();
RenderingAttributes renderingAttributes = appearance != null ? appearance.getRenderingAttributes() : null;
if (renderingAttributes == null || renderingAttributes.getVisible())
{
for (int i = 0, n = shape.numGeometries(); i < n; i++)
{
Geometry geometry = shape.getGeometry(i);
if (geometry instanceof GeometryArray)
{
count += ((GeometryArray) geometry).getVertexCount();
}
}
}
}
return count;
}
示例4: createWallPartShape
import javax.media.j3d.RenderingAttributes; //导入依赖的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;
}
示例5: updateFilledWallSideAppearance
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
/**
* Sets filled wall side appearance with its color, texture, transparency and visibility.
*/
private void updateFilledWallSideAppearance(final Appearance wallSideAppearance, final HomeTexture wallSideTexture,
boolean waitTextureLoadingEnd, Integer wallSideColor, float shininess)
{
if (wallSideTexture == null)
{
wallSideAppearance.setMaterial(getMaterial(wallSideColor, wallSideColor, shininess));
wallSideAppearance.setTexture(null);
}
else
{
// Update material and texture of wall side
wallSideAppearance.setMaterial(getMaterial(DEFAULT_COLOR, DEFAULT_AMBIENT_COLOR, shininess));
final TextureManager textureManager = TextureManager.getInstance();
textureManager.loadTexture(wallSideTexture.getImage(), wallSideTexture.getAngle(), waitTextureLoadingEnd,
new TextureManager.TextureObserver()
{
public void textureUpdated(Texture texture)
{
wallSideAppearance.setTexture(getHomeTextureClone(texture, home));
}
});
}
// Update wall side transparency
float wallsAlpha = this.home.getEnvironment().getWallsAlpha();
TransparencyAttributes transparencyAttributes = wallSideAppearance.getTransparencyAttributes();
transparencyAttributes.setTransparency(wallsAlpha);
// If walls alpha is equal to zero, turn off transparency to get better results
transparencyAttributes
.setTransparencyMode(wallsAlpha == 0 ? TransparencyAttributes.NONE : TransparencyAttributes.NICEST);
// Update wall side visibility
RenderingAttributes renderingAttributes = wallSideAppearance.getRenderingAttributes();
HomeEnvironment.DrawingMode drawingMode = this.home.getEnvironment().getDrawingMode();
renderingAttributes.setVisible(drawingMode == null || drawingMode == HomeEnvironment.DrawingMode.FILL
|| drawingMode == HomeEnvironment.DrawingMode.FILL_AND_OUTLINE);
}
示例6: updateOutlineWallSideAppearance
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
/**
* Sets outline wall side visibility.
*/
private void updateOutlineWallSideAppearance(final Appearance wallSideAppearance)
{
// Update wall side visibility
RenderingAttributes renderingAttributes = wallSideAppearance.getRenderingAttributes();
HomeEnvironment.DrawingMode drawingMode = this.home.getEnvironment().getDrawingMode();
renderingAttributes.setVisible(drawingMode == HomeEnvironment.DrawingMode.OUTLINE
|| drawingMode == HomeEnvironment.DrawingMode.FILL_AND_OUTLINE);
}
示例7: setOutlineAppearance
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
/**
* Sets the outline appearance on all the children of <code>node</code>.
*/
private void setOutlineAppearance(Node node)
{
if (node instanceof Group)
{
Enumeration<?> enumeration = ((Group) node).getAllChildren();
while (enumeration.hasMoreElements())
{
setOutlineAppearance((Node) enumeration.nextElement());
}
}
else if (node instanceof Link)
{
setOutlineAppearance(((Link) node).getSharedGroup());
}
else if (node instanceof Shape3D)
{
Appearance outlineAppearance = new Appearance();
((Shape3D) node).setAppearance(outlineAppearance);
outlineAppearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
outlineAppearance.setRenderingAttributes(renderingAttributes);
outlineAppearance.setColoringAttributes(Object3DBranch.OUTLINE_COLORING_ATTRIBUTES);
outlineAppearance.setPolygonAttributes(Object3DBranch.OUTLINE_POLYGON_ATTRIBUTES);
outlineAppearance.setLineAttributes(Object3DBranch.OUTLINE_LINE_ATTRIBUTES);
}
}
示例8: createRoomPartShape
import javax.media.j3d.RenderingAttributes; //导入依赖的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;
}
示例9: SlicePlaneRenderer
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
public SlicePlaneRenderer(View view, Context context, Volume vol)
{
super(view, context, vol);
volRefPtAttr = (CoordAttr) context.getAttr("Vol Ref Pt");
root = new BranchGroup();
// subclasses add the slice geometry to root
borderSwitch = new Switch(Switch.CHILD_ALL);
borderSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
RenderingAttributes ra = new RenderingAttributes();
ra.setDepthBufferEnable(true);
ColoringAttributes bclr = new ColoringAttributes(0.4f, 0.4f, 0.4f,
ColoringAttributes.SHADE_FLAT);
Appearance ba = new Appearance();
ba.setColoringAttributes(bclr);
ba.setRenderingAttributes(ra);
borderShape = new Shape3D(null, ba);
borderShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
borderSwitch.addChild(borderShape);
root.addChild(borderSwitch);
root.setCapability(BranchGroup.ALLOW_DETACH);
root.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
}
示例10: debugAppearance
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
public static Appearance debugAppearance( Color4f color )
{
final Appearance result = new Appearance( );
setColor( result , color , false );
setDepthTestFunction( result , RenderingAttributes.ALWAYS );
return result;
}
示例11: isVisible
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
public static boolean isVisible( Appearance app )
{
final RenderingAttributes ra = app.getRenderingAttributes( );
if( ra == null )
{
return true;
}
return ra.getVisible( );
}
示例12: updateRoomPartAppearance
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
/**
* Sets room part appearance with its color, texture and visibility.
*/
private void updateRoomPartAppearance(final Appearance roomPartAppearance, final HomeTexture roomPartTexture,
boolean waitTextureLoadingEnd, Integer roomPartColor, float shininess, boolean visible,
boolean ignoreTransparency)
{
if (roomPartTexture == null)
{
roomPartAppearance.setMaterial(getMaterial(roomPartColor, roomPartColor, shininess));
roomPartAppearance.setTexture(null);
}
else
{
// Update material and texture of room part
roomPartAppearance.setMaterial(getMaterial(DEFAULT_COLOR, DEFAULT_AMBIENT_COLOR, shininess));
final TextureManager textureManager = TextureManager.getInstance();
textureManager.loadTexture(roomPartTexture.getImage(), roomPartTexture.getAngle(), waitTextureLoadingEnd,
new TextureManager.TextureObserver()
{
public void textureUpdated(Texture texture)
{
texture = getHomeTextureClone(texture, home);
if (roomPartAppearance.getTexture() != texture)
{
roomPartAppearance.setTexture(texture);
}
}
});
}
if (!ignoreTransparency)
{
// Update room part transparency
float upperRoomsAlpha = this.home.getEnvironment().getWallsAlpha();
TransparencyAttributes transparencyAttributes = roomPartAppearance.getTransparencyAttributes();
transparencyAttributes.setTransparency(upperRoomsAlpha);
// If alpha is equal to zero, turn off transparency to get better results
transparencyAttributes.setTransparencyMode(
upperRoomsAlpha == 0 ? TransparencyAttributes.NONE : TransparencyAttributes.NICEST);
}
// Update room part visibility
RenderingAttributes renderingAttributes = roomPartAppearance.getRenderingAttributes();
renderingAttributes.setVisible(visible);
}
示例13: setup
import javax.media.j3d.RenderingAttributes; //导入依赖的package包/类
private void setup()
{
// Can be used to make coordSys smaller TODO: specify in constructor
Transform3D coordTrans = new Transform3D();
coordTrans.setTranslation(translation);
coordTrans.setScale(scale);
setTransform(coordTrans);
RenderingAttributes ra = new RenderingAttributes();
ra.setDepthBufferEnable(true);
LineArray xGeom = new LineArray(10, GeometryArray.COORDINATES);
setupArrow(plusX, plusY, plusZ);
xGeom.setCoordinates(0, line);
ColoringAttributes xColoringAttributes = new ColoringAttributes(1.0f,
0.0f, 0.0f, ColoringAttributes.SHADE_FLAT);
Appearance xAppearance = new Appearance();
xAppearance.setColoringAttributes(xColoringAttributes);
xAppearance.setRenderingAttributes(ra);
Shape3D xShape = new Shape3D(xGeom, xAppearance);
addChild(xShape);
LineArray yGeom = new LineArray(10, GeometryArray.COORDINATES);
setupArrow(plusY, plusX, plusZ);
yGeom.setCoordinates(0, line);
ColoringAttributes yColoringAttributes = new ColoringAttributes(0.0f,
1.0f, 0.0f, ColoringAttributes.SHADE_FLAT);
Appearance yAppearance = new Appearance();
yAppearance.setColoringAttributes(yColoringAttributes);
yAppearance.setRenderingAttributes(ra);
Shape3D yShape = new Shape3D(yGeom, yAppearance);
addChild(yShape);
LineArray zGeom = new LineArray(10, GeometryArray.COORDINATES);
setupArrow(plusZ, plusX, plusY);
zGeom.setCoordinates(0, line);
ColoringAttributes zColoringAttributes = new ColoringAttributes(0.0f,
0.0f, 1.0f, ColoringAttributes.SHADE_FLAT);
Appearance zAppearance = new Appearance();
zAppearance.setColoringAttributes(zColoringAttributes);
zAppearance.setRenderingAttributes(ra);
Shape3D zShape = new Shape3D(zGeom, zAppearance);
addChild(zShape);
}