1
Feedback / IRC channel?
« on: March 10, 2011, 04:06:11 pm »
Would it be an idea to make an irc channel for quick help or random chit-chat?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Out of memory on a 3527724-byte allocation.
FATAL EXCEPTION: GLThread 9
java.lang.OutOfMemoryError
at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:218)
at com.threed.jpct.ZipHelper.unzip(ZipHelper.java:30)
at com.threed.jpct.GLRenderer.convertTexture(GLRenderer.java:766)
at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:2151)
at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2064)
at com.threed.jpct.World.draw(World.java:1341)
at com.threed.jpct.World.draw(World.java:1122)
at gp.itsolutions.Render.onDrawFrame(Render.java:87)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
public class Terrain {
private Object3D terrain = null;
private Texture terrainTexture = null;
private ZipInputStream zis = null;
public Terrain(World world){
try {
if(terrainTexture == null)
terrainTexture = new Texture(Gameplay.resources.openRawResource(R.raw.terraintexture));
if(!TextureManager.getInstance().containsTexture("terrainTexture"))
TextureManager.getInstance().addTexture("terrainTexture", terrainTexture);
if(zis == null){
zis = new ZipInputStream(Gameplay.resources.openRawResource(R.raw.terrain));
zis.getNextEntry();
}
if( (terrain == null) && (zis != null) ){
terrain = Loader.loadSerializedObject(zis);
terrain.setScale(20);
terrain.setTexture("terrainTexture");
//F.tileTexture(terrain, 25);
terrain.compile();
terrain.build();
world.addObject(terrain);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void dispose(){
if(terrainTexture != null){ terrainTexture = null; }
if(terrain != null){ terrain = null; }
if(zis != null){ try { zis.close(); } catch (IOException e) { } zis = null; }
}
}
new SkyBox(1024);
So without the textures,camPos.x = (float) (Math.sin(me.getX()%360 * (Math.PI/180)) * -1.5f);
camPos.z = (float) (Math.cos(me.getX() * (Math.PI/180)) * 2.25f);
public class Terrain {
public static float HighestPoint = 0;
static Bitmap bmp = null;
static String pixel = null;
public static Object3D Generate(int X_SIZE, int Z_SIZE, TextureManager tm, String TextureID){
bmp = BitmapFactory.decodeResource(SpaceGrabber.resources, R.drawable.terrain); // the heightmap texture (128x128 due to memory limitations?)
float[][] terrain = new float[X_SIZE][Z_SIZE];
for (int x = 0; x < X_SIZE-1; x++) {
for (int z = 0; z < Z_SIZE-1; z++) {
pixel = Integer.toString(bmp.getPixel(x, z), 16);
terrain[x][z] = Integer.parseInt(pixel.charAt(1) + "" + pixel.charAt(2), 16);
if(terrain[x][z] > HighestPoint){
HighestPoint = terrain[x][z];
}
}
}
for (int x = 0; x < X_SIZE - 1; x++) {
for (int z = 0; z < Z_SIZE - 1; z++) {
terrain[x][z] = (terrain[x][z] + terrain[x + 1][z] + terrain[x][z + 1] + terrain[x + 1][z + 1]) / 4;
}
}
Object3D ground = new Object3D(X_SIZE * Z_SIZE * 2);
float xSizeF = (float) X_SIZE;
float zSizeF = (float) Z_SIZE;
int id = tm.getTextureID(TextureID); // I used a gray 128x128 texture
for (int x = 0; x < X_SIZE - 1; x++) {
for (int z = 0; z < Z_SIZE - 1; z++) {
TextureInfo ti = new TextureInfo(id, (x / xSizeF), (z / zSizeF), ((x + 1) / xSizeF), (z / zSizeF), (x / xSizeF), ((z + 1) / zSizeF));
ground.addTriangle(new SimpleVector(x * 10, terrain[x][z], z * 10), new SimpleVector((x + 1) * 10, terrain[x + 1][z], z * 10),
new SimpleVector(x * 10, terrain[x][z + 1], (z + 1) * 10), ti);
ti = new TextureInfo(id, (x / xSizeF), ((z + 1) / zSizeF), ((x + 1) / xSizeF), (z / zSizeF), ((x + 1) / xSizeF), ((z + 1) / zSizeF));
ground.addTriangle(new SimpleVector(x * 10, terrain[x][z + 1], (z + 1) * 10), new SimpleVector((x + 1) * 10, terrain[x + 1][z], z * 10), new SimpleVector((x + 1) * 10,
terrain[x + 1][z + 1], (z + 1) * 10), ti);
}
}
return ground;
}
}
SimpleVector playerPosition = new SimpleVector();
playerPosition.set(player.getPositionInWorldSpace());
ground.getHeight(playerPosition.x, playerPosition.z);