private Material getMtrl(int x, int y, int z) { if (((x == 0 || x == side - 1) && (y == 0 || y == side - 1)) || ((x == 0 || x == side - 1) && (z == 0 || z == side - 1)) || ((z == 0 || z == side - 1) && (y == 0 || y == side - 1))) { return borderMtrl; } if (x == 0) { return leftMtrl; } else if (x == side - 1) { return rightMtrl; } else if (y == 0) { return topMtrl; } else if (y == side - 1) { return bottomMtrl; } else if (z == 0) { return frontMtrl; } else if (z == side - 1) { return backMtrl; } return null; }
/** * Set all the MeshViews in the group to the given material, as well as the * children of any child groups. * * @param group * The group whose children will have their material set. * @param material * The material to be set to the group's children. */ private void setMaterial(Group group, Material material) { // Handle each of the group's children for (Node node : group.getChildren()) { // If the node is a mesh view, set its material if (node.getClass() == MeshView.class) { ((MeshView) node).setMaterial(material); } // Otherwise, recursively handle the child group else if (node.getClass() == Group.class) { setMaterial((Group) node, material); } } }
public List<MeshView> getAsMeshViews() { List<MeshView> result = new ArrayList<>(meshes.size()); for (int i = 0; i < meshes.size(); i++) { Mesh mesh = meshes.get(i); Material mat = materials.get(i); MeshView view = new MeshView(mesh); view.setMaterial(mat); view.setCullFace(CullFace.NONE); result.add(view); } return result; }
protected void bindMaterial(Group group) { Material material = createMaterial(); for (Node node : group.getChildren()) if (node instanceof Shape3D) ((Shape3D) node).setMaterial(material); else if (node instanceof SkinMultipleCubes) ((SkinMultipleCubes) node).updateSkin(skin); else if (node instanceof Group) bindMaterial((Group) node); }
public Material getMaterialWithColor(Color color, String image){ PhongMaterial mat = new PhongMaterial(color); if(image!=null && !image.isEmpty()){ Image img = new Image(image); mat.setDiffuseMap(img); NormalMap normal = new NormalMap(img); // normal.setIntensity(10); // normal.setIntensityScale(2); mat.setBumpMap(normal); } mat.setSpecularPower(32); mat.setSpecularColor(Color.WHITE); return mat; }
public void addSphere(double x, double y, double z, Material material) { Sphere sphere = new Sphere(RADIUS); sphere.setTranslateX(x * SCALE_FACTOR); sphere.setTranslateY(y * SCALE_FACTOR); sphere.setTranslateZ(z * SCALE_FACTOR); sphere.setMaterial(material); getChildren().add(sphere); }
public Material getMaterialWithPattern(){ PhongMaterial mat = new PhongMaterial(); mat.setDiffuseMap(getPatternImage()); mat.setSpecularPower(32); mat.setDiffuseColor(Color.WHITE); mat.setSpecularColor(Color.WHITE); return mat; }
public Material getMaterialWithPalette(){ PhongMaterial mat = new PhongMaterial(); mat.setDiffuseMap(getPaletteImage()); mat.setSpecularPower(20); mat.setDiffuseColor(Color.WHITE); mat.setSpecularColor(Color.WHITE); return mat; }
private Sphere createSphere(Physical ball) { Sphere sphere = new Sphere(this.radius); ViewPoint location = ViewPoint.of(ball.getLocation()); sphere.setTranslateX(location.x); sphere.setTranslateY(location.y); sphere.setTranslateZ(location.z); Material material = new PhongMaterial(this.color); sphere.setMaterial(material); return sphere; }
MeshContainer(Vector3d min, Vector3d max, List<Mesh> meshes, List<Material> materials) { this.meshes = meshes; this.materials = materials; this.bounds = new Bounds(min, max); this.width = bounds.getBounds().x; this.height = bounds.getBounds().y; this.depth = bounds.getBounds().z; if (materials.size() != meshes.size()) { throw new IllegalArgumentException("Mesh list and Material list must not differ in size!"); } }
protected Material createMaterial(Color color) { return new PhongMaterial(color); }
protected Material createMaterial() { PhongMaterial material = new PhongMaterial(); material.setDiffuseMap(skin); return material; }
public Map<String, Material> getMaterials() { return Collections.unmodifiableMap(materials); }
public Material getMaterial() { return materials.values().iterator().next(); }
public Material getMaterial(String key) { return materials.get(key); }
public final void setMaterial(Material value) { mesh.setMaterial(value); }
public void setMaterialWithPattern(Material mat, CarbonPatterns cp){ Image img = getPatternImage(cp); clearMaterialAndSetDiffMap(material, img); }
public static Material fromColour( Color c) { final PhongMaterial mat = new PhongMaterial(); mat.setDiffuseColor(c); // was darker mat.setSpecularColor(c.brighter()); return mat; }
public static Material fromImage( String fileName ) { Image img = new Image("file:"+fileName); PhongMaterial mat = new PhongMaterial(); mat.setDiffuseMap(img); return mat; }
private Material getMaterial(Color color) { return materials.computeIfAbsent(color, PhongMaterial::new); }
public Material getMaterialWithColor(Color color){ PhongMaterial mat = new PhongMaterial(color); mat.setSpecularPower(32); mat.setSpecularColor(Color.WHITE); return mat; }
public Material getMaterialWithImage(String image){ PhongMaterial mat = new PhongMaterial(); mat.setDiffuseMap(new Image(image)); return mat; }
/** * @return the materials */ public List<Material> getMaterials() { return materials; }
public Collection<Material> getMaterialCollection() { return materials.values(); }