Code: Select all
int res = 300;
ByteBuffer bytes = ByteBuffer.allocateDirect(res*res*4);
for(int i=0; i<res*res; i++)
{
bytes.putFloat(0);
}
terrainShape=new btHeightfieldTerrainShape(res,res,bytes.asFloatBuffer(),1,0.0f,0.0f,1,false);
Then i check the terrain by raycasting and creating an object in hit point.
Code: Select all
public void MylRayTest(ArrayList<ModelInstance> instances, Model model)
{
float max = Float.MIN_VALUE;
float min = Float.MAX_VALUE;
for(int i=-500; i<500; i+=5)
{
for(int j=-500; j<500; j+=5)
{
Vector3 from=new Vector3(new Vector3(i,10000,j));
Vector3 to = new Vector3(new Vector3(i,-10000,j));
ClosestRayResultCallback callback = new ClosestRayResultCallback(from, to);
world.rayTest(from, to, callback);
if(callback.hasHit())
{
Vector3 t = new Vector3();
callback.getHitPointWorld(t);
instances.add(new ModelInstance(model, t));
float tt = t.y;
if(tt>max) max=tt;
if(tt<min) min=tt;
}
callback.dispose();
}
}
System.out.println("Max: "+max+" Min: "+min);
}
As you can see it's not a simple plain. It's broken plain!
Why it happens? What is wrong?