本文整理汇总了Java中javax.media.j3d.TransparencyAttributes.setTransparencyMode方法的典型用法代码示例。如果您正苦于以下问题:Java TransparencyAttributes.setTransparencyMode方法的具体用法?Java TransparencyAttributes.setTransparencyMode怎么用?Java TransparencyAttributes.setTransparencyMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.TransparencyAttributes
的用法示例。
在下文中一共展示了TransparencyAttributes.setTransparencyMode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: CorticalColumn
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的package包/类
public CorticalColumn(float scale) {
super();
this.scale = scale;
Region.Param.ColumnParam par = Region.Param.getInstance().getColumnParam();
lengthX = par.getLength() * scale;
widthY = par.getWidth() * scale;
layer1 = par.getLayer1() * scale;
layer23 = par.getLayer23() * scale;
layer4 = par.getLayer4() * scale;
layer5A = par.getLayer5A() * scale;
layer5B = par.getLayer5B() * scale;
layer6 = par.getLayer6() * scale;
heightZ = par.getHeight() * scale;
Appearance ap = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(Utils3D.grey);
ap.setColoringAttributes(ca);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.7f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
ap.setTransparencyAttributes(myTA);
//render the Box as a wire frame
PolygonAttributes polyAttrbutes = new PolygonAttributes();
polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
ap.setPolygonAttributes(polyAttrbutes);
setAppearance(ap);
}
示例8: addText3D
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的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);
}
示例9: RegionCA1
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的package包/类
public RegionCA1(float scale) {
super();
this.scale = scale;
Region.Param.CA1Param regPar = Region.Param.getInstance().getCa1Param();
lengthX = regPar.getLength() * scale;
widthY = regPar.getWidth() * scale;
stratumOriens = regPar.getStratumOriens() * scale;
stratumPyramidale = regPar.getStratumPyramidale() * scale;
stratumRadiatum = regPar.getStratumRadiatum() * scale;
stratumLacunosum = regPar.getStratumLacunosum() * scale;
heightZ = regPar.getHeight() * scale;
Appearance ap = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(Utils3D.grey);
ap.setColoringAttributes(ca);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.7f);
myTA.setTransparencyMode(TransparencyAttributes.FASTEST);
ap.setTransparencyAttributes(myTA);
//render the Box as a wire frame
PolygonAttributes polyAttrbutes = new PolygonAttributes();
polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
ap.setPolygonAttributes(polyAttrbutes);
setAppearance(ap);
}
示例10: 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);
}
示例11: updateRoomPartAppearance
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的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);
}
示例12: addCoordinateSphereAxesToSceneGraph
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的package包/类
/**
* Function to add a white sphere and axes at the origin of the
* coordinate system for better orientation. The z-axis is in black.
*
* @param scene
* @param radius
*/
public static void addCoordinateSphereAxesToSceneGraph(TransformGroup scene, float scale, Point3f coordPos) {
if (coordPos == null) {
coordPos = new Point3f();
}
Transform3D t3d = new Transform3D();
Vector3f spherePos = new Vector3f(coordPos);
t3d.set(spherePos);
TransformGroup tg = new TransformGroup(t3d);
float rad = 10.0f * scale;
Appearance ap = new Appearance();
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.1f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
ap.setTransparencyAttributes(myTA);
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(grey);
ap.setColoringAttributes(ca);
tg.addChild(new Sphere(rad, ap));
scene.addChild(tg);
LineArray la1 = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la1.setCoordinate(0, coordPos);
float axeSize = 100.0f * scale;
// la1.setCoordinate(1, new Point3f(0.5f * rad, 0.0f, 0.0f));
la1.setCoordinate(1, new Point3f(coordPos.x + axeSize, coordPos.y, coordPos.z));
for (int i = 0; i < 2; ++i) {
la1.setColor(i, yellow);
}
scene.addChild(new Shape3D(la1));
LineArray la2 = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la2.setCoordinate(0, coordPos);
la2.setCoordinate(1, new Point3f(coordPos.x, coordPos.y + axeSize, coordPos.z));
for (int i = 0; i < 2; ++i) {
la2.setColor(i, red);
}
scene.addChild(new Shape3D(la2));
LineArray la3 = new LineArray(2, LineArray.COORDINATES | LineArray.COLOR_3);
la3.setCoordinate(0, coordPos);
la3.setCoordinate(1, new Point3f(coordPos.x, coordPos.y, coordPos.z + axeSize));
for (int i = 0; i < 2; ++i) {
la3.setColor(i, blue);
}
scene.addChild(new Shape3D(la3));
}
示例13: addAxons
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的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);
}
示例14: addDendrites
import javax.media.j3d.TransparencyAttributes; //导入方法依赖的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);
}