List of usage examples for javax.media.j3d Appearance ALLOW_COLORING_ATTRIBUTES_WRITE
int ALLOW_COLORING_ATTRIBUTES_WRITE
To view the source code for javax.media.j3d Appearance ALLOW_COLORING_ATTRIBUTES_WRITE.
Click Source Link
From source file:ExSpotLight.java
public AnnotationArrow(float x, float y, float z, float x2, float y2, float z2) { super(x, y, z, x2, y2, z2); setLineWidth(lineWidth);//w w w. j av a 2s . c om // Compute the length and direction of the line float deltaX = x2 - x; float deltaY = y2 - y; float deltaZ = z2 - z; float theta = -(float) Math.atan2(deltaZ, deltaX); float phi = (float) Math.atan2(deltaY, deltaX); if (deltaX < 0.0f) { phi = (float) Math.PI - phi; } // Compute a matrix to rotate a cone to point in the line's // direction, then place the cone at the line's endpoint. Matrix4f mat = new Matrix4f(); Matrix4f mat2 = new Matrix4f(); mat.setIdentity(); // Move to the endpoint of the line mat2.setIdentity(); mat2.setTranslation(new Vector3f(x2, y2, z2)); mat.mul(mat2); // Spin around Y mat2.setIdentity(); mat2.rotY(theta); mat.mul(mat2); // Tilt up or down around Z mat2.setIdentity(); mat2.rotZ(phi); mat.mul(mat2); // Tilt cone to point right mat2.setIdentity(); mat2.rotZ(-1.571f); mat.mul(mat2); arrowTrans = new TransformGroup(); arrowTrans.setCapability(Group.ALLOW_CHILDREN_WRITE); Transform3D trans = new Transform3D(mat); arrowTrans.setTransform(trans); // Create an appearance arrowAppearance = new Appearance(); arrowAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); getLineColor(arrowColor); coloringAttributes = new ColoringAttributes(); coloringAttributes.setColor(arrowColor); coloringAttributes.setShadeModel(ColoringAttributes.SHADE_FLAT); arrowAppearance.setColoringAttributes(coloringAttributes); // Build a cone for the arrow head arrowHead = new Cone(arrowRadius, // base radius arrowLength, // height 0, // don't generate normals radialDivisions, // divisions radially sideDivisions, // divisions vertically arrowAppearance); // appearance arrowTrans.addChild(arrowHead); addChild(arrowTrans); }
From source file:ExSpotLight.java
public void setAppearance(Appearance app) { super.setAppearance(app); arrowAppearance = app;/*from w w w.j a v a2s.c om*/ arrowAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); arrowAppearance.setColoringAttributes(coloringAttributes); arrowHead.setAppearance(arrowAppearance); }
From source file:ExSpotLight.java
public AnnotationLine(float x, float y, float z, float x2, float y2, float z2) { float[] coord = new float[3]; float[] texcoord = new float[2]; // Build a shape shape = new Shape3D(); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // Create geometry for a 2-vertex straight line line = new LineArray(2, GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2); line.setCapability(GeometryArray.ALLOW_COLOR_WRITE); // Starting point coord[0] = x;//ww w . j av a 2 s . c o m coord[1] = y; coord[2] = z; texcoord[0] = 0.0f; texcoord[1] = 0.0f; line.setCoordinate(0, coord); line.setTextureCoordinate(0, texcoord); // Ending point coord[0] = x2; coord[1] = y2; coord[2] = z2; texcoord[0] = 1.0f; texcoord[1] = 0.0f; line.setCoordinate(1, coord); line.setTextureCoordinate(1, texcoord); shape.setGeometry(line); // Create an appearance mainAppearance = new Appearance(); mainAppearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE); mainAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); lineAttributes = new LineAttributes(); lineAttributes.setLineWidth(lineWidth); mainAppearance.setLineAttributes(lineAttributes); coloringAttributes = new ColoringAttributes(); coloringAttributes.setColor(lineColor); coloringAttributes.setShadeModel(ColoringAttributes.SHADE_FLAT); mainAppearance.setColoringAttributes(coloringAttributes); addChild(shape); }
From source file:ExSpotLight.java
public void setAppearance(Appearance app) { mainAppearance = app;//from w w w . j av a 2 s. c o m mainAppearance.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE); mainAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); mainAppearance.setLineAttributes(lineAttributes); mainAppearance.setColoringAttributes(coloringAttributes); shape.setAppearance(mainAppearance); }
From source file:AppearanceTest.java
protected void setAppearanceCapability() { m_Appearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); }