Java3D Textur Problem

Developer_Y

Gesperrt
HI kann mir einer sagen was ich falsch mache?

Code:
package Bäume;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import Figuren.Rayman_Body;
import Figuren.Rayman_Feet;
import Figuren.Rayman_Hand_Left;
import Figuren.Rayman_Hand_Right;
import Figuren.Rayman_Head;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.vp.*;       
import com.sun.j3d.utils.image.TextureLoader;
	
	public class C_2 extends Applet {       
    
	//Private definierungen
	
        private Appearance blue = new Appearance();
        private Appearance blue2 = new Appearance();

    private SimpleUniverse universe ;
    private Canvas3D canvas;
    private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 10.0), 1000.0);
    Transform3D translate = new Transform3D();
    
      public void setupView() 
      { 
    	OrbitBehavior orbit = new OrbitBehavior(canvas,
                OrbitBehavior.REVERSE_ALL|OrbitBehavior.STOP_ZOOM);
        orbit.setSchedulingBounds(bounds);
        ViewingPlatform viewingPlatform = universe.getViewingPlatform();
        
        viewingPlatform.setNominalViewingTransform();
        viewingPlatform.setViewPlatformBehavior(orbit);       
        }       
         
        

          
          public BranchGroup createSceneGraph() {
          // Wurzel des Ast-Graphen erstellen
         BranchGroup objRoot = new BranchGroup();       
         // 45°-Rotation um die x-Achse
         translate.rotY(Math.toRadians(45));      
         
         Appearance white = new Appearance();

         Transform3D g1 = new Transform3D();
         g1.setTranslation(new Vector3f(0,1,0));
         TransformGroup G1 = new TransformGroup();
         G1.setTransform(g1);
         G1.addChild(new Rayman_Head().getChild());
         Transform3D g2 = new Transform3D();
         g2.setTranslation(new Vector3f(0,0,0));
         TransformGroup G2 = new TransformGroup();
         G2.setTransform(g2);
         G2.addChild(new Rayman_Body().getChild());
         Transform3D g3 = new Transform3D();
         g3.setTranslation(new Vector3f(-0.5f,0,0));
         TransformGroup G3 = new TransformGroup();
         G3.setTransform(g3);
         G3.addChild(new Rayman_Hand_Left().getChild());
         Transform3D g4 = new Transform3D();
         g4.setTranslation(new Vector3f(0.5f,0,0));
         TransformGroup G4 = new TransformGroup();
         G4.setTransform(g4);
         G4.addChild(new Rayman_Hand_Right().getChild());
         Transform3D g5 = new Transform3D();
         g5.setTranslation(new Vector3f(0.5f,-1f, 1.5f));
         TransformGroup G5 = new TransformGroup();
         G5.setTransform(g5);
         G5.addChild(new Rayman_Feet(blue).getChild1());
         G5.addChild(new Rayman_Feet(blue).getChild2());
         G5.addChild(new Rayman_Feet(blue).getChild3());
         G5.addChild(new Rayman_Feet(blue).getChild4());
         Transform3D g6 = new Transform3D();
         g6.setTranslation(new Vector3f(-0.5f,-1f, 1.5f));
         TransformGroup G6 = new TransformGroup();   
         G6.setTransform(g6);
         G6.addChild(new Rayman_Feet(blue2).getChild1());
         G6.addChild(new Rayman_Feet(blue2).getChild2());
         G6.addChild(new Rayman_Feet(blue2).getChild3());
         G6.addChild(new Rayman_Feet(blue2).getChild4());

         objRoot.addChild(G1);
         objRoot.addChild(G2);
         objRoot.addChild(G3);
         objRoot.addChild(G4);
         objRoot.addChild(G5);
         objRoot.addChild(G6);

       


        
         white.setTexture((new TextureLoader("F:/FUTURE.SYSTEMS/Rayman_Bilder/Rayman_Feet_.jpg",null)).getTexture());
         white.setTextureAttributes(new TextureAttributes(TextureAttributes.MODULATE,new Transform3D(),new Color4f(),TextureAttributes.FASTEST));
        
         blue2.setTexture((new TextureLoader("F:/FUTURE.SYSTEMS/Rayman_Bilder/Rayman_Feet_!.jpg",null)).getTexture());
         blue2.setTextureAttributes(new TextureAttributes(TextureAttributes.MODULATE,new Transform3D(),new Color4f(),TextureAttributes.FASTEST));

         blue.setTexture((new TextureLoader("F:/FUTURE.SYSTEMS/Rayman_Bilder/Rayman_Feet_!!.jpg",null)).getTexture());
         blue.setTextureAttributes(new TextureAttributes(TextureAttributes.MODULATE,new Transform3D(),new Color4f(),TextureAttributes.FASTEST));

        Color3f lightColor = new Color3f(.3f,.3f,.3f);
        AmbientLight ambientLight= new AmbientLight(lightColor);
        ambientLight.setInfluencingBounds(bounds);
        objRoot.addChild(ambientLight);
        DirectionalLight directionalLight = new DirectionalLight();
        directionalLight.setColor(lightColor);
        directionalLight.setInfluencingBounds(bounds);
        objRoot.addChild(directionalLight);       
        return objRoot;       
    }       
     
    public void init() {
         BranchGroup scene = createSceneGraph();       
         setLayout(new BorderLayout());
         
         GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
         canvas = new Canvas3D(config);
         add("Center", canvas);       
        
         universe = new SimpleUniverse(canvas);       
         setupView();       
         universe.addBranchGraph(scene);
    }       
    public void destroy() {universe.removeAllLocales();}       
   
    public static void main(String[] args) {new MainFrame(new C_2(), 256, 256);}
}

Die Fehler Meldung ist folgende:
Code:
java.lang.OutOfMemoryError: Java heap space
	at java.awt.image.DataBufferByte.<init>(Unknown Source)
	at java.awt.image.Raster.createInterleavedRaster(Unknown Source)
	at java.awt.image.BufferedImage.<init>(Unknown Source)
	at com.sun.j3d.utils.image.TextureLoader.getScaledImage(TextureLoader.java:806)
	at com.sun.j3d.utils.image.TextureLoader.getScaledImage(TextureLoader.java:783)
	at com.sun.j3d.utils.image.TextureLoader.getTexture(TextureLoader.java:526)
	at Bäume.C_2.createSceneGraph(C_2.java:106)
	at Bäume.C_2.init(C_2.java:121)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Was kann ich machen dass dieser Quellcode funktioniert?
 
Hm, verwendest Du vielleicht sehr große Bilder als Texturen? Versuch mal, die Bilder in einem Bildbearbeitungsprogramm zu verkleinern!
 
Die Bilder sind 20 * 20 groß, es ist das Problem. dass wenn ich eine dritte Textur nehme, dann geht das Programm nicht, wenn ich die dritte apperance wegmache, dann kann ich mit der zweiten Appearance die Textur von der dritten verwenden.,
 
Ich hab das mal bei anderen Quellcodes ausprobiert, ab 3 Appearance geht nichts mehr,
könntest du mir schildern wie man diesen Heap Space oder was das ist in "Eclipse" erhöht. Vielleicht könntest du mir ein Tutorial geben oder so?
 
Zurück