Author Topic: tile system?  (Read 2183 times)

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
tile system?
« on: August 14, 2012, 01:06:49 pm »
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..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: tile system?
« Reply #1 on: August 14, 2012, 03:02:47 pm »
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?

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: tile system?
« Reply #2 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?

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: tile system?
« Reply #3 on: August 15, 2012, 07:38:27 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..

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: tile system?
« Reply #4 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.

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: tile system?
« Reply #5 on: August 15, 2012, 08:47:16 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..

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: tile system?
« Reply #6 on: October 08, 2012, 09:52:57 pm »
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..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: tile system?
« Reply #7 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...

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: tile system?
« Reply #8 on: October 08, 2012, 11:25:11 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??
Code: [Select]
- removed
« Last Edit: October 09, 2012, 12:32:25 am by DHAReauxK »
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: tile system?
« Reply #9 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.

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: tile system?
« Reply #10 on: October 08, 2012, 11:33:35 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..