import artofillusion.*; import java.io.*; public class Stripes1 extends Texture3D { RGBColor color1, color2; float width; public Stripes1() { color1 = new RGBColor(1.0f, 0.0f, 0.0f); color2 = new RGBColor(1.0f, 1.0f, 1.0f); width = 0.5f; } public static String getTypeName() { return "Stripes 1"; } public void getAverageSpec(TextureSpec spec) { float w = 1.0f-width; spec.diffuse.setRGB(width*color1.getRed() + w*color2.getRed(), width*color1.getGreen() + w*color2.getGreen(), width*color1.getBlue() + w*color2.getBlue()); spec.specular.setRGB(0.0f, 0.0f, 0.0f); spec.transparent.setRGB(0.0f, 0.0f, 0.0f); spec.emissive.setRGB(0.0f, 0.0f, 0.0f); spec.bumpGrad.set(0.0, 0.0, 0.0); spec.roughness = spec.cloudiness = 0.0; } public void getTextureSpec(TextureSpec spec, double x, double y, double z, double xsize, double ysize, double zsize, double t, float param[]) { if (x-Math.floor(x) < width) spec.diffuse.copy(color1); else spec.diffuse.copy(color2); spec.specular.setRGB(0.0f, 0.0f, 0.0f); spec.transparent.setRGB(0.0f, 0.0f, 0.0f); spec.emissive.setRGB(0.0f, 0.0f, 0.0f); spec.bumpGrad.set(0.0, 0.0, 0.0); spec.roughness = spec.cloudiness = 0.0; } public void getTransparency(RGBColor trans, double x, double y, double z, double xsize, double ysize, double zsize, double t, float param[]) { trans.setRGB(0.0f, 0.0f, 0.0f); } public Texture duplicate() { Stripes1 s = new Stripes1(); return s; } public void edit(java.awt.Frame fr, Scene sc) { } public Stripes1(DataInputStream in, Scene theScene) throws IOException, InvalidObjectException { setName(in.readUTF()); color1 = new RGBColor(in); color2 = new RGBColor(in); width = in.readFloat(); } public void writeToFile(DataOutputStream out, Scene theScene) throws IOException { out.writeUTF(getName()); color1.writeToFile(out); color2.writeToFile(out); out.writeFloat(width); } }