Jump to content


Photo

Help with 3d walls


  • Please log in to reply
5 replies to this topic

#1 kakaru19

kakaru19

    GMC Member

  • GMC Member
  • 13 posts

Posted 14 May 2012 - 12:04 PM

Hi GMC, I been trying to do a ''cube' terrain system similar to minecraft for some days without any satisfactory results. First I made a program that serves as a ''2D map editor''

http://www.freeimagehosting.net/kg81r

Using instances in each cell with height variations, and identifying where it needs to be drawn a cliff, then i convert all that information on a list and save it. The ''real'' programs load the map info using that file, my first attempt was creating instances just like the editor, but having a room divided into 29x29 cells, hypothetically would take 900 instances to fill the whole room, even without having to fill all the cells, using a small map of less than half of the room it was creating nearly 280 instances. On the other hand visually, the result was what I expected.

http://www.freeimagehosting.net/2ni18

But assuming that too many instances could affect the game in the future, I decided to use tiles as they are drawn only once, and you can give them different heights using its depth, but the problem of using them is that there is no way to draw the cliffs, at least not with tiles.

http://www.freeimagehosting.net/smoq3

Right now I'm trying to find an efficient way to achieve this. Any suggestions? or should I resign myself using instances

Sorry for my bad English. Kakaru
  • 0

#2 RevenantGhost

RevenantGhost

    GMC Member

  • GMC Member
  • 106 posts
  • Version:GM8

Posted 14 May 2012 - 01:31 PM

You could draw all the blocks from a single instance, and if the terrain dont need to be destructable you can create a model and draw it, drawing every shape takes way too much time and you will have 1fps even if you have a computer with alien technology, contrarily drawing a single model, even if giant, doesn't make any problem specially with GM 8.0 or GM 8.1.
If you want it to be destructable, you have 2 ways: drawing all the terrain or a terrain cell from a single model and when you add/remove a block it re-makes the model, anyway that's possible only if the models are small (meant as polygons, size dont make any difference), if the models are too big you will have the game freezing for some seconds as soon as you modify the terrain.
The other way is making many instances, but for the reason i said before you need to "merge" (dont know the exact word, im not english) the blocks, doing like if there's 4 blocks you should't have 4 1x1x1 instances, but a single 2x2x2 instance, same with 3x3x3, 4x4x4, and so on.. This way you will use the minimum possible amount of instances to draw your terrain.

Anyway remember this:
GM + voxels = Not a good idea.
  • 0

#3 kakaru19

kakaru19

    GMC Member

  • GMC Member
  • 13 posts

Posted 14 May 2012 - 02:37 PM

Thank you RevenantGhost, drawing all the blocks from a single instance or drawing them on differents instances I think it would be just as wasteful, cause i need to draw on every step the same lines of code (assuming that the instance do absolutely nothing else) but I can be wrong in this.

I do not plan to make destructible terrain, so the giant complex model seems to be the only solution here, the only problem is that I never worked with primitive before, guess I could get a list of points to generate the vertices using the information of the map file, but I have no idea how to convert those vertices into filled surfaces, nor how to add the textures correctly! Could you please advise me how to assemble the model having the height information in each cell?

thanks again!
Kakaru
  • 0

#4 RevenantGhost

RevenantGhost

    GMC Member

  • GMC Member
  • 106 posts
  • Version:GM8

Posted 14 May 2012 - 02:48 PM

You dont have to use primitives if evrything is made of blocks, just use d3d_model_block instead of d3d_draw_block, make a single model or multiple models (depending on map size if you want some kind of mip-mapping or to remove map parts out of the field of view) and draw them.
If you dont know how to make a model is:
modelvariable = d3d_model_create();
d3d_model_block(modelvariable,blablablablabla);
As blablabla put the arguments you need.

Adding textures actually is the biggest problem because you cant use many textures but only a single 1, you should uv-map your model, thing that im ABSOLUTELY not able to, for sure someone out here can help you with that. :tongue:

And for the height informations just use a 2d array e.g. myarray[0,0] set as first number the x and as second the y, then give it the value of the z in that position, i did the same with the terrain of my game and it works perfectly.

Edited by RevenantGhost, 14 May 2012 - 02:50 PM.

  • 0

#5 kakaru19

kakaru19

    GMC Member

  • GMC Member
  • 13 posts

Posted 14 May 2012 - 03:11 PM

Yes, I am currently using one array to easily locate the height of each cell, no problem with that. I'm reading in the manual that models like the tiles are drawn only once so just to be sure I understood you well, replace each instance with a block model will be much more efficient right? being so I will try to use the blocks and learn to apply textures to them.

Thank you RevenantGhost
Kakaru
  • 0

#6 RevenantGhost

RevenantGhost

    GMC Member

  • GMC Member
  • 106 posts
  • Version:GM8

Posted 14 May 2012 - 03:33 PM

Yes, I am currently using one array to easily locate the height of each cell, no problem with that. I'm reading in the manual that models like the tiles are drawn only once so just to be sure I understood you well, replace each instance with a block model will be much more efficient right? being so I will try to use the blocks and learn to apply textures to them.

Thank you RevenantGhost
Kakaru

it will be more efficient, but will be even more efficient if you put all the blocks into a single model or into some models to make a kind of grid.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users