Jump to content

  • Log In with Google      Sign In   
  • Create Account

Kwizatz

Member Since 07 Apr 2000
Offline Last Active Oct 21 2014 10:53 AM

#5135195 Implementing an Entity Component System in C++

Posted by Kwizatz on 27 February 2014 - 04:03 PM

I am sort of late to this discussion but I am looking on how to implement the pattern myself,

 

Ok thanks for your answers.

 

I have another trouble:

  • My game has maps
  • Maps are made of cells
  • Cells have a position, an ID and a texture.

What should be the components, what should be the entities?

 

I'm pretty sure Map should be an entity, but then:

  • Cell can't be an entity (otherwise I can't use it in my Map entity)
  • Cell can't be a component since it uses other components (Position, ID and Texture).

 

And the same problem goes for a lot of things. Can one use component in other components or did I get it all wrong?

 

From what I've gathered I would say neither of those are entities, they all should be part of a map resource, referenced by a map component that is updated by a map system.

 

To elaborate, your map may be a XML document with cell or tile elements themselves with position (relative to the origin), id and texture (itself a reference to an image, shader and/or material) attributes.

You write some code to convert the XML into a runtime resource object, which is then referenced by a map component, the component is the "instantiation" of your resource, and it will then contain information specific for that instance of the resource, for example position if your map may coexist with multiple maps snapped together.

 

Later on, in your game loop you may have a map system which updates any variables in your map component, and a rendering system may render it later, or a collision system may query the component which itself would query the resource for collision information, etc.




#5028010 creating an editable avatar system like saints row

Posted by Kwizatz on 01 February 2013 - 08:44 PM

You probably want to look for morph target animation, which is what all of the sliders control, then interpolate the fixed character morphs with the ones for face expressions if any.


#5027545 Why won't this compile?

Posted by Kwizatz on 31 January 2013 - 08:28 AM

Yes, that's how it used to be, LoadResource which was a protected method, its a good point, I'll think about changing it to something more descriptive.




#5019664 Get coordinates for a rectangles edges

Posted by Kwizatz on 09 January 2013 - 04:51 PM

You may want to consider using polar coordinates or just store the angle of the ray to calculate the line.

If you just sweep the screen borders, the animation will seem to slow down and speed up because of the difference in ratio between width and height.




#5013193 Bodyfit armor

Posted by Kwizatz on 21 December 2012 - 12:03 PM

Well, why not generate the morphs from the bones offline? you add a new character, adjust the armor bones in your favorite 3d modeling package, and then run some script over the existing armor library to generate the morphs for the new guy offline.

 

I guess the way you're thinking it is fine if you don't mind about the extra runtime computations and the state changes when switching from body skeleton to armor skeleton.

Its not the way I'll do it, but I am the guy who tries to do as much as posible offline to squeze the most performance during runtime, I am the type of guy who sets the compiler for speed rather than size smile.png, your approach won't bring the computer to its knees, and aside from the limitations I mentioned I can't think of any other that stands out, usually you are in the middle of the implementation when they come out, so you'll never know until you start programming.




#5013166 Bodyfit armor

Posted by Kwizatz on 21 December 2012 - 10:13 AM

IMO, Its not bad per se, but it is limiting.

 

For example, the amount/size of uniforms in a vertex shader is somewhat limited, if you want to do skeletal animation on the GPU, you'll find out that you will be constrained to use between 50 and ~64 bones, a humanoid character can easily take that amount depending on how many fingers it has, nodes for the spine, etc. if you have to add bones for armor the amount of bones goes up, which means either do the animation on the CPU or adjust the skeleton (removing non escencial bones from the body) to fit the uniform limitation.

 

Also, what you'll be doing is pretty much the same as a morph, but using a bone to move several vertices at once instead of one at a time, this could limit how well the clothing would envelope the body, whereas with a morph, you'd have a finer control on how the armor envelops and folds on each character type. I may be wrong, but it would seem to me that about the same amount of work would go into tweaking bone values as it would go toward scaling and stretching the armor for a morph, I don't see where you would be getting something for free (IE: done with one piece of armour, done with all of them kind of thing).




#4633657 Good free program for creating 2d sprites?

Posted by Kwizatz on 13 April 2010 - 12:33 PM

The Gimp or Inkscape depending on your style.

You could also use Daz Studio to render 2d images of 3d characters, though most props and characters do have a cost.


#4564046 SceneGraph Implementation

Posted by Kwizatz on 27 November 2009 - 09:43 AM

Quote:
Original post by krum
Quote:
Original post by Kwizatz
Scene Graphs seem like a good idea, but they're not,


I completely disagree with much of Tom Forsyth's arguments against scene graphs. Scene graphs solves all sorts of problems that can not be easily implemented any other way. I wouldn't use them to solve every problem that can be solved with them (like scene culling), they should be an integral part of any general purpose game engine.

If the game engine that I have to use at work had a scene graph, my life would be much easier.


I agree with him because I was seeing all the problems he mentions in my design, a root node with a bazillion children, hacks to get up and down the hierarchy, I use a different system for skeletal animation, so it wasn't like "gun" was a child of "hand" or even "character", I even had a separate array of pointers to the nodes to do collision tests.

In the end, the only use I saw it was serving was for pushing and popping model view matrices for rendering and since all my objects were at level 1 of the tree, I wasn't gaining anything.

Still I just had to use a Scene Graph because that's what all the cool kids use, so I found his post liberating, of course, if you do have good reasons to use one, by all means do so, from my experience, they just add complexity though.


#4098155 Linux/OpenGL/SDL Rendering efficiency question

Posted by Kwizatz on 11 November 2007 - 11:34 AM

Quote:
Original post by md_lasalle
what about the operation of swapping the buffers do you think it would benefit in any way for it to be on its own thread so that you can easily control the rate at which it is being called ?

let's say my target is 60 fps, meaning each frame has 16.7 ms to render, and that my last frame took 4 ms to render, I could make the thread sleep for 12.7 ms before swapping the buffer again.

what is your opinion on this kind of approach ?


Well, what would you be doing for the time you wait for the thread to wake up? probably lock the rendering thread until the other one calls swap buffers, so its really no use.

Rather than play catch up to a target FPS, you should strive for frame rate independent movement, its not that hard, and there are two articles about it right here and here.




PARTNERS