Hi, ich hab grad einen kleinen "createthesceneGraph" geschrieben, und bin da auf ein Problem gestoßen,
ihr kennt in Java doch diese Methode mit den "[]"
aber bei mir kommt eine Fehlermeldung obwohl ich alles richtig mache:
(wie ich denke)
kann mir da einer weiterhelfen?
[highlight=Java]
public BranchGroup createSceneGraph()
{
BranchGroup BG = new BranchGroup();
//
DirectionalLight DLgt=new DirectionalLight(new Color3f(0.8f,0.8f,0.8f),new Vector3f(-0.5f,-1f,-0.5f));
AmbientLight ALgt=new AmbientLight(new Color3f(0.8f,0.8f,0.8f));
BoundingSphere BigBounds=new BoundingSphere(new Point3d(),100000);
ALgt.setInfluencingBounds(BigBounds);
DLgt.setInfluencingBounds(BigBounds);
BG.addChild(ALgt);
BG.addChild(DLgt);
//
Appearance App = new Appearance();
App.setTexture((new TextureLoader("F:/Rayman/Films/Trailer/Main.jpg",null)).getTexture());
App.setTextureAttributes(new TextureAttributes(TextureAttributes.MODULATE,new Transform3D(),new Color4f(),TextureAttributes.FASTEST));
Transform3D[] a = new Transform3D[10];
a[1].setTranslation(new Vector3f(0,-1,0));
a[2].setTranslation(new Vector3f(0,0,0));
a[3].setTranslation(new Vector3f(0,0,0));
a[4].setTranslation(new Vector3f(0,0,0));
a[5].setTranslation(new Vector3f(0,0,0));
a[6].setTranslation(new Vector3f(0,0,0));
a[7].setTranslation(new Vector3f(0,0,0));
a[8].setTranslation(new Vector3f(0,0,0));
a[9].setTranslation(new Vector3f(0,0,0));
a[10].setTranslation(new Vector3f(0,0,0));
TransformGroup[] A = new TransformGroup[10];
A[1].setTransform(a[10]);
A[2].setTransform(a[2]);
A[3].setTransform(a[3]);
A[4].setTransform(a[4]);
A[5].setTransform(a[5]);
A[6].setTransform(a[6]);
A[7].setTransform(a[7]);
A[8].setTransform(a[8]);
A[9].setTransform(a[9]);
A[10].setTransform(a[10]);
BG.addChild(A[1]);
BG.addChild(A[2]);
BG.addChild(A[3]);
BG.addChild(A[4]);
BG.addChild(A[5]);
BG.addChild(A[6]);
BG.addChild(A[7]);
BG.addChild(A[8]);
BG.addChild(A[9]);
BG.addChild(A[10]);
A[1].addChild(new Box(10,0.1f,10,Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS, App));
createStarBackground(BG);
BG.compile();
return BG;
}
[/highlight]
FehlerMeldung
Zeile 157 ist bei mir
Zeile 100 ist bei mir
("u" ist eine SimpleUniverse nur mal so nebenbei")
Zeile 201 ist bei mir
ihr kennt in Java doch diese Methode mit den "[]"
aber bei mir kommt eine Fehlermeldung obwohl ich alles richtig mache:
(wie ich denke)
kann mir da einer weiterhelfen?
[highlight=Java]
public BranchGroup createSceneGraph()
{
BranchGroup BG = new BranchGroup();
//
DirectionalLight DLgt=new DirectionalLight(new Color3f(0.8f,0.8f,0.8f),new Vector3f(-0.5f,-1f,-0.5f));
AmbientLight ALgt=new AmbientLight(new Color3f(0.8f,0.8f,0.8f));
BoundingSphere BigBounds=new BoundingSphere(new Point3d(),100000);
ALgt.setInfluencingBounds(BigBounds);
DLgt.setInfluencingBounds(BigBounds);
BG.addChild(ALgt);
BG.addChild(DLgt);
//
Appearance App = new Appearance();
App.setTexture((new TextureLoader("F:/Rayman/Films/Trailer/Main.jpg",null)).getTexture());
App.setTextureAttributes(new TextureAttributes(TextureAttributes.MODULATE,new Transform3D(),new Color4f(),TextureAttributes.FASTEST));
Transform3D[] a = new Transform3D[10];
a[1].setTranslation(new Vector3f(0,-1,0));
a[2].setTranslation(new Vector3f(0,0,0));
a[3].setTranslation(new Vector3f(0,0,0));
a[4].setTranslation(new Vector3f(0,0,0));
a[5].setTranslation(new Vector3f(0,0,0));
a[6].setTranslation(new Vector3f(0,0,0));
a[7].setTranslation(new Vector3f(0,0,0));
a[8].setTranslation(new Vector3f(0,0,0));
a[9].setTranslation(new Vector3f(0,0,0));
a[10].setTranslation(new Vector3f(0,0,0));
TransformGroup[] A = new TransformGroup[10];
A[1].setTransform(a[10]);
A[2].setTransform(a[2]);
A[3].setTransform(a[3]);
A[4].setTransform(a[4]);
A[5].setTransform(a[5]);
A[6].setTransform(a[6]);
A[7].setTransform(a[7]);
A[8].setTransform(a[8]);
A[9].setTransform(a[9]);
A[10].setTransform(a[10]);
BG.addChild(A[1]);
BG.addChild(A[2]);
BG.addChild(A[3]);
BG.addChild(A[4]);
BG.addChild(A[5]);
BG.addChild(A[6]);
BG.addChild(A[7]);
BG.addChild(A[8]);
BG.addChild(A[9]);
BG.addChild(A[10]);
A[1].addChild(new Box(10,0.1f,10,Box.GENERATE_NORMALS|Box.GENERATE_TEXTURE_COORDS, App));
createStarBackground(BG);
BG.compile();
return BG;
}
[/highlight]
FehlerMeldung
Code:
Exception in thread "main" java.lang.NullPointerException
at Start.Game.createSceneGraph(Game.java:157)
at Start.Game.<init>(Game.java:100)
at Start.Game.main(Game.java:201)
Code:
a[1].setTranslation(new Vector3f(0,-1,0));
Code:
u.addBranchGraph(createSceneGraph());
Zeile 201 ist bei mir
Code:
public static void main(String[]args)
{
new Game();
}
Zuletzt bearbeitet: