hi
If you create you cylinder with flag GENERATE_TEXTURE_COORDS, there is no need
to create texture coords with TexCoordGeneration, unless you need some especial
features as sphere mapping, reflection mapping, 3D or 4D texture coords, etc

Alessandro Borges

--- Juan Carlos Bermudez <[EMAIL PROTECTED]> escreveu: > Hello
everyone,
>
>   I am having problems trying to set the appearance of the top side of a
> cylinder. I use a picture to indicate the texture I want to apply to my
> cylinder, but when I do a setAppearance on the top side of the cylinder--
> setAppearance.(cyl.TOP, theApp) or cyl.getShape(Cylinder.TOP).setAppearance
> (theApp)-- all I see are lines but no texture(the texture render fine on
> the round surface).
>
>  I use a TexCoordGeneration plus a TextureLoader to obtaint the texture
> and the corresponding coordinates. But nothing seems to work. Can some one
> give me a hint on how to achive this? Please? What am I omitting?
>
>   Below I post the code I am using. Thanks all 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;
>
>
> 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");
>
>     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();
>
>     TexCoordGeneration texCoordGen = new
>                     TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,
>
> TexCoordGeneration.TEXTURE_COORDINATE_2);
>
>  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.setBoundaryModeS(Texture.WRAP);
>     wallsTexture.setBoundaryModeT(Texture.WRAP);
>
>     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.setTexCoordGeneration(texCoordGen);
>  theApp.setTexture(wallsTexture);
>
>
>     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);
>
>     Cylinder cyl = new Cylinder(1.0f, 0.1f, Cylinder.GENERATE_NORMALS,
>                                 64, 1, theApp);
>
>    //cyl.getShape(Cylinder.TOP).setAppearance(theApp);
>    cyl.setAppearance(cyl.TOP, theApp);
>
>     trGrpMain.addChild(cyl);
>
>     MouseZoom mZoom = new MouseZoom(trGrpMain);
>     MouseRotate mRot = new MouseRotate(trGrpMain);
>     MouseTranslate mTransl = new MouseTranslate(trGrpMain);
>
>     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);
>     myVWorld.getLocale().addBranchGraph(brGrp);
>
>
>     Transform3D tr3D = new Transform3D();
>     tr3D.setTranslation(new Vector3f(0.0f, 0.0f, 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".
>

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

===========================================================================
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".

Reply via email to