本文整理汇总了Java中javax.media.j3d.TransparencyAttributes类的典型用法代码示例。如果您正苦于以下问题:Java TransparencyAttributes类的具体用法?Java TransparencyAttributes怎么用?Java TransparencyAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransparencyAttributes类属于javax.media.j3d包,在下文中一共展示了TransparencyAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildScene
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
@Override
void buildScene(TransformGroup transformGroup) {
transformGroup.addChild(getColorBackground(new Color(.905f, .905f, 0.95f)));
Appearance appearance = new Appearance();
Material mat = new Material();
mat.setAmbientColor(0.5f, 0.5f, 0.5f);
mat.setDiffuseColor(1.0f, 1.0f, 1.0f);
mat.setEmissiveColor(0.0f, 0.0f, 0.0f);
mat.setSpecularColor(1.0f, 1.0f, 1.0f);
mat.setShininess(80.0f);
appearance.setMaterial(mat);
TransparencyAttributes ta = new TransparencyAttributes();
ta.setTransparency(0.5f);
ta.setTransparencyMode(TransparencyAttributes.BLENDED);
appearance.setTransparencyAttributes(ta);
transformGroup.addChild(new Box(0.6f, 0.5f, 0.4f, appearance));
transformGroup.addChild(getPointLight(new Color(1.0f, 1.0f, 1.0f), new Point3f(2.0f, 2.0f, 2.0f)));
transformGroup.addChild(getAmbientLight(new Color(0.1f, 0.1f, 0.1f)));
transformGroup.setTransform(getTransform(new Vector3f(0.3f, 0.3f, 0.3f), 0.75, -1, Math.PI / 4.0d));
}
示例2: Triangle3dCreator
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
/**
* Creates a new instance of Triangle3dCreator color the color of the
* triangle
*/
public Triangle3dCreator(Color3f color) {
this.triangleColor = color;
this.triangleAppearance = new Appearance();
// ca werden nicht benoetigt
// ColoringAttributes ca = new ColoringAttributes();
// ca.setColor(triangleColor);
// this.triangleAppearance.setColoringAttributes(ca);
TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.FASTEST, 0.5f);
this.triangleAppearance.setTransparencyAttributes(ta);
// Material material = new Material();
// material.setAmbientColor(color);
// material.setShininess(0.5f);
// material.setLightingEnable(true);
// this.triangleAppearance.setMaterial(material);
this.triangleContainer = new Shape3D();
this.triangleContainer.setAppearance(triangleAppearance);
triangleContainer.removeGeometry(0);
}
示例3: Triangle3dCreator
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
/**
* Creates a new instance of Triangle3dCreator color the color of the
* triangle
*/
public Triangle3dCreator(Color3f color) {
this.triangleColor = color;
this.triangleAppearance = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(triangleColor);
this.triangleAppearance.setColoringAttributes(ca);
TransparencyAttributes ta = new TransparencyAttributes();
ta.setTransparency(0.5f);
this.triangleAppearance.setTransparencyAttributes(ta);
this.triangleContainer = new Shape3D();
triangleContainer.removeGeometry(0);
}
示例4: makeAppearance
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
private Appearance makeAppearance( Material material, Color4f color, boolean transparent )
{
Appearance appearance = new Appearance();
appearance .setMaterial( material );
appearance .setCapability( Appearance .ALLOW_MATERIAL_READ );
appearance .setCapability( Appearance .ALLOW_MATERIAL_WRITE );
material .setLightingEnable( true );
Color3f justColor = new Color3f( color .x, color.y, color.z );
appearance .setColoringAttributes( new ColoringAttributes( justColor, ColoringAttributes .SHADE_FLAT ) );
if ( transparent || color.w < 1.0f ) {
TransparencyAttributes ta = new TransparencyAttributes();
ta .setTransparencyMode( TransparencyAttributes .BLENDED );
float alpha = transparent? ( PREVIEW_TRANSPARENCY * color.w ) : color.w;
ta .setTransparency( PREVIEW_TRANSPARENCY );
appearance .setTransparencyAttributes( ta );
}
return appearance;
}
示例5: createBox
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
private Box createBox() {
// ��
Appearance app = new Appearance();
Material mat = new Material();
mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
app.setMaterial(mat);
// �����ɂ���
TransparencyAttributes transAttr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, 0.5f);
app.setTransparencyAttributes(transAttr);
Box box = new Box(0.5f, 0.5f, 0.5f, app);
return box;
}
示例6: Ball
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
public Ball(double x, double y, double z) {
position = new Vector3d(x, y, z);
velocity = new Vector3d(0, 0, 0);
acceleration = new Vector3d(0, -0.01, 0); // �����x�͈��
// �ړ��\
this.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
app = new Appearance();
Material mat = new Material();
mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
app.setMaterial(mat);
TransparencyAttributes transAttr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, 0.2f);
app.setTransparencyAttributes(transAttr);
// �{�[����lj�
this.addChild(new Sphere(radius, Sphere.GENERATE_NORMALS, 100, app));
move();
}
示例7: DebugVector
import javax.media.j3d.TransparencyAttributes; //导入依赖的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 );
}
示例8: maskAppearance
import javax.media.j3d.TransparencyAttributes; //导入依赖的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;
}
示例9: Ground3D
import javax.media.j3d.TransparencyAttributes; //导入依赖的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);
}
示例10: createWallPartShape
import javax.media.j3d.TransparencyAttributes; //导入依赖的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;
}
示例11: updateFilledWallSideAppearance
import javax.media.j3d.TransparencyAttributes; //导入依赖的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);
}
示例12: createRoomPartShape
import javax.media.j3d.TransparencyAttributes; //导入依赖的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;
}
示例13: PointsShape
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
public PointsShape() {
// BY_REFERENCE PointArray storing coordinates and colors
cloud = new PointArray(MAX_POINTS, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.BY_REFERENCE);
mesh = new TriangleArray(MAX_POINTS, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.BY_REFERENCE);
TransparencyAttributes ta = new TransparencyAttributes();
ta.setTransparencyMode(TransparencyAttributes.NICEST);
ta.setTransparency(0.0f);
PointAttributes pointAttributes = new PointAttributes();
pointAttributes.setPointSize(2.83f);
pointAttributes.setCapability(PointAttributes.ALLOW_SIZE_WRITE);
Appearance a = new Appearance();
a.setPointAttributes(pointAttributes);
a.setTransparencyAttributes(ta);
// the data structure can be read and written at run time
cloud.setCapability(GeometryArray.ALLOW_REF_DATA_READ);
cloud.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
mesh.setCapability(GeometryArray.ALLOW_REF_DATA_READ);
mesh.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
sem = new Semaphore(0);
// create PointsShape geometry and appearance
createGeometry();
createAppearance();
// setAppearance(a);
}
示例14: SlicePlane3DRenderer
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
public SlicePlane3DRenderer(View view, Context context, Volume vol)
{
super(view, context, vol);
texVol = new Texture3DVolume(context, vol);
TransparencyAttributes transAttr = new TransparencyAttributes();
transAttr.setTransparencyMode(TransparencyAttributes.BLENDED);
texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
texAttr.setCapability(TextureAttributes.ALLOW_COLOR_TABLE_WRITE);
Material m = new Material();
m.setLightingEnable(false);
PolygonAttributes p = new PolygonAttributes();
p.setCullFace(PolygonAttributes.CULL_NONE);
p.setPolygonOffset(1.0f);
p.setPolygonOffsetFactor(1.0f);
appearance = new Appearance();
appearance.setMaterial(m);
appearance.setTextureAttributes(texAttr);
appearance.setTransparencyAttributes(transAttr);
appearance.setPolygonAttributes(p);
appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
appearance.setCapability(Appearance.ALLOW_TEXGEN_WRITE);
shape = new Shape3D(null, appearance);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
root.addChild(shape);
}
示例15: SlicePlane2DRenderer
import javax.media.j3d.TransparencyAttributes; //导入依赖的package包/类
public SlicePlane2DRenderer(View view, Context context, Volume vol)
{
super(view, context, vol);
texVol = new Texture2DVolume(context, vol);
for (int i = 0; i < 4; i++)
{
shapeColrs[i] = new Color4f();
}
texAttr.setTextureMode(TextureAttributes.MODULATE);
texAttr.setCapability(TextureAttributes.ALLOW_COLOR_TABLE_WRITE);
trans.setTransparencyMode(TransparencyAttributes.BLENDED);
trans.setSrcBlendFunction(TransparencyAttributes.BLEND_ONE);
trans.setDstBlendFunction(TransparencyAttributes.BLEND_ONE);
m.setLightingEnable(false);
p.setCullFace(PolygonAttributes.CULL_NONE);
r.setDepthBufferWriteEnable(false);
// these are the default for no texture
trans.setTransparency(0.0f);
clr.setColor(0.0f, 0.0f, 0.0f);
// set up an initial, empty slice
sliceGroup.setCapability(Group.ALLOW_CHILDREN_READ);
sliceGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
sliceGroup.addChild(null);
root.addChild(sliceGroup);
numSlicePts = 0;
setSliceGeo();
}