Jump to content

  • Log In with Google      Sign In   
  • Create Account

Underlying structure of a game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 hannesnisula   Members   -  Reputation: 1037

Like
1Likes
Like

Posted 28 April 2011 - 03:37 PM

Hi I'm trying to figure out how to structure my game. My plan is to have objects that consists of several children that could be separated from the parent, like a human losing an arm etc. But my problem seems to be how to do with the meshes. My meshes can consist of several sub meshes and for a humanoid each part needs to be associated with a sub mesh, because my humanoid models are built as such. So how would be a good idea to go about accomplishing this? Should I split the mesh into several meshes consisting of a sub mesh each and associate the limb objects with this or do I associate each limb with a sub mesh?

If I split the full mesh into several other new meshes consisting of one limb each it feels useless to have a sub mesh class since I'd need to split most multiple-submesh-meshes up into their own individual meshes anyway. I also need to associate some objects with meshes (consisting of an arbitrary number of sub meshes) that are not supposed to be split or anything fancy like that.

I don't know if there are some obvious errors with my suggestions or if there's a good solution but I'd like to hear you guys' thoughts on this.

Thanks in advance!

Sponsor:

#2 hannesnisula   Members   -  Reputation: 1037

Like
0Likes
Like

Posted 30 April 2011 - 04:43 AM

bump

#3 Splinter of Chaos   Members   -  Reputation: 239

Like
0Likes
Like

Posted 30 April 2011 - 10:03 AM

Is what you're trying to do anything like this?: http://laserbrainstudios.com/2011/02/image-optimizations/

#4 hannesnisula   Members   -  Reputation: 1037

Like
1Likes
Like

Posted 30 April 2011 - 05:54 PM

Is what you're trying to do anything like this?: http://laserbrainstu...-optimizations/


No, the problem is how the Object class will relate to the Mesh class. I have some requirements I can't seem to fulfill without feeling it's a cheap hack.

- Some objects will logically be treated as a single object though consisting of several meshes/submeshes (like a house with windows and walls etc). So this could be satisfied with an Object class related to a Mesh class in turn consisting of several Submeshes.

- Some other (like humanoids) are supposed to be destructible, as in limbs detached and then treated as individual objects. If I had a Mesh class consisting of a number of Submeshes this could be solved by having each child object of the humanoid connected to a submesh each. But then if it's destroyed how is this handled with the mesh? Would I create a new Mesh instance with a single subset, the submesh it's connected to? And it would also require each child object of the whole humanoid object (the limbs) to be of a special kind to be connected to Submeshes instead of Meshes as in the other cases.

I've only come up with 2 solutions I don't like, which are that every Submesh of every Mesh (as they are created) are really their own Mesh so there would be no Submeshes at all, but this would produce the problem with having an object consisting of several Meshes/Submeshes. The other is that a Mesh consists of a number of Submeshes and if a destructible object with several parts would then create more and more instances of Meshes with a single Submesh (which comes from another Mesh consisting of all related Submeshes) when detached from each other.

How is this generally handled? Is there even a general solution? What are your opinions?

#5 Splinter of Chaos   Members   -  Reputation: 239

Like
0Likes
Like

Posted 01 May 2011 - 01:26 AM

I'm relatively uninformed compared to the other members of this forum, but i have an idea (might be completely useless) and hopefully someone will give you a better one. Posted Image Also, when you said mesh, i thought texture, but i googled and found you probably meant the 3D set of vertices.

I'd think you'd want to draw each submesh as if it was its own object. That way, if a limb gets detached, none of the other limbs/whatever are affected and the affected limb can keep its mesh without modification. Actually, i'd make the class (Human, for example) not worry about the mesh at all, but rather have the class hold a member called body, leftArm, rightArm, etc., and have those handle the meshes/submeshes. Again, this way, if a limb gets detached, no other limb is affected and the detached member wouldn't need modification, except that it would no longer be linked to the body.

The other option you mentioned i'd think would be a lot harder. The basic problem you seem to have is: should i make simple components in a complex system, or a complex system with simple components? I don't know that one is better than the other, but i hope you find an elegant solution with a simple system and simple components.

#6 KulSeran   Members   -  Reputation: 2585

Like
0Likes
Like

Posted 01 May 2011 - 03:52 AM

I would suggest something like the following:
1) build your skinned humanoid mesh as one solid mesh.
2) break up the mesh's index buffers based on materials as usual.
3) Now, separate all the index buffers into your "sub mesh" groups.
4) Next, make new meshes for each "gib" that you want to spawn. These could be skinned meshes of an upper and lower arm, or just pieces of the arm, or both in a recursive fashion.
5) Add in some attachpoint information to your models so that you can specify where on each parrent mesh the appropriate gib spawns from (and what bone).

Now, to draw each human, you render only the index buffers for active meshes on the human. When you shoot off an arm, spawn the new child mesh "gib" (and copy over position / bone information). Then turn off the appropriate sub mesh on the parent. THe "gib", being its own object can now repeat the same process as the human it spawned from, allowing it to break into more pieces.

This approach will let you keep all the proper skinning on a model (as it remains a single mesh), while letting your disable parts of the mesh (by not rendering those index buffers). The severed arm is it's own seperate mesh / object, as it no longer has anything to do with the main model.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS