Represent entity with multiple points

Every book I’ve read about game development explains how to create an entity using a single point in the space that represents its position. This position is then changed using other forces.
If I want to represent a person using multiple points (for example 2 points for the feet, 1 for the center of gravity and 1 for the head) how can I do? Do you know any resources that explain something like that?
N.B. I’m not interested in creating a graphic 3d visualization

I’m not really sure what your question is.

If you want to represent an entity as a collection of multiple points, then you’d just create a data structure that contains those points. Something like this:


class Person{
   Point head;
   Point leftFoot;
   Point rightFoot;
   Point centerOfGravity;
   //etc
}

What have you tried? What exactly are you stuck on? It’s pretty hard to answer general “how do I do this” type questions other than by telling you to try something out and post some code.

It would be nice to know, why do you want to use more then one point.
Usually a entity is represented by a point (its position) and 1 or more shapes, which are then used for collision detection and collision response.
Those shapes usually have a position, which is relative to the position of the entity.

So i woudld like to know, why you want to use more then one position for one entity?

Sorry for not being clear.
My problem is not the java implementation, I need to understand the relation between those points. For example if I have 2 or more points that represents the legs of the person, how those points should change their positions when the person walk or run?

[quote]It would be nice to know, why do you want to use more then one point.
Usually a entity is represented by a point (its position) and 1 or more shapes, which are then used for collision detection and collision response.
Those shapes usually have a position, which is relative to the position of the entity.

So i woudld like to know, why you want to use more then one position for one entity?
[/quote]
I want to create a soccer simulator based on some player skills and team tactics. I was thinking to use more points for having more precision. For example if I want to compute a shot of a player based on the favourite foot how can i do with a single position point? How do I know which foot have made the shot if I have only the position of the player?

Tell me if it’s not enough clear yet

Ah okay, i guess i have understood.
I am not sure, if you need to have different points for those things or if there is a simpler, cleaner solution for your problem,
but i try to help you with the point thing.
The player/entity itself should only have 1 point, which represents its position.
All other points (foot, arm, head etc,) should then be relative to the entitys position.

That means, if your player moves, only its “main position” changes, the foot-point etc. only change, if its foot moves (for example when shooting/running).
The position of the foot point (and all other points) can then be converted to world-coordinates, by simply adding the “main position” to them.

For example the player is in the middle of the soccer-field, its position is P(52.5, 1, 34) in m.
The position of its foot is then (for example) P(-0.3, -1, 0).
The world position of the foor is the P(52.5 - 0.3, 1-1, 34-0) = P(52.2, 0, 34).
Just an example, i hope that helps.

Aiming at something nobody has done before - bravo :slight_smile:
Kevin’s suggestion seems like the most straightforward way to start. Or if that slide-tackles using some framework your using, maybe model the body with each foot etc. as a separate entity - i.e.

class Player {
  Entity leftFoot;
  Entity rightFoot;
  Entity head;
}

I think that what you are asking, is about animation and collision detection. If you want to display an animation, you would have two images (or more) and draw them each for a frame, and you will see it animate. To know which part was collided, use hitboxes.

For, example, see these two images. The first one shows the sprite, and the second one shows the sprite with hitboxes drawn on it.

These hitboxes are just rectangles, which you can use to test on which part the collision took place. What you’d be doing is testing each of the sprite’s rectangles with each of the other sprite’s hitboxes to determine the collision. If any one intersect, you know which part, i.e., which hitbox intersects, and react to the collision.

The solution of Springrbua seems interesting, I can use a single point for the position and then create the others based on this one. The problem however remain, when the position change how the other points change relative to that position?
I’m thinking that there will be too much physics to take care off for implementing it from scratch. Do you know any framework that do something like this?

To be more clear this is in short what I want to do:
I want to simulate a soccer match between two teams, each with 11 players. Each player have different values for its skills.
The simulator shouldn’t create a graphic visualization of the match, it should only create a text file with the positions of the entities (players, etc…) at each frame. I can then use this file for create a 2d or 3d visualization of the match.

Sorry if my english is not very well :-\

[quote=“raxell,post:8,topic:52041”]
Are you trying to do this in 3D or 2D?

The basics are just basic trigonometry: if you know the body position, the angle of the leg, and the upper-leg length, then you can figure out where the knee should be. Then if you know the angle of the knee and the lower-leg length, you can find the location of the foot.

But, imho, this approach is overkill for what you want to do. Just figuring out where the legs should be is going to be hard enough, then to have that interact with the world, then to try to make that interaction realistic? That’s probably not the approach you should take. For proof, try playing QWOP.

Instead, you should probably try to simplify the interaction: do you really need the legs to interact with the world? Or do you just need them to animate realistically, and then use hit boxes to detect collisions?

You could also try a physics engine like JBox2D, but I highly doubt your complicated approach is going to work the way you’re hoping it will.

Either way, good luck.