In your module createAppearance add :
TextureLoader txtL = new TextureLoader("image-name",this); ap.setTexture(txtL.getTexture); This should work. -- Romil D. ----- Original Message ----- From: Wendel Silva <[EMAIL PROTECTED]> Date: Thursday, June 10, 2004 1:34 pm Subject: [JAVA3D] Texture in a Shape3d > Hi, > > How can i put some texture in a shape3d? > > []'s > > Wendel B Silva > > > > > > > Below is my code to create a single plane > > import javax.media.j3d.*; > import javax.vecmath.*; > > public class Shape extends Shape3D > > { > > public Shape(double height, double width) > > { > > this.setGeometry(createGeometry(height, width)); > > this.setAppearance(createAppearance()); > > this.setCapability(Shape3D.ALLOW_APPEARANCE_READ); > > this.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); > > } > > > private Geometry createGeometry(double height, double width) > > { > > int v = 8; > > QuadArray qa = new QuadArray(v, QuadArray.COORDINATES | > QuadArray.NORMALS | > QuadArray.TEXTURE_COORDINATE_2); > > Point3d[] coords = new Point3d[v]; > > Vector3f[] normal = new Vector3f[v]; > > TexCoord2f[] textcor = new TexCoord2f[v]; > > double x = 0; > > double y = -10; > > double z = 0; > > int i = 0; > > > coords[i++] = new Point3d(x+width, y, z); > > coords[i++] = new Point3d(x, y, z); > > coords[i++] = new Point3d(x, y+height, z); > > coords[i++] = new Point3d(x+width, y+height, z); > > > coords[i++] = new Point3d(x+width, y+height, z); > > coords[i++] = new Point3d(x, y+height, z); > > coords[i++] = new Point3d(x, y, z); > > coords[i++] = new Point3d(x+width, y, z); > > > qa.setCoordinates(0, coords); > > > return qa; > > } > > > private Appearance createAppearance() > > { > > Appearance ap = new Appearance(); > > ap.setColoringAttributes(createColoringAttributes()); > > ap.setPolygonAttributes(createPolygonAttributes()); > > return ap; > > } > > > private ColoringAttributes createColoringAttributes() > > { > > ColoringAttributes ca = new ColoringAttributes(); > > ca.setColor(10f, 200f, 10f); > > ca.setShadeModel(ColoringAttributes.SHADE_FLAT); > > return ca; > > } > > > private PolygonAttributes createPolygonAttributes() > > { > > PolygonAttributes polyAttr = new PolygonAttributes(); > > polyAttr.setPolygonMode(PolygonAttributes.POLYGON_FILL); > > return polyAttr; > > } > > } > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in > the body > of the message "signoff JAVA3D-INTEREST". For general help, send > email to > [EMAIL PROTECTED] and include in the body of the message "help". > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".