for(int i=0;i<24;i++)normals[i]=new Vector3f(); Point3f [] pts=new Point3f[24]; for(int i=0;i<24;i++)pts[i]=new Point3f(); Color3f [] clrs=new Color3f[24]; for(int i=0;i<24;i++)clrs[i]=new Color3f(0.5f,0.5f,0.5f); pa.setCullFace(PolygonAttributes.CULL_NONE); Material mat=new Material(); mat.setEmissiveColor(new Color3f(0.5f,0.5f,0.5f)); mat.setAmbientColor(new Color3f(0.1f,0.1f,0.1f)); mat.setDiffuseColor(new Color3f(0.2f,0.3f,0.4f)); mat.setSpecularColor(new Color3f(0.6f,0.3f,0.2f)); mat.setLightingEnable(true); RenderingAttributes ra=new RenderingAttributes(); ColoringAttributes ca=new ColoringAttributes(); ca.setShadeModel(ColoringAttributes.SHADE_GOURAUD); ca.setColor(new Color3f(0.2f,0.5f,0.9f)); app.setColoringAttributes(ca); app.setRenderingAttributes(ra); light1.setColor(new Color3f(1f,1f,1f)); light1.setDirection(new Vector3f(0,1,0)); objRotate.addChild(light1); DirectionalLight light2=new DirectionalLight(); light2.setInfluencingBounds(new BoundingSphere(new Point3d(5.0,0,0),10.0)); light2.setColor(new Color3f(0.5f,1f,0.5f)); light2.setDirection(new Vector3f(0,-1,0)); objRotate.addChild(light2);
double angle = 0; for (int i=0; i<parallels; i++) { plane.add(new Point3f((float)Math.cos(angle), (float)Math.sin(angle), 0)); angle += inc_rads; final Vector3f vplane = new Vector3f(0, 0, 1); final Transform3D t = new Transform3D(); final AxisAngle4f aa = new AxisAngle4f(); final Color3f cf = new Color3f(this.color); final HashMap<Color,Color3f> cached_colors = new HashMap<Color,Color3f>(); cached_colors.put(this.color, cf); final Vector3f vpc = new Vector3f(x - parx, y - pary, z - parz); final Vector3f cross = new Vector3f(); cross.cross(vpc, vplane); cross.normalize(); // not needed? c = cached_colors.get(nd.color); if (null == c) { c = new Color3f(nd.color); cached_colors.put(nd.color, c);
public BranchGroup getScene() { BranchGroup group = new BranchGroup(); ObjectFile object = new ObjectFile(); Scene scene = null; try { scene = object.load("/Users/John/ArtOfIllusion/Hourglass.obj"); }catch(Exception e){e.printStackTrace();} group.addChild(scene.getSceneGroup()); Color3f light1Color = new Color3f(1.0f, 1.0f, 1.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); Vector3f light1Direction = new Vector3f(.3f, 0, 0); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); group.addChild(light1); return group; }
/** * The user has created another Volume Color. Make a place for its color and * its volume. Don't allow the use of an existing color. * * @param chosenColor * @return */ public boolean addVolumeColor(Color chosenColor) { volumes.add(new Double(0)); voxelCounts.add(new Integer(0)); Color3f newColor = new Color3f(chosenColor); for (Color3f color : colors) { if (newColor.equals(color)) return false; // Already used } colors.add(new Color3f(chosenColor)); currentColorIndex = volumes.size()-1; return true; }
@Override public void adjustmentValueChanged(final AdjustmentEvent e) { final Content content = univ.getSelected(); if (null == content) { Utils.log("Nothing selected!"); return; } Color3f color = content.getColor(); if (null == color) color = new Color3f(1, 1, 0); // default to yellow final float[] co = new float[3]; color.get(co); co[k] = e.getValue() / 255.0f; content.setColor(new Color3f(co)); typer.setText(Integer.toString(e.getValue())); } });
private void processVertexCopy(VertexCopy vc, int stripFlag) { int r = meshBuffer.getMeshReference(vc.p) ; if ((r == meshBuffer.NOT_FOUND) || (vertexNormals && noMeshNormalSubstitution && (! vc.n.equals(meshBuffer.getNormal(r))))) { addVertex(vc.p, vc.n, vc.c, stripFlag, MESH_PUSH) ; meshBuffer.push(vc.p, vc.c, vc.n) ; } else { if (vertexNormals && !noMeshNormalSubstitution && (! vc.n.equals(meshBuffer.getNormal(r)))) addNormal(vc.n) ; if (vertexColor3 && (! vc.c3.equals(meshBuffer.getColor3(r)))) addColor(vc.c3) ; else if (vertexColor4 && (! vc.c4.equals(meshBuffer.getColor4(r)))) addColor(vc.c4) ; addMeshReference(stripFlag, r) ; } }
boolean equivalent(ColoringAttributesRetained cr) { return ((cr != null) && color.equals(cr.color) && (shadeModel == cr.shadeModel)); }
/** * This method retrieves this interpolator's startColor. * @param color the vector that will receive the interpolator's start color */ public void getStartColor(Color3f color) { color.set(startColor); }
Mtl(final float alpha, final Color3f c) { this.alpha = alpha; final float[] f = new float[3]; c.get(f); this.R = f[0]; this.G = f[1]; this.B = f[2]; name = "mat_" + mat_index; mat_index++; }
BranchGroup lineGroup = new BranchGroup(); Appearance app = new Appearance(); ColoringAttributes ca = new ColoringAttributes(new Color3f(204.0f, 204.0f, 204.0f), ColoringAttributes.SHADE_FLAT); app.setColoringAttributes(ca); for (int i = 0; i < 2; i++) { for (int j = 0; j <2; j++) { plaPts[count] = new Point3f(i/10.0f,j/10.0f,0); colPts[count]=new Color3f(i/3.0f,j/3.0f,(float) ((i+j)/3.0));//my arbitrary color set :) count++;
private static final Color3f col(String s) { s = s.substring(1, s.length() - 1); final String[] tmp = s.split(","); return new Color3f(Float.parseFloat(tmp[0]), Float.parseFloat(tmp[1]), Float.parseFloat(tmp[2])); }
Color3f[] colors = new Color3f[] { new Color3f(0, 0, 0), new Color3f(1, 0, 0), new Color3f(0, 0, 1), addLight(group, new Color3f(1f, 1f, 0f), new Vector3f(4.0f, +7.0f, -12.0f)); addLight(group, new Color3f(1f, 1f, 1f)); new Color3f(1, 0, 1),// new Color3f(0, 1, 0),// new Color3f(0, 0, 1),// new Color3f(1, 1, 0),// new Color3f(1, 1, 1),// }; ita.setColors(0, colors);
void resetColorAtGroup(Group startGroup, Color3f edgeColor) { Color3f currentColor = new Color3f(); Color3f resetColor = new Color3f(EDGE_COLOR); Enumeration children = startGroup.getAllChildren(); while (children.hasMoreElements()) { ColoringAttributes ca = appearance.getColoringAttributes(); ca.getColor(currentColor); if (!currentColor.equals(edgeColor)) { continue;
@Override public void contentSelected(final Content arg0) { if (null == arg0) { return; } Color3f color = arg0.getColor(); if (null == color) color = new Color3f(1, 1, 0); // default to yellow final float[] co = new float[3]; color.get(co); for (int i=0; i<3; ++i) { // Disallow the slider from firing an event when its value is adjusted sliders[i].setValueIsAdjusting(true); final int val = (int)(co[i] * 255); typers[i].setText(Integer.toString(val)); sliders[i].setValue(val); } // After all are set, re-enable, which triggers events (the color will be set three times...) for (int i=0; i<3; ++i) { sliders[i].setValueIsAdjusting(false); } // Alpha slider: alphaSlider.setValueIsAdjusting(true); final int alpha = (int)((1 - arg0.getTransparency()) * 255); alphaTyper.setText(Integer.toString(alpha)); alphaSlider.setValue(alpha); alphaSlider.setValueIsAdjusting(false); }
private void processVertexCopy(VertexCopy vc, int stripFlag) { int r = meshBuffer.getMeshReference(vc.p) ; if ((r == meshBuffer.NOT_FOUND) || (vertexNormals && noMeshNormalSubstitution && (! vc.n.equals(meshBuffer.getNormal(r))))) { addVertex(vc.p, vc.n, vc.c, stripFlag, MESH_PUSH) ; meshBuffer.push(vc.p, vc.c, vc.n) ; } else { if (vertexNormals && !noMeshNormalSubstitution && (! vc.n.equals(meshBuffer.getNormal(r)))) addNormal(vc.n) ; if (vertexColor3 && (! vc.c3.equals(meshBuffer.getColor3(r)))) addColor(vc.c3) ; else if (vertexColor4 && (! vc.c4.equals(meshBuffer.getColor4(r)))) addColor(vc.c4) ; addMeshReference(stripFlag, r) ; } }
public static String getColorName(final Color3f col) { for (int i = 1; i < colors.length; i++) { if (colors[i].equals(col)) return colorNames[i]; } return "None"; }
/** * This method sets the endColor for this interpolator. * @param color the new end color */ public void setEndColor(Color3f color) { endColor.set(color); prevAlphaValue = Float.NaN; }