Tile based game: mesh generation

Hey.



I’m working on a tile based game and I’m using quads as faces for the cube shaped tiles, but I’ve come across a slight issue on performance here, loading times to be precise. I’m currently cloning a dummy cube for all the seperate cubes on the scenegraph which proves to be rather time consuming on startup, I was wondering if there is a better way to use the same mesh but in different coordinates at the same time, without the use of cloning. Being unable to have the same spatial in different nodes at once, I’m pretty much out of ideas, seeing that I’m new to JME.



Any help on the matter would be appreciated.

Box worlds are not made out of boxes, search the forum for “voxels”. If you haven’t done any mesh / 3d programming before you’re in for a tough ride.

haha it’s like 20 topics about it, there should be “Quick Help” about it :roll:

Also, I always feel the need to point this out because it seems counter-intuitive: box worlds are the HARDEST type of game to make, not the easiest.



If batching the geometry into one mesh didn’t already occur to you as a solution right away then this is probably too hard of a place to start when making a 3D game.

I haven’t even mentioned the word “box” in my post a single time!

I said I was using QUADS…

I’ll admit I haven’t looked up on voxels yet properly, but as far as I know, they’re just a single-colored volumetrix pixel, and I’m planning to use textured surfaces, which doesn’t really fit together. I may be wrong though, I will look it up in time. (It is also important for each side of the blocks to have different textures!)



My game concept explicitly requires the usage of blocks (if not for the static geometry) as it is supposed to be a puzzle game. I wasn’t picking blocks just because it seemed easiest!

And I am already merging together static geometry to optimize… also culling the temporarily-hidden faces of blocks.



In my post I clearly stated the issue I had was with LOADING TIMES, not actual reduced framerate ingame. I said I was cloning the geometry of a sample cube into each cube in the map, because there is not a way to include the same geometry multiple times in the scene graph that I know of. This is what’s making my game take a bit more time than optimal to initialize, and this is what I need help with, because I want to create ONE mesh to use for ALL the blocks, instead of creating a mesh for every single block in the map.



I haven’t been taken for a complete idiot in such a way before…

I’m not taking you for a complete idiot… but 99% of the folks who stumble in with batching problems are trying to make a box world like Minecraft because they think the simpler graphics means that it’s simpler to program.



In your case, why not just use one Box and make multiple Geometry objects? I see no reason to clone it.

@pspeed said:
I'm not taking you for a complete idiot... but 99% of the folks who stumble in with batching problems are trying to make a box world like Minecraft because they think the simpler graphics means that it's simpler to program.

In your case, why not just use one Box and make multiple Geometry objects? I see no reason to clone it.


Edit: I meant Quad not Box... it's the mesh to the geometry. And you can reuse a mesh as much as you want.

Also, how many quads are you creating? If loading times are really bogging you down then it sounds like there may be a lot of them.

Well you can just make a mesh, and do several geometrys out of that. thats what you looking for ?

(also for some reason your post looks like a boxworld one, I wanted to reply something similar like the others, untill i read your clarification. )

And for the record…

@dancso said:
I haven't even mentioned the word "box" in my post a single time!


@dancso said:
I'm using quads as faces for the cube shaped tiles


We aren't complete idiots either.

Quads as faces of cube shaped tiles is almost precisely how one would make a box world. box = cube

You could probably do this using one custom mesh for all your tiles and animating the mesh to move the tiles around. Then you just need a single object to create the mesh in one go and move the things within it as required.

Even if you don’t do a box world the problem is the same: You have lots of single objects which is suboptimal (as said in our “best practices” and “improve performance” docs) and you will need to create the mesh in a custom way. All posts dealing with “voxels” will help you, if you do actual boxes or not. The manual says you shouldn’t use lots of objects in various locations. Nobody took you for an idiot, we just felt we have to give you this very basic information as you didn’t seem aware of it.

I may be creating a few thousand quads at once, but that’s probably as far as I would go with it.

I frowned at the box word because as you know, there’s a primitive called “box”, which cannot be individually textured on faces, nor culled, and it all seemed like you took me for the randomly appearing newbie who thinks he’s gonna change the world with his minecraft clone but doesn’t actually know a single thing about programming. (I admit the “taken for a complete idiot” thing was exxagerated) It’s the feeling of being prejudiced for dealing with a commonly brought up topic by newbies that estranged me.



How was I appearing unaware of basic information like going for a box world is not a newbie friendly way to go? It was completely unrelated to the topic. As was telling me to merge geometry together… My question was whether there was a better way to draw many blocks without cloning quads for each of them, wasting loading time and memory. Simply saying I might want to use voxels instead of quads would have been enough. Especially since it also serves as a solution to my problem to begin with, and more.

I’m sorry for the tempered reply earlier, I felt a little offended there…



I have somewhat looked up voxels now, and so I was wrong about them after all. I’ll probably end up using them, it was already bugging me that combining the quads (and thus vertices that overlapped eachother) didn’t quite merge the way voxels do. I’ve been running a few stress tests, and it seemed to run well on my old potato, except when shadows and dynamic lights were combined. I guess there’s always reason to optimize further, so I shall do as much as I can.

Thanks for pointing me in the right direction after all.

Okay, happy to see that you seem to be on the right track now. I will explain to you why I/we instantly judged your level of experience and what information you need to properly do what you want to do. Mind that this is not meant as an insult, just as the initial comments weren’t!



You will have to work on the mesh level for achieving what you want, still you were working with single objects. You can texture faces of a box using UV coordinates, still you seem to take it like each part that looks different needs a different material. Single objects do not perform well as each uses an instance of the shader with its material, you didn’t seem to see this connection. This is the “3d knowledge” and “read the documentation on best practices” part. The posts in the forum that you get as result for looking for “voxels” will give you all the information to do what you want to if you either have the 3d knowledge or read our documentation thoroughly.



Our documentation is made for people that do not have any 3d experience as well and we put many hours into writing it, thus we allow ourselves to just answer briefly if most of the topics are covered in detail by us in the docs.

1 Like

I have discovered the importance of texture atlases recently, but I wasn’t using them yet because I hadn’t touched my jME project for quite a while before making this topic.

I’ve been using this following function from way earlier, but I could not remember what it was called, so all I knew it was doing some merging on the static map geometry.

[java]GeometryBatchFactory.optimize(Node);[/java]

Having understood the example code here, it proved to be the solution to my problem, as before I was first constructing all the seperate parts and then merged them instead of just building them together as a whole from the beginning.

I did indeed not have a proper insight about how meshes are built up, so I didn’t naturally think that manually creating the polygons was a good idea.

Only pointing this out in case someone else in need of help stumbles upon this thread.



After a lot of research, I have finally understood what voxels really are, and I am glad to realize that I’ve been actually using the same system for a long time! In example: (old 2D experiment of mine with placeholder graphics)



I’m sorry again for getting unreasonably infuriated, I know how annoying it can be to deal with repetitive issues on forums… guess it caught me at a bad time.

1 Like