Main Menu
Menu

Show posts

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.

Show posts Menu

Topics - Kaiidyn

#1
Feedback / IRC channel?
March 10, 2011, 04:06:11 PM
Would it be an idea to make an irc channel for quick help or random chit-chat?
#2
Support / Different screen resolutions
March 05, 2011, 02:19:38 PM
Just some thoughts here.

I am developing on a SGS with a screen res of 800x480...
I was thinking about blitting etc for graphical user interface (menu, hud, etc)
But how can I take different screen resolutions into account, eg 480x320...


edit: I got a loading texture 800x480 that I want to blit, but Texture says that 800 is unsupported width, how would I go about making loading texture?
#3
Support / Out of memory
February 24, 2011, 02:41:09 PM
I'm starting to get really frustrated with this error...

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)


I am rewriting and cleaning the code for what I have now in my mmo game (in a separate project)
and get this error when (I think) loading the terrain from zip file (as ZipHelper is mentioned in the error)
But the fact is, I did not change anything compared to my old code, except for the fact that I created a separate class for loading and disposing the terrain...

Terrain class:
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; }
}
}


I have tried several attempts to try and fix it, but I can't get the right one..
Figured a second pair of eyes might help..
#4
Support / SkyBox missing feature?
February 23, 2011, 11:36:53 AM
It is possible to initialize the skybox using
new SkyBox(1024);
So without the textures,
However there is no way to set the textures at a later stadium.
At least, not that I could find.
Maybe add some functions like SkyBox.setNorth or SkyBox.setTextures(n, e, s, w) ?
#5
Support / What does jPCT stand for?
February 19, 2011, 07:23:39 PM
Just wondering..
#6
Support / SkyBox and Camera Rotation
February 17, 2011, 10:34:50 PM
I added a skybox to my game, but when I rotate my camera, I'm always facing the same side of the skybox.. its like its a far away billboarded object.
is there any fix for this?

(using http://www.jpct.net/forum2/index.php/topic,1873.msg13762.html#msg13762 )
#7
Support / Rotate camera around point
February 12, 2011, 04:21:26 PM
How do I rotate my camera around the player when moving my finger over the screen? (on all axis)
what I currently have is this
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);


but this does not take the player position into account.. and is probably plain bad maths =p (i suck at them lols)

Kind regards,
Kaiidyn.
#8
Support / Polygon picking?
February 09, 2011, 11:01:35 AM
So I got my terrain now.
What I need now is something like polygon picking?
I want to be able to tap the terrain at any position and return the world-space coordinates of where I tapped the terrain.
I think the most logical way to do this is to check which polygon is being tapped on, and return it's (x y and z) position..
I was looking at http://www.jpct.net/wiki/index.php/Picking but the 'fast way' does not work on android ( ? ) as world.getVisibilityList() does not exist..
#9
Support / Framerate and movement
February 07, 2011, 09:25:10 PM
When moving an object in the render loop.. lets say.. rotateX(0.01f); it will rotate faster with higher framerate and rotates slower with lower framerate..
If i remember correctly, some other sdk i once used had a function or something called AccurateTimeElapsed..
I'm not sure what it does but when calling eg, rotateX(0.001f * AccurateTimeElapsed); it would rotate at the same speed on any framerate..
is there some similar method or whatever in jPCT?
Or if someone knows how it works so that I can implement it myself ?

Kind regards,
Kaiidyn.
#10
Support / Landscape, Model or Heightmap?
February 04, 2011, 09:53:27 PM
What is better to use for a landscape/terrain with hills etc,
an 3D model (3ds?) or an Heightmap texture..

