Hey there,
i would like to test a collision between a box, which is my dummy (will be replaced by a model later), and a Model (a car in this case).
I'd like to exit the game, if the collision is true. I tried it with the intersection command, but it did not work so far
if (nissanNode.getModelBound().intersects(b.getModelBound())) {
System.exit(0);
}
Eclipse gives me the following message:
"The Method getModelBound() is undefined for the type Node"
Then i tried it with the code below, i can start, but then i get the message afterthe code.
if (nissanNode.getWorldBound().intersects(b.getModelBound())) {
System.exit(0);
}
"
SCHWERWIEGEND: Exception in game loop
java.lang.NullPointerException
at drive.simpleInitGame(drive.java:110)
at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
at com.jme.app.BaseGame.start(BaseGame.java:74)
at drive.main(drive.java:62)
"
Heres my Code so far.
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.bounding.BoundingSphere;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.scene.CameraNode;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Box;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.FormatConverter;
import com.jmex.model.converters.ObjToJme;
import java.net.URL;
import java.util.Random;
import java.util.logging.Logger;
import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingSphere;
import com.jme.image.Texture;
import com.jme.input.KeyInput;
import com.jme.input.action.InputActionEvent;
import com.jme.input.action.KeyInputAction;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Controller;
import com.jme.scene.Skybox;
import com.jme.scene.Spatial;
import com.jme.scene.Text;
import com.jme.scene.TriMesh;
import com.jme.scene.shape.Sphere;
import com.jme.scene.state.CullState;
import com.jme.scene.state.MaterialState;
import com.jme.util.TextureManager;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.audio.AudioSystem;
import com.jmex.audio.AudioTrack;
// Simpel Game erstellen
public class drive extends SimpleGame {
private static final Logger logger = Logger
.getLogger(drive.class.getName());
private Node nissanNode;
// Konfigurationsfenster am Anfang