List of usage examples for javax.media.j3d PolygonAttributes POLYGON_POINT
int POLYGON_POINT
To view the source code for javax.media.j3d PolygonAttributes POLYGON_POINT.
Click Source Link
From source file:BehaviorTest.java
public void processStimulus(java.util.Enumeration criteria) { while (criteria.hasMoreElements()) { WakeupCriterion wakeUp = (WakeupCriterion) criteria.nextElement(); if (wakeUp instanceof WakeupOnElapsedTime) { // we are starting the explosion, apply the // appearance changes we require PolygonAttributes polyAttribs = new PolygonAttributes(PolygonAttributes.POLYGON_POINT, PolygonAttributes.CULL_NONE, 0); m_Shape3D.getAppearance().setPolygonAttributes(polyAttribs); PointAttributes pointAttribs = new PointAttributes(3, false); m_Shape3D.getAppearance().setPointAttributes(pointAttribs); m_Shape3D.getAppearance().setTexture(null); m_TransparencyAttributes = new TransparencyAttributes(TransparencyAttributes.NICEST, 0); m_TransparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE); m_Shape3D.getAppearance().setTransparencyAttributes(m_TransparencyAttributes); } else {//from ww w . j a v a 2s. c o m // we are mid explosion, modify the GeometryArray m_nFrameNumber++; m_GeometryArray.getCoordinates(0, m_CoordinateArray); m_TransparencyAttributes.setTransparency(((float) m_nFrameNumber) / ((float) m_nNumFrames)); m_Shape3D.getAppearance().setTransparencyAttributes(m_TransparencyAttributes); for (int n = 0; n < m_CoordinateArray.length; n += 3) { m_Vector.x = m_CoordinateArray[n]; m_Vector.y = m_CoordinateArray[n + 1]; m_Vector.z = m_CoordinateArray[n + 2]; m_Vector.normalize(); m_CoordinateArray[n] += m_Vector.x * Math.random() + Math.random(); m_CoordinateArray[n + 1] += m_Vector.y * Math.random() + Math.random(); m_CoordinateArray[n + 2] += m_Vector.z * Math.random() + Math.random(); } // assign the new coordinates m_GeometryArray.setCoordinates(0, m_CoordinateArray); } } if (m_nFrameNumber < m_nNumFrames) { // assign the next WakeUpCondition, so we are notified again wakeupOn(m_FrameWakeupCondition); } else { // we are at the end of the explosion // reapply the original appearance and GeometryArray // coordinates setEnable(false); m_Shape3D.setAppearance(m_Appearance); m_GeometryArray.setCoordinates(0, m_OriginalCoordinateArray); m_OriginalCoordinateArray = null; m_GeometryArray = null; m_CoordinateArray = null; m_TransparencyAttributes = null; // if we have a listener notify them that we are done if (m_Listener != null) wakeupOn(m_Listener.onExplosionFinished(this, m_Shape3D)); } }
From source file:AppearanceTest.java
public void onPoint() { getPolygonAttributes().setPolygonMode(PolygonAttributes.POLYGON_POINT); }
From source file:AppearanceExplorer.java
PolygonAttributesEditor(PolygonAttributes init) {
super(BoxLayout.Y_AXIS);
polygonAttr = init;//w ww . j a v a 2 s .c o m
polygonMode = polygonAttr.getPolygonMode();
cullFace = polygonAttr.getCullFace();
polygonOffset = polygonAttr.getPolygonOffset();
polygonOffsetFactor = polygonAttr.getPolygonOffsetFactor();
backFaceNormalFlip = polygonAttr.getBackFaceNormalFlip();
String[] modeNames = { "POLYGON_POINT", "POLYGON_LINE", "POLYGON_FILL", };
int[] modeValues = { PolygonAttributes.POLYGON_POINT, PolygonAttributes.POLYGON_LINE,
PolygonAttributes.POLYGON_FILL, };
IntChooser modeChooser = new IntChooser("Mode:", modeNames, modeValues, polygonMode);
modeChooser.addIntListener(new IntListener() {
public void intChanged(IntEvent event) {
polygonMode = event.getValue();
polygonAttr.setPolygonMode(polygonMode);
}
});
add(modeChooser);
String[] cullNames = { "CULL_NONE", "CULL_BACK", "CULL_FRONT", };
int[] cullValues = { PolygonAttributes.CULL_NONE, PolygonAttributes.CULL_BACK,
PolygonAttributes.CULL_FRONT, };
IntChooser cullChooser = new IntChooser("Cull:", cullNames, cullValues, cullFace);
cullChooser.addIntListener(new IntListener() {
public void intChanged(IntEvent event) {
cullFace = event.getValue();
polygonAttr.setCullFace(cullFace);
}
});
add(cullChooser);
FloatLabelJSlider polygonOffsetSlider = new FloatLabelJSlider("Offset", 0.1f, 0.0f, 2.0f, polygonOffset);
polygonOffsetSlider.setMajorTickSpacing(1.0f);
polygonOffsetSlider.setPaintTicks(true);
polygonOffsetSlider.addFloatListener(new FloatListener() {
public void floatChanged(FloatEvent e) {
polygonOffset = e.getValue();
polygonAttr.setPolygonOffset(polygonOffset);
}
});
add(polygonOffsetSlider);
LogFloatLabelJSlider polygonOffsetFactorSlider = new LogFloatLabelJSlider("Offset Factor", 0.1f, 10000.0f,
polygonOffsetFactor);
polygonOffsetFactorSlider.addFloatListener(new FloatListener() {
public void floatChanged(FloatEvent e) {
polygonOffsetFactor = e.getValue();
polygonAttr.setPolygonOffsetFactor(polygonOffsetFactor);
}
});
add(polygonOffsetFactorSlider);
JCheckBox backFaceNormalFlipCheckBox = new JCheckBox("BackFaceNormalFlip", backFaceNormalFlip);
backFaceNormalFlipCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JCheckBox checkbox = (JCheckBox) e.getSource();
backFaceNormalFlip = checkbox.isSelected();
polygonAttr.setBackFaceNormalFlip(backFaceNormalFlip);
}
});
// no ablity to change without replcing polygon attributes
backFaceNormalFlipCheckBox.setEnabled(false);
add(new LeftAlignComponent(backFaceNormalFlipCheckBox));
}
From source file:Demo3D.java
/** * This methode serves to construct the earth. * /*from w w w .j av a2 s .com*/ * @return com.sun.j3d.utils.geometry.Sphere earth - the constructed earth */ public Sphere myEarth() { // Optical properties of the earth. // Ambient-diffuse-reflection coefficient diffAmb = new Color3f(1.0f, 1.0f, 1.0f); // Diffuse-reflection coefficient reflDiff = new Color3f(1.0f, 1.0f, 1.0f); // Specular-reflection coefficient (reflectance function) reflSpec = new Color3f(0.0f, 0.0f, 0.1f); // c = shininess: cos^c in the specular reflection c = 1; // Emitted light emittedLight = new Color3f(0.0f, 0.0f, 0.0f); appearance = new Appearance(); // Create the material and set up the optical properties. material = new Material(diffAmb, emittedLight, reflDiff, reflSpec, c); appearance.setMaterial(material); // Set up the polygon's rendering-mode (with the polygonAttributes) and // the shading-mode (with the coloringAttributes). polygonAttributes = new PolygonAttributes(); coloringAttributes = new ColoringAttributes(); // Points if (renderingType.compareTo("points") == 0) { polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_POINT); } /* Lines*/ else if (renderingType.compareTo("lines") == 0) { polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_LINE); } /* Polygons */ else if (renderingType.compareTo("polygons") == 0) { /* is the default value*/ polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_FILL); coloringAttributes.setShadeModel(ColoringAttributes.SHADE_FLAT); } /* Gouraud */ else if (renderingType.compareTo("gouraud") == 0) { polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_FILL); /* is the default value*/ coloringAttributes.setShadeModel(ColoringAttributes.SHADE_GOURAUD); /* is the default value*/ } else if (renderingType.compareTo("texture") == 0) { polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_FILL); /* is the default value*/ coloringAttributes.setShadeModel(ColoringAttributes.SHADE_GOURAUD); /* is the default value*/ /* Loading of the texture*/ newTextureLoader = new NewTextureLoader("Images/Earth.jpg"); newTextureLoader.setImageObserver(newTextureLoader.getImageObserver()); texture = newTextureLoader.getTexture(); appearance.setTexture(texture); /* Application mode of the texture */ textAttr = new TextureAttributes(); textAttr.setTextureMode(TextureAttributes.REPLACE); /* there still are: BLEND, COMBINE, DECAL, and MODULATE*/ appearance.setTextureAttributes(textAttr); } appearance.setPolygonAttributes(polygonAttributes); appearance.setColoringAttributes(coloringAttributes); /* Construction of the earth with all its features.*/ earth = new Sphere(scale_XYZ, Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS, 10, appearance); return earth; }