List of usage examples for javax.media.j3d TransparencyAttributes NONE
int NONE
To view the source code for javax.media.j3d TransparencyAttributes NONE.
Click Source Link
From source file:GeometryByReferenceTest.java
BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
// Set up attributes to render lines
app = new Appearance();
transp = new TransparencyAttributes();
transp.setTransparency(0.5f);// w w w . jav a 2s . co m
transp.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
transp.setTransparencyMode(TransparencyAttributes.NONE);
app.setTransparencyAttributes(transp);
tetraRegular = createGeometry(1);
tetraStrip = createGeometry(2);
tetraIndexed = createGeometry(3);
tetraIndexedStrip = createGeometry(4);
geoArrays[0] = tetraRegular;
geoArrays[1] = tetraStrip;
geoArrays[2] = tetraIndexed;
geoArrays[3] = tetraIndexedStrip;
shape = new Shape3D(tetraRegular, app);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
Transform3D t = new Transform3D();
// move the object upwards
t.set(new Vector3f(0.0f, 0.3f, 0.0f));
// rotate the shape
Transform3D temp = new Transform3D();
temp.rotX(Math.PI / 4.0d);
t.mul(temp);
temp.rotY(Math.PI / 4.0d);
t.mul(temp);
// Shrink the object
t.setScale(0.6);
TransformGroup trans = new TransformGroup(t);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.addChild(trans);
trans.addChild(shape);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
// Set up the global lights
Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
AmbientLight aLgt = new AmbientLight(alColor);
aLgt.setInfluencingBounds(bounds);
DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
lgt1.setInfluencingBounds(bounds);
objRoot.addChild(aLgt);
objRoot.addChild(lgt1);
// Let Java 3D perform optimizations on this scene graph.
objRoot.compile();
return objRoot;
}
From source file:InterleavedTest.java
BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
// Set up attributes to render lines
app = new Appearance();
app.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE);
transp = new TransparencyAttributes();
transp.setTransparency(0.5f);/*from ww w . ja v a 2s. com*/
transp.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
transp.setTransparencyMode(TransparencyAttributes.NONE);
app.setTransparencyAttributes(transp);
// load textures
TextureAttributes texAttr1 = new TextureAttributes();
texAttr1.setTextureMode(TextureAttributes.DECAL);
TextureAttributes texAttr2 = new TextureAttributes();
texAttr2.setTextureMode(TextureAttributes.MODULATE);
TextureLoader tex = new TextureLoader(texImage1, new String("RGB"), this);
if (tex == null)
return null;
tex1 = tex.getTexture();
tex = new TextureLoader(texImage2, new String("RGB"), this);
if (tex == null)
return null;
tex2 = tex.getTexture();
textureUnitState[0] = new TextureUnitState(tex1, texAttr1, null);
textureUnitState[1] = new TextureUnitState(tex2, texAttr2, null);
tetraRegular = createGeometry(1);
tetraStrip = createGeometry(2);
tetraIndexed = createGeometry(3);
tetraIndexedStrip = createGeometry(4);
geoArrays[0] = tetraRegular;
geoArrays[1] = tetraStrip;
geoArrays[2] = tetraIndexed;
geoArrays[3] = tetraIndexedStrip;
shape = new Shape3D(tetraRegular, app);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
Transform3D t = new Transform3D();
// move the object upwards
t.set(new Vector3f(0.0f, 0.3f, 0.0f));
// rotate the shape
Transform3D temp = new Transform3D();
temp.rotX(Math.PI / 4.0d);
t.mul(temp);
temp.rotY(Math.PI / 4.0d);
t.mul(temp);
// Shrink the object
t.setScale(0.6);
TransformGroup trans = new TransformGroup(t);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.addChild(trans);
trans.addChild(shape);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
// Set up the global lights
Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
AmbientLight aLgt = new AmbientLight(alColor);
aLgt.setInfluencingBounds(bounds);
DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
lgt1.setInfluencingBounds(bounds);
objRoot.addChild(aLgt);
objRoot.addChild(lgt1);
// Let Java 3D perform optimizations on this scene graph.
objRoot.compile();
return objRoot;
}
From source file:GeometryByReferenceNIOBuffer.java
BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
// Set up attributes to render lines
app = new Appearance();
transp = new TransparencyAttributes();
transp.setTransparency(0.5f);// w w w .j a va2s.co m
transp.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
transp.setTransparencyMode(TransparencyAttributes.NONE);
app.setTransparencyAttributes(transp);
//create the direct nio buffer
createJ3DBuffers();
tetraRegular = createGeometry(1);
tetraStrip = createGeometry(2);
tetraIndexed = createGeometry(3);
tetraIndexedStrip = createGeometry(4);
geoArrays[0] = tetraRegular;
geoArrays[1] = tetraStrip;
geoArrays[2] = tetraIndexed;
geoArrays[3] = tetraIndexedStrip;
shape = new Shape3D(tetraRegular, app);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
Transform3D t = new Transform3D();
// move the object upwards
t.set(new Vector3f(0.0f, 0.3f, 0.0f));
// rotate the shape
Transform3D temp = new Transform3D();
temp.rotX(Math.PI / 4.0d);
t.mul(temp);
temp.rotY(Math.PI / 4.0d);
t.mul(temp);
// Shrink the object
t.setScale(0.6);
TransformGroup trans = new TransformGroup(t);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.addChild(trans);
trans.addChild(shape);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
// Set up the global lights
Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
AmbientLight aLgt = new AmbientLight(alColor);
aLgt.setInfluencingBounds(bounds);
DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
lgt1.setInfluencingBounds(bounds);
objRoot.addChild(aLgt);
objRoot.addChild(lgt1);
// Let Java 3D perform optimizations on this scene graph.
objRoot.compile();
return objRoot;
}
From source file:InterleavedNIOBuffer.java
BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
// Set up attributes to render lines
app = new Appearance();
app.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE);
transp = new TransparencyAttributes();
transp.setTransparency(0.5f);// w w w. ja v a 2s . c om
transp.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
transp.setTransparencyMode(TransparencyAttributes.NONE);
app.setTransparencyAttributes(transp);
// load textures
TextureAttributes texAttr1 = new TextureAttributes();
texAttr1.setTextureMode(TextureAttributes.DECAL);
TextureAttributes texAttr2 = new TextureAttributes();
texAttr2.setTextureMode(TextureAttributes.MODULATE);
TextureLoader tex = new TextureLoader(texImage1, new String("RGB"), this);
if (tex == null)
return null;
tex1 = tex.getTexture();
tex = new TextureLoader(texImage2, new String("RGB"), this);
if (tex == null)
return null;
tex2 = tex.getTexture();
textureUnitState[0] = new TextureUnitState(tex1, texAttr1, null);
textureUnitState[1] = new TextureUnitState(tex2, texAttr2, null);
createInterleavedBuffers();
tetraRegular = createGeometry(1);
tetraStrip = createGeometry(2);
tetraIndexed = createGeometry(3);
tetraIndexedStrip = createGeometry(4);
geoArrays[0] = tetraRegular;
geoArrays[1] = tetraStrip;
geoArrays[2] = tetraIndexed;
geoArrays[3] = tetraIndexedStrip;
shape = new Shape3D(tetraRegular, app);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
Transform3D t = new Transform3D();
// move the object upwards
t.set(new Vector3f(0.0f, 0.3f, 0.0f));
// rotate the shape
Transform3D temp = new Transform3D();
temp.rotX(Math.PI / 4.0d);
t.mul(temp);
temp.rotY(Math.PI / 4.0d);
t.mul(temp);
// Shrink the object
t.setScale(0.6);
TransformGroup trans = new TransformGroup(t);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.addChild(trans);
trans.addChild(shape);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
// Set up the global lights
Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
AmbientLight aLgt = new AmbientLight(alColor);
aLgt.setInfluencingBounds(bounds);
DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
lgt1.setInfluencingBounds(bounds);
objRoot.addChild(aLgt);
objRoot.addChild(lgt1);
// Let Java 3D perform optimizations on this scene graph.
objRoot.compile();
return objRoot;
}
From source file:GeometryByReferenceTest.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); GeometryArray geo;//from ww w .j a v a 2 s . c o m boolean setColor = false, setVertex = false; if (target == geomType) { geo = geoArrays[geomType.getSelectedIndex()]; // Set everything to null, and set it later .. geo.setColorRefFloat(null); geo.setColorRef3f(null); geo.setCoordRefFloat(null); geo.setCoordRef3f(null); shape.setGeometry(geoArrays[geomType.getSelectedIndex()]); setColor = true; setVertex = true; } else if (target == transparency) { if (transparency.isSelected()) { transp.setTransparencyMode(TransparencyAttributes.BLENDED); } else { transp.setTransparencyMode(TransparencyAttributes.NONE); } } else if (target == updates) { updateIndex = updates.getSelectedIndex(); if (updateIndex == 1) { System.out.println("Doing coordinate update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } else if (updateIndex == 2) { System.out.println("Doing color update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } } else if (target == vertexType) { geo = ((GeometryArray) shape.getGeometry()); if (vertexIndex == 0) { geo.setCoordRefFloat(null); } else if (vertexIndex == 1) { geo.setCoordRef3f(null); } vertexIndex = vertexType.getSelectedIndex(); setVertex = true; } else if (target == colorType) { geo = (GeometryArray) shape.getGeometry(); if (colorIndex == 0) { geo.setColorRefFloat(null); } else if (colorIndex == 1) { geo.setColorRef3f(null); } colorIndex = colorType.getSelectedIndex(); setColor = true; } if (setVertex) { geo = (GeometryArray) shape.getGeometry(); if (vertexIndex == 0) { if (geo instanceof IndexedGeometryArray) geo.setCoordRefFloat(indexedFloatVerts); else geo.setCoordRefFloat(floatVerts); } else if (vertexIndex == 1) { if (geo instanceof IndexedGeometryArray) geo.setCoordRef3f(indexedP3fVerts); else geo.setCoordRef3f(p3fVerts); } } if (setColor) { geo = (GeometryArray) shape.getGeometry(); if (colorIndex == 0) { if (geo instanceof IndexedGeometryArray) geo.setColorRefFloat(indexedFloatClrs); else geo.setColorRefFloat(floatClrs); } else if (colorIndex == 1) { if (geo instanceof IndexedGeometryArray) geo.setColorRef3f(indexedC3fClrs); else geo.setColorRef3f(c3fClrs); } } }
From source file:GeometryByReferenceNIOBuffer.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); GeometryArray geo;//from w ww .ja va 2 s .c om boolean setColor = false, setVertex = false; if (target == geomType) { geo = geoArrays[geomType.getSelectedIndex()]; // Set everything to null, and set it later .. geo.setColorRefBuffer(null); geo.setCoordRefBuffer(null); shape.setGeometry(geoArrays[geomType.getSelectedIndex()]); setColor = true; setVertex = true; } else if (target == transparency) { if (transparency.isSelected()) { transp.setTransparencyMode(TransparencyAttributes.BLENDED); } else { transp.setTransparencyMode(TransparencyAttributes.NONE); } } else if (target == updates) { updateIndex = updates.getSelectedIndex(); if (updateIndex == 1) { System.out.println("Doing coordinate update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } else if (updateIndex == 2) { System.out.println("Doing color update"); ((GeometryArray) (shape.getGeometry())).updateData(this); } } if (setVertex) { geo = (GeometryArray) shape.getGeometry(); if (geo instanceof IndexedGeometryArray) geo.setCoordRefBuffer(indexedFloatBufferCoord); else geo.setCoordRefBuffer(floatBufferCoord); } if (setColor) { geo = (GeometryArray) shape.getGeometry(); if (geo instanceof IndexedGeometryArray) geo.setColorRefBuffer(indexedFloatBufferColor); else geo.setColorRefBuffer(floatBufferColor); } }
From source file:InterleavedNIOBuffer.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); if (target == geomType) { shape.setGeometry(geoArrays[geomType.getSelectedIndex()]); } else if (target == transparency) { if (transparency.isSelected()) { transp.setTransparencyMode(TransparencyAttributes.BLENDED); } else {// w ww . j ava2 s . c o m transp.setTransparencyMode(TransparencyAttributes.NONE); } } else if (target == textureBox) { if (textureBox.isSelected()) { app.setTextureUnitState(textureUnitState); } else { app.setTextureUnitState(null); } } }
From source file:AppearanceTest.java
public void onNONE() { getTransparencyAttributes().setTransparencyMode(TransparencyAttributes.NONE); }
From source file:AppearanceExplorer.java
TransparencyAttributesEditor(TransparencyAttributes init) {
transpAttr = init;// w ww . ja v a2 s .co m
transparency = transpAttr.getTransparency();
mode = transpAttr.getTransparencyMode();
srcBlendFunction = transpAttr.getSrcBlendFunction();
dstBlendFunction = transpAttr.getDstBlendFunction();
setLayout(new GridLayout(4, 1));
FloatLabelJSlider transparencySlider = new FloatLabelJSlider("Transparency", 0.1f, 0.0f, 1.0f,
transparency);
transparencySlider.setMajorTickSpacing(0.1f);
transparencySlider.setPaintTicks(true);
transparencySlider.addFloatListener(new FloatListener() {
public void floatChanged(FloatEvent e) {
transparency = e.getValue();
transpAttr.setTransparency(transparency);
}
});
add(transparencySlider);
String[] modeNames = { "NONE", "SCREEN_DOOR", "BLENDED", "NICEST", "FASTEST" };
int[] modeValues = { TransparencyAttributes.NONE, TransparencyAttributes.SCREEN_DOOR,
TransparencyAttributes.BLENDED, TransparencyAttributes.NICEST, TransparencyAttributes.FASTEST };
IntChooser modeChooser = new IntChooser("Mode:", modeNames, modeValues, mode);
modeChooser.addIntListener(new IntListener() {
public void intChanged(IntEvent event) {
mode = event.getValue();
transpAttr.setTransparencyMode(mode);
}
});
add(modeChooser);
String[] blendNames = { "BLEND_ZERO", "BLEND_ONE", "BLEND_SRC_ALPHA", "BLEND_ONE_MINUS_SRC_ALPHA" };
int[] blendValues = { TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE,
TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, };
IntChooser srcBlendFunctionChooser = new IntChooser("Src Blend Func:", blendNames, blendValues,
srcBlendFunction);
srcBlendFunctionChooser.addIntListener(new IntListener() {
public void intChanged(IntEvent event) {
srcBlendFunction = event.getValue();
transpAttr.setSrcBlendFunction(srcBlendFunction);
}
});
add(srcBlendFunctionChooser);
IntChooser dstBlendFunctionChooser = new IntChooser("Dst Blend Func:", blendNames, blendValues,
dstBlendFunction);
dstBlendFunctionChooser.addIntListener(new IntListener() {
public void intChanged(IntEvent event) {
dstBlendFunction = event.getValue();
transpAttr.setDstBlendFunction(dstBlendFunction);
}
});
add(dstBlendFunctionChooser);
}