/** * Method to access appearance of axes in 3D * * @param initValue false if appearance has to be changed according to user value */ public static void setAxisAppearanceValues(Object initValue) { int[] colors = J3DUtils.get3DColorAxes(); for (int i = 0; i < axisApps.length; i++) { Color userColor = new Color(colors[i]); if (axisApps[i] == null) { axisApps[i] = new J3DAppearance(TransparencyAttributes.NONE, 0.5f, userColor); // Turn off face culling so we can see the back side of the labels // (since we're not using font extrusion) PolygonAttributes polygonAttributes = new PolygonAttributes(); polygonAttributes.setCullFace(PolygonAttributes.CULL_NONE); // Make the axis lines 2 pixels wide LineAttributes lineAttributes = new LineAttributes(); lineAttributes.setLineWidth(3.0f); ColoringAttributes colorAttrib = new ColoringAttributes(); colorAttrib.setColor(new Color3f(userColor)); colorAttrib.setCapability(ColoringAttributes.ALLOW_COLOR_READ); colorAttrib.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE); axisApps[i].setColoringAttributes(colorAttrib); axisApps[i].setPolygonAttributes(polygonAttributes); axisApps[i].setLineAttributes(lineAttributes); axisApps[i].setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ); axisApps[i].setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); RenderingAttributes ra = new RenderingAttributes(); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_READ); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE); ra.setVisible(J3DUtils.is3DAxesOn()); axisApps[i].setRenderingAttributes(ra); } else if (initValue == null) // redoing color only when it was changed in GUI axisApps[i].set3DColor(null, userColor); } }
public void processStimulus(Enumeration criteria) { posVector.set( (float) targetHistogram.neutronNumber - ((float) targetMaxNeutron / 2.0f), (float) targetHistogram.abundance[step] - targetHistogram.normalizationFactor, (float) -targetHistogram.protonNumber + ((float) targetMaxProton / 2.0f)); ca = targetHistogram.fillingAppearance.getColoringAttributes(); targetColorRamp.getColor( targetHistogram.abundance[step] - targetHistogram.normalizationFactor, histColor); ca.setColor(histColor); step++; if (step >= targetHistogram.abundance.length) { step = 0; } targetT3D.set(posVector); targetTG.setTransform(targetT3D); this.wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_CLICKED)); }
/** * Method to access appearance for cells in 3D * * @param initValue no null if appearance has to be changed according to user value. Using this * mechanism to avoid the creation of new Boolean() just for the checking */ public static void setCellAppearanceValues(Object initValue) { Color3f userColor = new Color3f(new Color(User.getColor(User.ColorPrefType.INSTANCE_3D))); if (cellApp == null) { cellApp = new J3DAppearance(TransparencyAttributes.SCREEN_DOOR, 0, null); RenderingAttributes ra = new RenderingAttributes(); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_READ); ra.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE); ra.setVisible(J3DUtils.is3DCellBndOn()); cellApp.setRenderingAttributes(ra); // Set up the polygon attributes PolygonAttributes pa = new PolygonAttributes(); pa.setCullFace(PolygonAttributes.CULL_NONE); pa.setPolygonMode(PolygonAttributes.POLYGON_LINE); cellApp.setPolygonAttributes(pa); // TextureAttributes texAttr = new TextureAttributes(); // texAttr.setTextureMode(TextureAttributes.MODULATE); // //texAttr.setTextureColorTable(pattern); // cellApp.setTextureAttributes(texAttr); LineAttributes lineAttr = new LineAttributes(); lineAttr.setLineAntialiasingEnable(true); cellApp.setLineAttributes(lineAttr); // ** Data for cells ColoringAttributes ca = new ColoringAttributes(); ca.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE); ca.setCapability(ColoringAttributes.ALLOW_COLOR_READ); ca.setColor(userColor); cellApp.setColoringAttributes(ca); cellApp.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ); cellApp.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); } else if (initValue == null) // redoing color only when it was changed in GUI { ColoringAttributes ca = cellApp.getColoringAttributes(); Color3f curColor = new Color3f(); ca.getColor(curColor); if (!userColor.equals(curColor)) ca.setColor(userColor); } }
/** * Computes the new transform for this interpolator for a given alpha value. * * @param alphaValue alpha value between 0.0 and 1.0 * @param transform object that receives the computed transform for the specified alpha value * @since Java 3D 1.3 */ public void computeTransform(float alphaValue, Transform3D transform) { // compute the current value of u from alpha and the // determine lower and upper knot points computePathInterpolation(alphaValue); // Determine the segment within which we will be interpolating currentSegmentIndex = this.lowerKnot - 1; // if we are at the start of the curve if (currentSegmentIndex == 0 && currentU == 0f) { iHeading = keyFrames[1].heading; iPitch = keyFrames[1].pitch; iBank = keyFrames[1].bank; iPos.set(keyFrames[1].position); iScale.set(keyFrames[1].scale); // if we are at the end of the curve } else if (currentSegmentIndex == (numSegments - 1) && currentU == 1.0) { iHeading = keyFrames[upperKnot].heading; iPitch = keyFrames[upperKnot].pitch; iBank = keyFrames[upperKnot].bank; iPos.set(keyFrames[upperKnot].position); iScale.set(keyFrames[upperKnot].scale); // if we are somewhere in between the curve } else { // Get a reference to the current spline segment i.e. the // one bounded by lowerKnot and upperKnot currentSegment = cubicSplineCurve.getSegment(currentSegmentIndex); // interpolate quaternions iHeading = currentSegment.getInterpolatedHeading(currentU); iPitch = currentSegment.getInterpolatedPitch(currentU); iBank = currentSegment.getInterpolatedBank(currentU); // interpolate position currentSegment.getInterpolatedPositionVector(currentU, iPos); // interpolate position currentSegment.getInterpolatedScale(currentU, iScale); // System.out.println("Pos :" + iPos); } // Modification by ReubenDB if (colorRampingInterpolate == true) { float[] curPos = new float[3]; iPos.get(curPos); myColorRamp.getColor(curPos[1], histColor); // System.out.println("SETING COLOR:" + histColor + " CurPos: " + curPos[0] + ", " + curPos[1] // + ", " + curPos[2]); objectCA.setColor(histColor); // System.out.println("CurrentAlpha = " + myAlpha.value()); } if (timeDisplayInterpolate == true) { myTimeDisplay.updateDisplayFromAlpha(myAlpha.value()); // System.out.println(myAlpha.value()); } // Generate a transformation matrix in tMat using interpolated // heading, pitch and bank pitchMat.setIdentity(); pitchMat.rotX(-iPitch); bankMat.setIdentity(); bankMat.rotZ(iBank); tMat.setIdentity(); tMat.rotY(-iHeading); tMat.mul(pitchMat); tMat.mul(bankMat); // TODO: Vijay - Handle Non-Uniform scale // Currently this interpolator does not handle non uniform scale // We cheat by just taking the x scale component // Scale the transformation matrix sMat.set((double) iScale.x); tMat.mul(sMat); // Set the translation components. tMat.m03 = iPos.x; tMat.m13 = iPos.y; tMat.m23 = iPos.z; rotation.set(tMat); // construct a Transform3D from: axis * rotation * axisInverse transform.mul(axis, rotation); transform.mul(transform, axisInverse); }