Hallo,
ich habe folgendes problem: Wenn ich in Eclipse(V3.1) versuche eine Textuer zu laden,
erhalte ich folgende Fehlermeldung: The method setTexture(Texture)
in the type Appearance is not applicable for the arguments (Texture)
Code:
Bitte helft mir!
ich habe folgendes problem: Wenn ich in Eclipse(V3.1) versuche eine Textuer zu laden,
erhalte ich folgende Fehlermeldung: The method setTexture(Texture)
in the type Appearance is not applicable for the arguments (Texture)
Code:
Code:
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import javax.media.j3d.*;
import javax.vecmath.AxisAngle4f;
import javax.vecmath.Color3f;
import javax.vecmath.Color4f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
//import com.sun.j3d.utils.image.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.universe.SimpleUniverse;
import java.awt.Component;
public class Game extends Applet{
private SimpleUniverse u = null;
public BranchGroup createSceneGraph() {
BranchGroup RootBG=new BranchGroup();
TransformGroup SphereTG=new TransformGroup();
Transform3D SphereT3D=new Transform3D();
Appearance SphereAppearance=new Appearance();
AmbientLight ALgt=new AmbientLight(new Color3f(1f,1f,1f));
DirectionalLight DLgt=new DirectionalLight(new Color3f(1f,1f,1f),new Vector3f(-0.5f,-0.5f,-1f));
BoundingSphere BigBounds=new BoundingSphere(new Point3d(),100000);
ALgt.setInfluencingBounds(BigBounds);
DLgt.setInfluencingBounds(BigBounds);
SphereT3D.setTranslation(new Vector3f(0f,0f,-1.5f));
SphereTG.setTransform(SphereT3D);
SphereAppearance.setMaterial(new Material(new Color3f(0f,0f,1f),new Color3f(0f,0f,0f),new Color3f(1f,0f,0f),new Color3f(1f,1f,1f),100f));
//Texture text = TextureLoader.INSTANCE.getTexture("texturen/Wand.jpg");
SphereAppearance.setTexture(TextureLoader.INSTANCE.getTexture("texturen/Wand.jpg"));
SphereAppearance.setTexCoordGeneration(new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP,TexCoordGeneration.TEXTURE_COORDINATE_2));
SphereAppearance.setTextureAttributes(new TextureAttributes(TextureAttributes.REPLACE,new Transform3D(),new Color4f(),TextureAttributes.NICEST));
SphereTG.addChild(new Sphere(1.0f,Sphere.GENERATE_NORMALS,40,SphereAppearance));
RootBG.addChild(SphereTG);
RootBG.addChild(ALgt);
RootBG.addChild(DLgt);
RootBG.compile();
return RootBG;
}
public Game(){
}
public void init(){
setLayout(new BorderLayout());
GraphicsConfiguration config=SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
add("Center", c);
u = new SimpleUniverse(c);
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(createSceneGraph());
}
public void destroy(){
u.cleanup();
}
public static void main(String[] args) {
new MainFrame(new Game(), 400, 400);
}
}