Adding a texture to a box..

This was working at one point, but i dont know what is wrong
URL r = null;
          try {
               r = new URL("file:ground.png");
          } catch (MalformedURLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          Texture tex = new TextureLoader(r, "LUMINANCE", this).getTexture();
          app.setTexture(tex);
          TextureAttributes texAttr = new TextureAttributes();
          texAttr.setTextureMode(TextureAttributes.MODULATE);
          app.setTextureAttributes(texAttr);I keep getting a nullPointerException.. and it says it cant find the file when it is right there next to the .class. Help?
and app was declared static so it isnt there next to the contents.
Thanks.
Edited by: newber on Jul 8, 2008 2:01 PM

Hi, I'm new to Java 3D and I'm not sure what the problem is, but check the file name and make sure it's right. maybe .png isn't supported. Or maybe you should say URL r = new URL(); and then re-instanitate it in the try - catch block.

Similar Messages

  • Texture in a box - problem(wrong colours)

    hello guys I want to create a box with a texture of chess board on top of it, but the problem is that it loads just a dark blue colour surface instead of blue and white squares surface,feel free to check what I mean, here is what the program shows
    http://img97.imageshack.us/i/checkes.png/
    and here the original texture I want to put in the box
    http://img266.imageshack.us/i/arizonae.jpg/
    here also is my code
    import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior;
    import javax.media.j3d.Transform3D;
    import javax.swing.JFrame;
    import java.awt.*;
    import javax.swing.*;
    import javax.media.j3d.Canvas3D;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import javax.media.j3d.BranchGroup;
    import com.sun.j3d.utils.geometry.Box;
    import com.sun.j3d.utils.image.TextureLoader;
    import javax.vecmath.*;
    import javax.media.j3d.DirectionalLight;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.ImageComponent2D;
    import javax.media.j3d.Material;
    import javax.media.j3d.Texture;
    import javax.media.j3d.Texture2D;
    import javax.media.j3d.TransformGroup;
    import com.sun.j3d.utils.behaviors.mouse.*;
    public class vrlm extends JFrame {
    * The SimpleUniverse object
    protected SimpleUniverse simpleU;
    * The root BranchGroup Object.
    protected BranchGroup rootBranchGroup;
    * Constructor that consturcts the window with the given name.
    * @param name
    * The name of the window, in String format
    public vrlm(String name) {
    // The next line will construct the window and name it
    // with the given name
    super(name);
    // Perform the initial setup, just once
    initial_setup();
    * Perform the essential setups for the Java3D
    protected void initial_setup() {
    // A JFrame is a Container -- something that can hold
    // other things, e.g a button, a textfield, etc..
    // however, for a container to hold something, you need
    // to specify the layout of the storage. For our
    // example, we would like to use a BorderLayout.
    // The next line does just this:
    getContentPane().setLayout(new BorderLayout());
    // The next step is to setup graphics configuration
    // for Java3D. Since different machines/OS have differnt
    // configuration for displaying stuff, therefore, for
    // java3D to work, it is important to obtain the correct
    // graphics configuration first.
    GraphicsConfiguration config = SimpleUniverse
    .getPreferredConfiguration();
    // construct the canvas.
    Canvas3D canvas3D = new Canvas3D(config);
    // And we need to add the "canvas to the centre of our
    // window..
    getContentPane().add("Center", canvas3D);
    // Creates the universe
    simpleU = new SimpleUniverse(canvas3D);
    // First create the BranchGroup object
    rootBranchGroup = new BranchGroup();
    * Adds a light source to the universe
    * @param direction
    * The inverse direction of the light
    * @param color
    * The color of the light
    public void addDirectionalLight(Vector3f direction, Color3f color) {
    // Creates a bounding sphere for the lights
    BoundingSphere bounds = new BoundingSphere();
    bounds.setRadius(1000d);
    // Then create a directional light with the given
    // direction and color
    DirectionalLight lightD = new DirectionalLight(color, direction);
    lightD.setInfluencingBounds(bounds);
    // Then add it to the root BranchGroup
    rootBranchGroup.addChild(lightD);
    * Adds a box to the universe
    * @param x
    * x dimension of the box
    * @param y
    * y dimension of the box
    * @param z
    * z dimension of the box
    Appearance vasixrwma(){
         Appearance vasixrwmaa = new Appearance();
    //load the texture
         String filename = "C:/Documents and Settings/Andy/Desktop/Arizona.jpg";
         TextureLoader loader = new TextureLoader(filename, this);
    ImageComponent2D image = loader.getImage();
    if(image == null) {
    System.out.println("load failed for texture: "+filename);
    Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
    image.getWidth(), image.getHeight());
    texture.setEnable(true);
    texture.setImage(0, image);
    texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
    texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);
    vasixrwmaa.setTexture(texture);
         return vasixrwmaa;
    public void addBox(float x, float y, float z, Color3f diffuse, Color3f spec, float a, float b, float c) {
    // Add a box with the given dimension
    // First setup an appearance for the box
    Appearance app = new Appearance();
    Material mat = new Material();
    mat.setDiffuseColor(diffuse);
    mat.setSpecularColor(spec);
    mat.setShininess(5.0f);
    app.setMaterial(mat);
    Box box = new Box(x, y, z, app);
    // Create a TransformGroup and make it the parent of the box
    Transform3D meros = new Transform3D();
    meros.setTranslation(new Vector3d(a, b, c));
    TransformGroup tg = new TransformGroup(meros);
    Appearance appear = vasixrwma();
    box.getShape(Box.TOP).setAppearance(appear);
    tg.addChild(box);
    // Then add it to the rootBranchGroup
    rootBranchGroup.addChild(tg);
    //code for mouse navigation
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    MouseRotate myMouseRotate = new MouseRotate();
    myMouseRotate.setTransformGroup(tg);
    myMouseRotate.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseRotate);
    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(tg);
    myMouseTranslate.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseTranslate);
    MouseZoom myMouseZoom = new MouseZoom();
    myMouseZoom.setTransformGroup(tg);
    myMouseZoom.setSchedulingBounds(new BoundingSphere());
    rootBranchGroup.addChild(myMouseZoom);
    // new code for key navigation
    KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(tg);
    keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(),1000.0));
    rootBranchGroup.addChild(keyNavBeh);
    * Finalise everything to get ready
    public void finalise() {
    // Then add the branch group into the Universe
    simpleU.addBranchGraph(rootBranchGroup);
    // And set up the camera position
    simpleU.getViewingPlatform().setNominalViewingTransform();
    public static void main(String[] argv) {
    vrlm bc = new vrlm("checkers");
    bc.setSize(250, 250);
    bc.addBox(10f, 10f, 10f, new Color3f(0.8f, 0.52f, 0.25f), new Color3f(0.8f, 0.52f, 0.25f), 0.7f, -0.0415f, 0.7f);
    bc.addDirectionalLight(new Vector3f(0f, 0f, -1),
    new Color3f(4f, 4f, 0f));
    bc.finalise();
    bc.show();
    return;
    please everyone's help is appreciated, because its urgent, thank you very much!!!!

    Dave,
    You won't need that hovering window next time!
    Jerry

  • New added disk in vm virtual box not shown in solaris

    hi,
    I have added new disk in VM virtual box to use it for asm, using storage tree in Vm virtual box i have added two new disks but after that when i start my OS (solaris 10) and use format command it only shows my one disk not the added disk which i add in storage. Any idea why the new added disks are not shown .
    Thanks
    Zeeshan

    Navigate to the repository tab in OVMM and right-click on the storage repo, where you created/copied the vm disk image file. From the pop-up menu choose refresh repository.
    That should scan you repository and make the new disk visible on OVMM.

  • Adding a graphic into text box (runtime without drawing sprite)

    I have the game instructions in a scrolling box but would
    like to add graphic of the arrow keys
    into the text field .
    this is probably simple .. tried adding with "+" .. but
    wasn't that simple...
    thanks for considering

    it can be either ... I tried with a library graphic ... and
    then as a mc .. but figured a image in the library would be the
    easiest ....
    was hoping I could just add it in the AS3 text script.. but
    did not work for me
    thank you for asking

  • Adding VI's to Function box

    Hello all,
    I just figured out how to add VI's to the Function box (the box that
    appears when you right-click on the diagram) by adding VI's to an
    arbitrarily-named folder in the Vi.lib\addons\ folder. But I just have
    a quick question: how to I define the icons? I want to add several
    utilities, and it would be easier to have different icons shown. I know
    each VI has its own icon, but I'd like to know how to give each
    directory in the addons folder it's own look. Thank you for your help.
    Rick

    Since you know how to add VI's as submenu to the function palette (function box), just keep the right click on the submenu and select "edit submenu icon". Then you can edit the icon just as you edit VI's icon. Note than the icon must have no close rectangular around it if you would like to make the icon transparent as other submenu icon.

  • Adding Images to a Combo Box-Acrobat 9 Pro

    Hello everyone. Can images be used as selections in a combo box in Acrobat 9 Pro? If so, how can I set that up? I only see an option for text choices when I look at the combo box properties. Basically, I want to click the drop-down and see images (clip-art basically) to choose from instead of text choices. Thank you for the help.

    Yeah, unfortunately, that isn't an option for the people will be using this form. I really need to know if there is a way to have 1 text box that I can alter line spacing.

  • Adding a "normal" square check box as a Pages 09 bullet?

    I would like to add a "normal" check box to my text bullets or image bullets in Pages 09 for more formal documents. The "artsy" check box supplied with Pages 09 is inappropriate for my work. Is there a way of getting or using a normal square check box for pages?

    The changes are in the document, not in the program.
    When the program will open this hacked document, it will grab the xml instruction as is.
    If the syntax is modified as it was from Numbers '08 to Numbers '09, the keywords will change but not the contents.
    Its the beauty of XML
    I wish to add that I posted this hack because it is not machine dependent.
    If you apply it on your machine, the document will behave the same if you open it on an other system.
    I would not did that if the document was OK only on its source machine. Not sure of my syntax but I think that you may understand. You may re-phrase it if it's really too odd).
    Second addition.
    As you saw, there are nine predefined bullets.
    If you edit the embedded descriptors you may have nine + nine different bullets. But you may also edit already edited descriptors.
    So, if you want to build a really ugly document you may use a huge number of different bullets (Pandora's box is open).
    Yvan KOENIG (from FRANCE vendredi 24 avril 2009 11:23:27)

  • Adding multiple separators in combo box

    i want to add multiple separtors in my combo box items but i can add - Value in the items list only once so i get only one separator, how can i add multiple separators in combo box items
    Tushar Jambhekar
    [email protected]
    Jambhekar Automation Solutions
    LabVIEW Consultancy, LabVIEW Training
    Rent a LabVIEW Developer, My Blog

    Tushar Jambhekar wrote:
    I tried that already, but it doesnt work
    Works fine here:
    Actually, I would argue that this is a bug in the editor, which should ingnore duplicate hypens if they have a special value.
    Try to take over the world!
    Attachments:
    Combo.PNG ‏13 KB

  • Javascript - added images display as grey boxes

    I am attempting to add an Image to an InDesign document via a javascript that I am executing via the RunScript() soap method of InDesign Cs4 server.  The script I am using to add an image is something similar to this:
    var imageFile = File("//c/images/animage.pdf");
    var imageGraphic = myDocument.pages.item(0).place(imageFile, null, imageLayer);
    imageGraphic = imageGraphic[0];
    var imageFrame = imageGraphic.parent;
    imageFrame.geometricBounds = [IMAGE_TOP_Y, IMAGE_TOP_X, IMAGE_BOTTOM_Y, IMAGE_BOTTOM_X];
    imageFrame.fit(FitOptions.proportionally);
    imageFrame.fit(FitOptions.frameToContent);
    The script adds the image correctly, but when I pull up the document with InDesign, the Images are displayed as grey boxes.  I am able to fix this within InDesign designer by manually setting the "Display Performance" to "High Quality" through the menus, but I need to handle this via the script run on the server.  I attempted to update the script to the following:
    var imageFile = File("//c/images/animage.pdf");
    var imageGraphic = myDocument.pages.item(0).place(imageFile, null, imageLayer);
    imageGraphic = imageGraphic[0];
    var imageFrame = imageGraphic.parent;
    imageFrame.geometricBounds = [IMAGE_TOP_Y, IMAGE_TOP_X, IMAGE_BOTTOM_Y, IMAGE_BOTTOM_X];
    imageFrame.fit(FitOptions.proportionally);
    imageFrame.fit(FitOptions.frameToContent);
    //HERE IS THE NEW LINE
    imageFrame.localDisplaySetting = DisplaySettingOptions.HIGH_QUALITY;
    This script runs without problems within the CS4 ExtendScript Toolkit on my local pc.  However, when I run the script against the InDesign CS4 server, I get the following error:
    Error Number: 55
    Error String: Object does not support the property or method 'localDisplaySetting'
    Does anyone have any advice on how I should proceed?  My main goal is to have the image display correctly without the grey box.

    hello, I'm running into the same issue with image showing up as grey boxes. I'm updating documents via (JS) scripts by placing new images into rectangles. When I open up that document after the script saves it, all I see is a grey box until I change the Display Performance to Typical (or higher). In my scripts, I can change the localDisplaySettings to DisplaySettings.TYPICAL, but it only works locally, when I run this on the server it fails because it says DisplaySettings is undefined. I'm wondering if this is a server setting, and if so, how I might be able to change it?
    Thanks in advance!

  • Adding element in a List box

    How do we add an element to an existing List box in swings?

    Read this section from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/list.html]How to Use Lists.

  • Adding tooltip to WebHelp Search box

    I'd like to provide a tooltip or inductive text for the Search text box in WebHelp. Specifically, I want to tell users to enclose multiple words in quotation marks, since this format returns the most relevant results. Is there a way to add a tooltip to the Search box or even just additional text to the line that starts: "Type in the word(s) to search for:"?
    We're using RoboHelp HTML 9. It would be great to know how to do this programatically, but, if necessary, I don't mind editing output files
    Thanks!
    Diana

    Something like this?
    File > Project Settings > General Tab > Advanced > LNG File Tab
    There you can change FtsInputPrompt to your own string.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Adding images in custom dialog box

    Hi!
    Do  you know if it's possibile to insert an image in a custom dialog box? I mean during the custom dialog box design (during the .dre file creation).
    Thanks to all!

    Hi Stemens,
    I'm hesitant to answer your questions anymore because somebody always comes behind and shows everybody how much I don't know   Anyway, I do not know of a way. I remember that there have been other developers discussing this and I think everybody just gave up. I have never seen an image in a dialog box, so that tends to indicate to me that no one has found a way.
    Russ

  • Adding text to a target box??!!

    Hi there,
    Ive made a trigger and target so when i roll over an image the target box fades in with a light opacity fill over the image which gives it a nice effect.
    Now I want to add text on that target box so when the fill colour fades in some full opacity text fades in as well.
    I can't seem to find a way to do this. Can someone explain how please?
    E

    You can try this widget :
    http://musewidgets.com/collections/all/products/massive-hover
    Thanks,
    Sanjit

  • Problem adding images to html text box.

    This one, like a steering wheel down the trousers, is driving
    me nuts....
    Source can be downloaded where is says 'herehere' below (not
    used to this forum, seems a bit weird.)
    I have 2 text boxes on the stage, both are set to 'multiline'
    and set to render 'html'.
    they are also set to show the contents of the variables html1
    and html2 respectively
    via the 'Var' field in the property window.(so this is an
    Actionscript 2 thing).
    the html I'm using is a very basic <img src /> tag.
    You can use any small image file you like to try this out,
    just change both source file names.
    (mine happened to be called bonkers.jpg, but gifs and pngs
    seem to be the same).
    When I define 'html1' directly, it works fine.
    If I define 'html2' directly it works fine,
    However if I define html2 via an array, although the content
    of both html1 and html2 both seems the same,
    (and all the trace code that follows checks this) the second
    html box doesn't work.
    It took me the best part of a day to figure out it was the
    process of transferring from an array
    that was causing the issue, but why ? What does an array do
    to a string that makes it stop working at html ?
    Any help would be much appreciated.
    Thanks
    Gaz
    here
    here

    Giving them the same instance name was an error on my part, I
    think it happened when I copied the text box across, but even
    without the instance names or different instance names, the set-up
    only worked when the html didn't come via an array. Perhaps not a
    bug, but an anomaly.
    I think I need to get out of the practice of using the
    preference panel to assign variables to text boxes (something I do
    a lot when debugging), and one barrier that's held me back from
    switching to AS3. Now you've introduced me to htmlText(), there
    will be no holding me back :-)
    Thanks again.

  • Adding data in a list box

    Hi all,
    I created a list-box on the selection-screen using
    PARAMETERS p_mtart type mtart AS LISTBOX VISIBLE LENGTH 20
    But, I don't find a way to add data to this list-box.
    Please help me.
    Regards,
    Saurabh Buksh.

    Hi,
    Sorry to bother you.
    I solved it.
    Regards,
    Saurabh Buksh.

Maybe you are looking for

  • Chinese characters in Labview 8

    HI, I have a Labview 8 Professional version on Linux. I want to know if Labview 8 professional version supports chinese characters. I want to have chinese characters in my front panel but i dont know how to do it. My linux OS doesnt have any chinese

  • Question Mark / not reading hard drives

    I have a flashing question mark /apple icon on the attempts to startup my G4 . Not reading the drives . I have used the startup disk & checed the profile & it reads the drives in the extensions, however not on startup

  • OSInstall.mpkg folders on the Hard Drive after new installation of Mac OS X

    I recently installed Mac OS X 10.4.3 on a newly erased hard drive on a G4 to which I'm doing major upgrades. The installation went fine, and everything works well, but ther are four folders on the root level of the hard drive which are puzzling. The

  • CS4 using Save for Web & Devices Problem

    I choose Save for Web & Devices. Select .jpg as file type but on bottom left under preview it says GIF. And I cannot reduce the resolution quality using the slide bar. It always says GIF and file size stays the same.   Can anyone tell me how to fix t

  • Hitting different G/L accounts

    i have a plant A which has materials of supplies type and plant B having materials of parts type.Both the plants are having same valuation group code whereby during inventory posting both the plants will hit the same G/L accounts.Now i am moving the