I have been screwing around with heightmaps for a bit now, attempting to make a nice (easy to use (HARD TO MAKE;o) class for it.
but is it really worth the effort.. ? or could I better use a model for terrain.. (looking at resource usage for mobile devices)

I'd rather use heightmaps, but what I cant figure out is a nice way to read the file..
As the one in the wiki (i posted) has like 3 for loops that needs to loop through the x*y size of the image.
and that consumes a whole lot of time..
I am trying to get a 256x256 heightmap image to load.. but it takes about 4 minutes just to loop through the for's..
Anyone know of a better way to handle heightmaps?

Or maybe a proper way to use a model with collision detection (get y from specific x/z on the object)..

Kind regards,
Kaiidyn..
#11
Projects / Thanatos Online, a MMORPG for Android
February 02, 2011, 01:20:41 PM
I am working on a Massive Multiplayer Online Role Playing Game for android (and other platforms to come)

Details can be found here: http://thanatosonline.wikidot.com/

Let me know what you think, and if you have any suggestions to add.. don't hesitate to tell me :)
eg. what works, what is playable, and what do you like to play/see in an mmo for mobile devices.

Kind regards,
Kaiidyn.
#12
Support / Input text field
January 27, 2011, 01:48:29 PM
How would i go about making a working input text field?
Like enter your name to add high-score or something.

Thanks in advance,
Kaiidyn.
#13
Support / Per pixel lighting/shadows
January 19, 2011, 01:29:22 PM
I have a simple box with a light, but the light casts on the triangles of the box and that is..... ugly.. =p
Is there any way to enable a per pixel lighting or shadow casting?
if so, how would i go about doing that?
#14
Support / Heightmap Terrain
November 29, 2010, 08:59:16 PM
managed to get heightmap working, and want to share it with all of you :)

When using it make sure you have a Texture Manager with a TextureID ready, (I used a flat gray 128x128 image for this)

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;
}
}
#15
Support / Position in world-space
November 24, 2010, 01:43:28 PM
I need to get the position of my object in world space.
and with that I need to get the terrain height (terrain generated with this script: http://www.jpct.net/forum2/index.php/topic,1343.0.html )

Something like


SimpleVector playerPosition = new SimpleVector();
playerPosition.set(player.getPositionInWorldSpace());
ground.getHeight(playerPosition.x, playerPosition.z);


Is this possible?

Kind regards,
Kaiidyn.
#16
Support / Rotating Object
November 23, 2010, 03:23:53 PM
When using Object3D.rotateX the object rotates the object with the value given.
Is it possible to do like Object3D.rotateX(Math.toRadians(45)); in the renderloop and keep the object rotated at 45 degrees, instead of adding 45 deg. to the current rotation value?

Edit: Also is it possible to get the current rotate value?
#17
Support / Texturing a Primitive
November 21, 2010, 10:06:09 AM
Hello,

I just started out a couple of days ago with 3D programming for Android,
And jPCT-ae really got my attention, It's easy to use and well documented.
But I got a problem putting a texture on a Ellipsoid primitive.

TextureManager.getInstance().flush();
TextureManager tm = TextureManager.getInstance();
Resources res = Engine.resources;

/** LOAD TEXTURES **/
Texture random = new Texture(Engine.resources.getDrawable(R.raw.random));
tm.addTexture("random", random);

TextureInfo randomTex = new TextureInfo(tm.getTextureID("random"));

button1 = Primitives.getEllipsoid(64, 0.5f);
button1.setTexture(randomTex);
button1.build();
button1.translate(0, -125, 0);
world.addObject(button1);

All this code is located in onSurfaceCreated.

The texture I'm trying to put on.

I got the feeling it does actually work, but partially,
As I see my entire mesh in red.
I think I need to do something with the UV Mapping, but have no idea how that works.
Or, it has something to do with texture scaling.. that the image is too big for the object.

My question therefor is, how do I downscale the texture to match my object, or how does UV Mapping work?

Kind regards,
Kaiidyn.


Edit:
Figured out that it is actually a problem with the UV mapping,
the center of the texture (where i have the text) gets put on the side of the Ellipsoid that has been squeezed by the scaleHeight.
What I want is that the text in the texture is set on the top of the primitive as a button, like This one.
But I have no idea how to do that.