저는 일반적으로 3D 엔진을 처음 사용합니다. 기하학과 BoundingVolume 객체를 충돌 시키려고하면이 NullPointerException이 발생합니다. 여기JMonkeyEngine- 기하학 교차점 NullPointerException
내가 내 개체 (죄송합니다,이 순간에 오히려 혼란의)
public void simpleInitApp() {
Quad q= new Quad(100, 100);
Dome mesh = new Dome(Vector3f.ZERO, 2, 32, 1f,false);
geom = new Geometry("Cylinder", mesh); //declared elsewhere
g3 = new Geometry("lel", q);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.Red);
geom.setMaterial(mat);
g3.setMaterial(mat2);
rootNode.attachChild(geom);
rootNode.attachChild(g3);
여기 내 업데이트 루프
public void simpleUpdate(float tpf) {
// System.out.println("hi");
BoundingVolume b = g3.getWorldBound(); //should give boundingvolume of the quad
System.out.println(b.getVolume()); //just to test if this works
CollisionResults r2 = new CollisionResults(); //declare and initialize the collisionresults
geom.collideWith(b, r2); //collide
System.out.println(r2.size()); //this returns a value, usually between 0-2
for(CollisionResult x:r2){
System.out.println("x = "+ x.getContactPoint().getX());
/*and oddly enough, i get a NullPointerException here even though the collision appeared successful - this never prints anything either so it's not going out of bounds or anything*/
}
}
TL의 선언 방법은, 내가하려고 할 때 NullPointerException이 DR-수 BoundingVolume과 Geometry의 교차점에서 각 CollisionResult의 좌표를 인쇄하십시오.
JMonkey 포럼이나 JMonkey 문서는 도움이되지 않습니다. 당신 중 누구라도 도울 수 있습니까? 미리 감사드립니다.
나는 피 묻은 바보 야 ... 고마워. – user2701956