Hi everyone, hi Alessandro, problem is, I want that the picture defining the texture will tile enough times, as to create the impression the texture is a good plain piece of turf, or a street formed of little pebbles packed together.
After I have set the capability for auto-generating texturecoords, and have unset the setTexCoordGeneration for the appearance, the image displays without lines, but I need the tiling. I have set the setBoundaryModeS(Texture.WRAP) and setBoundaryModeT(Texture.WRAP) methods of the texture objet I apply to the appearance, but the image doesn't tile. Can someone tell me, what am I missing? I post the code with the modification Alessandro adviced me to do, plus some I added, keyNavigation + clipingDistances. Thanks in advance, JC ======================================================================== CODE starts here ======================================================================== import java.awt.*; import java.awt.event.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.SimpleUniverse; import com.sun.j3d.utils.behaviors.mouse.*; import com.sun.j3d.utils.image.TextureLoader; import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior; import javax.media.j3d.View; public class myCylinder extends Frame implements ActionListener { protected Canvas3D displayCanvas; protected SimpleUniverse myVWorld; protected Button Quit; public myCylinder() { displayCanvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration ()); myVWorld = new SimpleUniverse(displayCanvas); Quit = new Button("Quit"); myVWorld.getViewingPlatform().getViewers()[0].getView(). setBackClipDistance (500.0d); myVWorld.getViewingPlatform().getViewers()[0].getView(). setFrontClipDistance (0.05d); Quit.addActionListener(this); this.setLayout(new BorderLayout()); this.add("Center", displayCanvas); Panel ButtonsPanel = new Panel(); ButtonsPanel.setLayout(new GridLayout(1, 3)); ButtonsPanel.add(Quit); this.add("South", ButtonsPanel); Appearance theApp = new Appearance(); TextureLoader textureLoader = new TextureLoader("turf.jpg", null); ImageComponent2D img = textureLoader.getImage(); Texture2D wallsTexture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, img.getWidth(), img.getHeight ()); wallsTexture.setImage(0, img); wallsTexture.setEnable(true); wallsTexture.setMagFilter(Texture.NICEST); wallsTexture.setMinFilter(Texture.NICEST); PolygonAttributes polyAttr = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0.0f); theApp.setPolygonAttributes(polyAttr); theApp.setTexture(wallsTexture); wallsTexture.setBoundaryModeS(Texture.WRAP); wallsTexture.setBoundaryModeT(Texture.WRAP); PointLight sunLight = new PointLight(new Color3f(0.9f, 0.9f, 0.9f), new Point3f(0.0f, 1.0f, 1.0f), new Point3f(1.5f, 0.0f, 0.0f)); BoundingSphere inflZone = new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), 300.0f); sunLight.setInfluencingBounds(inflZone); TransformGroup trGrpMain = new TransformGroup(); trGrpMain.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); trGrpMain.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); trGrpMain.addChild(sunLight); float cylRadio = 50.0f; Cylinder cyl = new Cylinder(cylRadio*1.0f, 0.1f, Cylinder.GENERATE_NORMALS| Cylinder.GENERATE_TEXTURE_COORDS, 64, 1, theApp); cyl.getShape(Cylinder.TOP).setAppearance(theApp); //cyl.setAppearance(cyl.TOP, theApp); Transform3D tr3DTransl = new Transform3D(); tr3DTransl.set(new Vector3d(0.0f, -0.15f, 0.0f)); TransformGroup shiftTerrainTrGrp = new TransformGroup(tr3DTransl); shiftTerrainTrGrp.addChild(cyl); trGrpMain.addChild(shiftTerrainTrGrp); MouseZoom mZoom = new MouseZoom(trGrpMain); MouseRotate mRot = new MouseRotate(trGrpMain); MouseTranslate mTransl = new MouseTranslate(trGrpMain); KeyNavigatorBehavior keynav = new KeyNavigatorBehavior(myVWorld.getViewingPlatform(). getViewPlatformTransform()); keynav.setSchedulingBounds(inflZone); mZoom.setSchedulingBounds(inflZone); mRot.setSchedulingBounds(inflZone); mTransl.setSchedulingBounds(inflZone); BranchGroup brGrp = new BranchGroup(); brGrp.addChild(trGrpMain); brGrp.addChild(mZoom); brGrp.addChild(mRot); brGrp.addChild(mTransl); brGrp.addChild(keynav); myVWorld.getLocale().addBranchGraph(brGrp); Transform3D tr3D = new Transform3D(); tr3D.setTranslation(new Vector3f(0.0f, 0.05f, 2.0f)); myVWorld.getViewingPlatform(). getViewPlatformTransform().setTransform(tr3D); this.setSize(400, 600); this.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand() == "Quit") { this.dispose(); System.exit(0); } } public static void main(String[] _args) { myCylinder cylind = new myCylinder(); } } ======================================================================== CODE ends here ======================================================================== =========================================================================== 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".