Jump to content

Map Building Design


tipforeveryone
 Share

Recommended Posts

I have a plan to put a building into game, I wonder which is the best way to do that, I thinkabout some solutions but doubt about physics performance as well

1. Import a whole building model in blender (rooms, walls, stairs, roof etc), then create a physic mesh to apply to it. my character will move around inside the building with its physic mesh.

image.png.bfb9f70ec0d1714a03cc12e2bb4d4a28.pngimage.png.67299b4246807efd0e35543a9bc9f5e7.png

2. Create each elements of building in blender (stairs, walls, columns, roof as sperated meshes), import into game, reposition those elements to construct whole building, each element has it own physic mesh

3. Import whole building model then use premitive shape to construct the building's physic. I will assign invisible material on those shapes to hide them later.

Link to comment
Share on other sites

Your physics mesh will be very high poly as it does 2 triangles per rectangle face. I would guess this would be expensive, but I'm interested in how it works out. 

The correct way to do this would be to make the gameplay walls/floors out of brushes and do the roof, railings and such as models. But with vsync enabled/low frame rate, brushes will pop in upon spinning the camera. If your plan doesn't work out, I suggest you make your building layout with brushes, and force disable vsync. Forcing a frame rate via the graphics driver (like what you have to do with Nivdia Linux drivers) produces better results anyway.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

I can remember I had this problem: if the building is too complex, the poly mesh could be correctly generated but not entirely be saved by the engine, and that's why I had to use your solution described under (2). But if the house is not too complex, it should be ok with using (1)

Other solution is to build your own collision shape with a mesh named "collision" that will be recognized as such by the engine - I do not know exactly how to proceed but this should be best solution because it minimizes cost I think. That will be used on the Leadwerks  tree to build a simple box shape on the trunk, without shaping the leaf

  • Like 1

 

 

Link to comment
Share on other sites

If you export a model with it's collision mesh as a child, you'll run into issues if you give the model mass. Plus the final result like looks sloppy to me.

I personally like to collapse all my static models upon importing. This might also help performance, but I'm not 100% on that.

  • Like 1

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

  • 2 weeks later...
8 hours ago, cassius said:

I don't understand. Why create basic shapes when there are physics options in the model editor. Or am I missing something?

The automatic physics options don't work very well for most shapes and certainly not for complex ones.  Even something relatively simple like the scene below (a single FBX), the various options either overdo it or give horrible results.  The final one is convex decomposition with the maximum (6) iterations.

scene_polymesh.jpg.663ace6986c68b7d9221b

scene_convex_hull.jpg.d5c1fc2f8aefc42a35

convexdecompisition_6iterations.jpg.4711

Link to comment
Share on other sites

Test screenshots on my system: Intel i5 7600k and a AMD RX 480.

1000 sphere brushes (400-500fps!)

image.thumb.png.5de350c6e69b0ff57414e283cb608be8.png

Here's the app drawing 1000 boxes that are models. (108 polys per model; 250 - 280fps)

image.thumb.png.4644e7a8e3ee1fa03ac2c7c7e78fc329.png

It should be noted that the sphere example took really long to load, but the end result is basically free geometry. We are told in other engines that brushes are expensive and should be replaced with models before you ship. However, in Leadwerks 4, the opposite is true - Models are more of a cost than brushes. The issue is that we have no vertex tool so we are limited with building things with simple shapes.

There is also a nasty rotation issue with faces in which the editor will auto apply the rotation of 0 upon loading a map. I've reported this, but it's not something Josh can't really track without knowing what's causing it.

So in-conclusion, I see that you should be using collapsed brushes (brushes without scripts) for buildings. Just disable vsync to prevent the walls popping in/out and you should be set.

With the upcoming engine, this shouldn't be an issue, and hopefully there will be a vertex tool for brushes in the new editor.

  • Like 3
  • Thanks 1

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

The difference comes from the fact that the entire thing is collapsed to just a single model. This means that every piece of code, which iterates over all instances only walks over this object once instead of 1000 times. Also there is only one transformation matrix which is getting updated and pushed back and forth from CPU to GPU and which takes much less space (which can be used for caching again)

Link to comment
Share on other sites

2 hours ago, Ma-Shell said:

The difference comes from the fact that the entire thing is collapsed to just a single model. This means that every piece of code, which iterates over all instances only walks over this object once instead of 1000 times. Also there is only one transformation matrix which is getting updated and pushed back and forth from CPU to GPU and which takes much less space (which can be used for caching again)

Does this mean that if reepblue combined all of those boxes into a single mesh that it would be the same speed?  Because that's probably how you would want to export the house in the original post anyway.

Link to comment
Share on other sites

I suppose, that would be the case. There might be some other optimizations for brushes (e.g. if you want to have a sphere, you can simply transfer the center and the radius to the GPU instead of multiple vertices and again save some bandwidth and RAM real estate) but I believe that these differences would be only minor. I should say though, that I have never done any comparison nor do I have any specific knowledge of how this is implemented. Everything I'm saying about that topic is just derived from things I gathered in different forum posts here over the years and using my own logic ;)

Link to comment
Share on other sites

My concern is the collision mesh and how many buildings you want. If every building was its own model with it's own shape, you'll most likely get the same performance as The Zone. (40fps on my system)

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

I had to try this myself.  I added textures but the results were what you would expect:

Brushes:

brushes.thumb.jpg.b5975ae7fa22b8b53c28d6b75d1f6345.jpg

Models:

models.thumb.jpg.8526fc2d1f32e01bd1ad8433a3a6ae40.jpg

I then combined all boxes into 1 mesh and all collision boxes into 1 collisionmesh in 3DS Max and exported it.  The speed was again good:

1625472919_modelscombined.thumb.jpg.c83429cb262ed7bd31aa8e6c227e16c9.jpg

I think the lesson is that limbs slow Leadwerks down a lot and yet individual brushes don't.

  • Like 3
Link to comment
Share on other sites

Yeah, figured much. Issue is that it may not be possible or ideal to collapse all your models into one for a real game. I guess when it comes to detailing, you need to find out what chunks you're allowed to combine.

Again, the new engine makes this issue go away, but I really wish that a group feature was implemented to auto merge your models for you so you didn't have to do each combination yourself.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...