Game Development Community

Dynamically Combining Multiple Meshes into One Object

by Jack Stone · in Game Design and Creative Issues · 08/20/2015 (11:33 am) · 2 replies

Hello,

I am working on a concept for a large sandbox type open world game. The game will essentially allow the player to build their own tools, weapons, structures, vehicles, and much more, from just the discrete elements provided in the world. These elements will be things like wood, iron, stone, water, etc etc.

I have decided that the best way to implement this functionality would be to allow the player to construct prefabricated shapes from these elements, for example Steel Rod, Steel Tube, Iron Nail, Wood Plank, Wood Sheet, etc.
The user will then combine these very basic elements to construct almost anything.

I had tried simply adding the objects to the world as individual meshes, and then updating the position of each one in C++, but this didn't work for two reasons:

1:
Adding many meshes to the world results in a massive performance (framerate) drop. Even with just a few dozen objects, (all with their own collision boxes)I was having framerate issues. This was with a debug build, but even so, I would need to be able to render a lot more objects than that for this to work.

2:
Moving all of these objects at once does not work. Even when running the position update code in C++, instead of script, the objects would update one at a time, which means with a moving vehicle, the player will see noticeable jitter as the position of every object making up the vehicle update one at a time.

So, clearly, what I need to do is to allow the user to create their vehicle or object by dynamically creating and placing regular static meshes. Then, I need to combine all of those meshes into a single in-game object, so that it can be rendered and updated at once.

The question is, how can I go about doing this? Or, is this even a viable option?

I have read this post:
http://www.garagegames.com/community/forums/viewthread/62021

Which talks about using the wheeled vehicle class, but I am uncertain how to do this dynamically, when the different objects are not known at compile time, and the user is creating the object on the fly.

Has anyone done this?

Thanks!

#1
08/20/2015 (1:07 pm)
I have done something simular with an Airship for my Demo coming out. The actual airship is an invisible box with lots of mount points. The parts that make up the visible airship are mounted You can make up to 3 ShapeBaseImages. These can have animations if needed and are very light on the network. Then you can have numerous shapeBase objects that you can mount. This is what I do for the armor. I have up to 22 pieces at one time per character before counting special mounts and weapons.

Check on how many vertices you have for those objects. I have up to 3 characters with over 20 pieces of armor each, flying creatures and land creatures roaming in the distance, mega structures among hundreds of swaying custom plants and trees without slowdown. Also check the complexity of your collision meshes for vehicles (Should be a simple box). This is the most CPU intensive thing in comparison to all else I have encountered so far and will bog down a system to a near crash at times if the collision mesh is too complex.
#2
08/28/2015 (11:29 am)
Hello, Thanks for your reply.

That seems like an excellent idea, is it possible to mount that many shapes to the airship? I thought I read somewhere that there was a limit that was much less than that. Do you notice any performance issues with what you're doing?

I am not too worried about vertices, they should be fairly simple. In my testing, I was just using simple boxes, and the collision was a simple box as well, so it is curious.

By combining the objects into one, it could be possible to simplify the collision calculations as well, no?