Hello,
I dont know if this has already been talked about in these forums but I could not find what I was looking for so I apologise in advance.
I have a uneven terrain wich is an OBJ which I import.
(marked in re is where the car drives, I want the car to follow the grey terrain.)
and I ahve my car which is also a OBJ which I import when the two colide its as through a box has been created around the highest point and the car just drives on a flat plane at the highest point rather than folloing the terrain.
Thanks
private void plane_level() {
ObjToJme converter = new ObjToJme();
try {
URL objFile = Main.class.getClassLoader().getResource("level.obj");
converter.setProperty("mtllib", objFile);
converter.setProperty("texdir", objFile);
ByteArrayOutputStream BO = new ByteArrayOutputStream();
System.out.println("Starting to convert .obj to .jme");
converter.convert(objFile.openStream(), BO);
world = (TriMesh) BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray()));
world.setModelBound(new BoundingBox());
world.updateModelBound();
world.setLocalTranslation(0, -10, 0);
MidPointHeightMap heightMap = new MidPointHeightMap(64, 1f);
//set height maps
ProceduralTextureGenerator pt = new ProceduralTextureGenerator(heightMap);
pt.addTexture(new ImageIcon(Main.class.getClassLoader().getResource("B4NDIT2.jpg")), -128, 0, 128);
pt.addTexture(new ImageIcon(Main.class.getClassLoader().getResource("B4NDIT2.jpg")), 0, 128, 255);
pt.addTexture(new ImageIcon(Main.class.getClassLoader().getResource("B4NDIT2.jpg")), 128, 255, 384);
pt.createTexture(32);
// assign the texture to the terrain
TextureState ts = display.getRenderer().createTextureState();
Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),
Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
ts.setTexture(t1, 0);
world.setRenderState(ts);
final StaticPhysicsNode staticNode = getPhysicsSpace().createStaticNode();
//Box world;
//world = new Box("world", new Vector3f(0, -1, 0), 50f, .2f, 50f);
MaterialState redgreen = display.getRenderer().createMaterialState();
redgreen.setDiffuse(ColorRGBA.red);
redgreen.setShininess(10f);
world.setRenderState(redgreen);
staticNode.attachChild(world);
staticNode.generatePhysicsGeometry();
staticNode.setMaterial(Material.CONCRETE);
rootNode.attachChild(staticNode);
} catch (Exception e) {
}
}