Jump to content

Recommended Posts

Posted

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.

Posted

whichever way you do it you need to set the physics to polymesh ( in model editor and then select model and go into scene panel and make the pysics  scene mode  etc.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

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!

Posted

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

 

 

Posted

Leadwerks doesn't seem to be very good at creating even simpler collision meshes (as per my thread) so I think you'll need to use Marcousik's suggestion and make them in your modeling program yourself.

Edit: just realized that the thread is in the LE5 beta forums though it discusses LE4 so I don't know who will have access.

Posted

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!

  • 2 weeks later...
Posted

Thanks guys, by I figure out the best way to get the goal.

1. Only create model of whole structure

2 Create another version with only basic shapes the use it as physic mesh

3. Create other elements of building as sperated models with their own physic mesh

4. Put them together. Here is the result

 

Posted

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

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted
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

Posted

I always use polymesh option for enterable buildings. I have a huge castle model tht works fine.. interesting though, thanks.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

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!

Posted

This is really interesting and weird... I read somewhere that csg are converted to models after the start function.

I would really enjoy to know why so much fps difference, like where/for what goes/is used this "fps*energy" ?

 

 

Posted

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)

Posted

Yes okay, I understand, so this would mean when using a ray cast with pick(),  the PickInfo.entity:Hide() on this would hide all the 1000 spheres. 

Well should try this, but I am not sure about this.

 

 

Posted
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.

Posted

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 ;)

Posted

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
Posted

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!

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.

×
×
  • Create New...