tile system?

Started by 9kaywun, August 14, 2012, 01:06:49 PM

Previous topic - Next topic

9kaywun

I need to implement a simple tile system into my 3d game client for npc/prop rendering.. I am using Primitives.getPlane(quad, scale) to generate a small region, but I can't figure out how I could go about making an imaginary 96x96 grid with textures rendered over it.
I have already written a method to load map data from a file and would render the scene like so <regionId, tileId, textureId>
I also would like to be able to not have any negative ids for tiles because it over complicates certain functions I intend on integrating server-sided in the future.
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

EgonOlsen

I don't get the question...you want to create on object that consists of 96*96 quads? Or 96*96 individual quads? And what does this have to do with negative ids?

Disastorm

e3d, are you asking how to make a 96X96 tile board with each tile represented by a plane with a custom texture based on a map file?

9kaywun

Quote from: Disastorm on August 15, 2012, 04:50:52 AM
e3d, are you asking how to make a 96X96 tile board with each tile represented by a plane with a custom texture based on a map file?

Yes. Exactly.
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

Disastorm

You can just read through the map file and for each entry create a tile in the appropriate location.  For example you can decide to have the first tile at 0,0(with arbitrary z value) then when you read the next tile you can place it at like 50,0 then 100,0 and make them have a width of 50. At some point then you also want to make the rows start going down so then you reset the x to 0 and increment the y and then continue incrementing the x again.

9kaywun

Quote from: Disastorm on August 15, 2012, 08:13:45 PM
You can just read through the map file and for each entry create a tile in the appropriate location.  For example you can decide to have the first tile at 0,0(with arbitrary z value) then when you read the next tile you can place it at like 50,0 then 100,0 and make them have a width of 50. At some point then you also want to make the rows start going down so then you reset the x to 0 and increment the y and then continue incrementing the x again.

Much appreciated, Disastorm!
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

9kaywun

Realized that creating so many Object3D instances (1 per tile) is not very efficient... Is there another way I can go about rendering this? Such as rendering a plane, and mapping a specific texture to each "tile" in the x/y loop?
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

EgonOlsen

The easiest thing might be to take your already existing tiles and merge into one large object by using Object3D.mergeAll(..). You can't modify them individually after that, of course...

9kaywun

#8
Quote from: EgonOlsen on October 08, 2012, 09:58:57 PM
The easiest thing might be to take your already existing tiles and merge into one large object by using Object3D.mergeAll(..). You can't modify them individually after that, of course...

Rebuild my region constructor.. Having a problem with the region looking like it did before. Not sure what I did wrong though?
Here is a picture to show the issue. Left side is a test app, sharing the renderer with the Game app (right) and using the old/new region systems.
(Image was too wide to use img tags, so here is the url)
http://i.troll.ws/3a10358e.png

and here's the code.. Maybe I am translating tiles wrong??

- removed
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

EgonOlsen

The merging doesn't care about rotations and translation until you make them permanent. Try to add tiles[y].rotateMesh() and tiles[y].translateMesh() in your loop to make them permanent.

9kaywun

Quote from: EgonOlsen on October 08, 2012, 11:29:41 PM
The merging doesn't care about rotations and translation until you make them permanent. Try to add tiles[y].rotateMesh() and tiles[y].translateMesh() in your loop to make them permanent.

That did flatten the tiles in the world space. Now I just have to position them properly on my end of the code.. Thanks, such hasty support is very much appreciated ;)
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..