Author
Topic: Raven's projects (Read 24937 times)

For the past week I've been experimenting with jPCT (very happy with it, actually, I'm very amazed that there aren't more people using it! Why is that??). I wanted to share with you some of my concerns regarding a system architecture for an FP(S) platform (I'd like it to be more than just a shooter (hence the parenthesis).

My end-goal is to create a first-person game, but since I haven't quite decided the game's nature/theme I'd like to begin with creating a general platform for it (that I could perhapse release under GPL for others to experiment with).

Currently I'm wondering about the following things:

1. Levels My current architecture introduces levels as classes, for each level there is a class with the same name. The level class would store vital information like the players starting position in that level, lighting positions, etc... However, the problem is that that's a lot of information to hand sort, object positions, decorations, etc..

A partial solution to this problem would be having a certain type of signal in the level designs as pointers for a "LevelManager" which would place objects.

For example: a sphere with the texture named "PlayerPos" is actually a pointer for where the Player Starting Position should be. Levelmanager would read these pointers, and use their position to automatically instantiate and place the right types of objects, etc.. (then delete them from the world)

Theoretically, this would be possible with jPCT, yes?

2. Segmented character/player bodies

Multi-part humanoids. For an FPS game, it'd be really nice to have arms, torso, head and feet all separate objects capable of being damaged independently. However that would pose many problems: Animations for each part would have to be animated seperately and initiated at the same time when something happens to the humanoid. So it would be very hard to animate these parts independantly from eachother while the end result is supposed to act as a whole.

Can anyone think of a good way to implement a segmented-body ? There's also the question of computation, will segmented humanoids be too much for jPCT to handle?

I also noticed in another thread that Egon/Helge has been questioned before about skeletal-character physics like Half-Life uses. At the time there was no plan to implement that kind of feature. That hasn't by any chance changed, has it?

3. Saving

My current thoughts on saving are by simply making the Level class, Stats class (Contains historical info about the gameplay) and Player class serializable. When continued you would simply load the classes.

A partial solution to this problem would be having a certain type of signal in the level designs as pointers for a "LevelManager" which would place objects....Theoretically, this would be possible with jPCT, yes?

Yes. But i would use the name of the object, not it's texture. jPCT creates names for objects loaded from 3ds that start with the name the object has in 3ds. You may check for this name and don't merge the placeholder object to the level but replace it with the item instead.

Quote from: "Raven"

Can anyone think of a good way to implement a segmented-body ? There's also the question of computation, will segmented humanoids be too much for jPCT to handle?

Not too much to handle, but difficult to implement. It should be possible to code such a thing using IVertexControllers....but it sounds quite hard to do to me.

Quote from: "Raven"

I also noticed in another thread that Egon/Helge has been questioned before about skeletal-character physics like Half-Life uses. At the time there was no plan to implement that kind of feature. That hasn't by any chance changed, has it?

The point is, that i can only do so much. Doing a good skeletal animation system is a little project of its own. To be honest, i hoped for somebody to write one on top of jPCT, releasing it to the public and letting me integrate it into the engine's core to squeeze out some additional performance...but that didn''t happen until now :wink:To be honest, i don't recommend starting with a goal as high as this animation system because chances are that you'll never finish it. But that's just me.

Quote from: "Raven"

My current thoughts on saving are by simply making the Level class, Stats class (Contains historical info about the gameplay) and Player class serializable. When continued you would simply load the classes.

Sounds a bit brute to me, but that's all I can think of.

Don't know, should work well enough if space and/or loading times aren't important.

Yes. But i would use the name of the object, not it's texture. jPCT creates names for objects loaded from 3ds that start with the name the object has in 3ds. You may check for this name and don't merge the placeholder object to the level but replace it with the item instead.

Ah, I didn't know that. That's great! It'll make mapmaking a lot easier. Yeah, replacing the object is what I had envisioned.

Quote from: "EgonOlsen"

Not too much to handle, but difficult to implement. It should be possible to code such a thing using IVertexControllers....but it sounds quite hard to do to me.

Ach, that's too bad. At this point I don't think I dare venture into IVertexControllers. I'd rather get a working demo first. But thanks for clarifying this for me.

Quote from: "EgonOlsen"

The point is, that i can only do so much. Doing a good skeletal animation system is a little project of its own. To be honest, i hoped for somebody to write one on top of jPCT, releasing it to the public and letting me integrate it into the engine's core to squeeze out some additional performance...but that didn''t happen until now :wink:To be honest, i don't recommend starting with a goal as high as this animation system because chances are that you'll never finish it. But that's just me.

I usually try and set my goals high to begin with and then tone them down as time progresses. Thanks for being honest - I was hoping someone would have a "magic solution" for accomplishing this, but given the options I won't attempt create it (Well, not yet at least :wink: ).

I have an idea though of how to accomplish "damage" to different bodyparts; simply creating invisible 3x3x3 cube around the characters. When a character would receive damage, the cubes register where the "inflictor" came from. For example, if a projectile hits a character in the chest, it must have passed through the middle cube -- this way we know a bit more than just that the character was hit. However, I'm unsure what kind of invisibility would be required, since I gather that invisible objects aren't processed? Maybe a dummy object cube?

EDIT: Actually, just a simple row of invisible cubes would be an improvement. One cube around the legs, one in the middle and one for the head. At least a lot simpler to implement.

It should be possible to get what you want easier IMHO. I think that you can use polygon IDs for this. For each model in question, you may determine which polygons belong to which body part. Using the PolygonManager on an untransformed/-translated object you can get the vertex coordinates in object space...and it may be possible to say that (for example) everything below y=-10 is the head, between 10 and -10 is the chest etc...that may work on most models well enough. Store this list and use a CollisionListener to get the ID of the polygon that has been hit by the collision, search your list for it and voila, you have your body part. Just an idea...If you follow the "boxes"-approach, they don't have to be invisible all the time, just during rendering. That's what Paradroidz does to calculate collisions against a sphere even if the droids are usually none. When rendering, the droids are visible and the spheres are invisible. When doing the collision check, the spheres will become visible and invisible again after collision detection has finished. But i would head for the polygon ID way instead...should be easier and works better if you manage to assign polygons to body parts in some way.

Or write yourself a GameEvent and a GameEventListener. Make the door a GameEventListener, register it on each button in question and let the button fire a GameEvent(<pressed>) to all its listeners when pressed.

public final static GameEvent BUTTON_PRESSED=new GameEvent(0); public final static GameEvent BUTTON_RELEASED=new GameEvent(1); public final static GameEvent ANOTHER_EVENT=new GameEvent(3); public final static GameEvent WHATEVER=new GameEvent(4);

Thank you both, Helge and rolz -- I combined both of your ideas keeping the object3D seperate in a GameObject class wich emplements a GameEventListener. It worked like a charm, and gave me much clearer view of how to puzzle all my smaller bits together that I've been experimenting with since I starting working with jPCT.

I have another question though that is perhapse not justifyable on these forums due to the fact that it derives from my inexperience working with full scale applications and especially 3d rendering.

But well, here it goes: I'm trying to get a grip on how I'll manage the animations that follow triggering, for example, a door object. I implemented the door triggering event where the Door(Object3D) was an md2 file with an "Opening" animation. Of course, the opening animation itself was carried out in the Door object and was therefore not in consistency with the frames in the main game. To explain: initiating the door opening animation caused the animation itself too be drawn too fast for the player to see.

In the official jPCT examples, this is solved by calling doMovement() once every loop in the main gameloop, hence the animations are always consisent with the main thread.

So what I'm currently thinking is to have a GameEventManager, which would keep a listing of all GameObjects as well as an AnimationQueue: a Hashlist that contains all the objects that require animating in the next iteration of the main game loop.

The main gameloop would therefore look something like this, with the addition of soundManager:

while (!quit) {player.doMovement();GameEventManager.animationQueue(); // If there is something that requires animationSoundManager.playSounds(GameEventManager.soundQueue()); // Play any sounds that the gameEvents emit}}

So, to sum up, my question basically is: is this the way to go? Or is there some other method that's better when making 3D games? For example, should I be looking into threading each type of manager so it runs independantly?

For example, should I be looking into threading each type of manager so it runs independantly?

I'm quite busy ATM, so the short answer to this is: NOOOOO! :wink: Don't let another thread than your main thread manipulate your game entities (at least not as long as it affects jPCT related stuff). It may happen at any time, even when jPCT is rendering them and that will cause all kinds of wierdness which are a pain to debug. Trust me...been there, done that...Don't manipulate the Camera, the World, an Object3D etc. from inside another thread. Don't do it. Never! jPCT has a kind of locking implemented (has to be enable explicitly) to make it pseudo-threadsave, but that dates back to the times where i thought that i might be a good idea. It isn't...

Edit: Here's a short code snippet from Paradroidz' main loop. Looks similar to your approach. That doesn't mean that it's the only way to go, but it works for me.

So, to sum up, my question basically is: is this the way to go? Or is there some other method that's better when making 3D games? For example, should I be looking into threading each type of manager so it runs independantly?

as a rule of thumb, you should avoid threading whenever you can. it only complicates things and cost some performance (due to syncronization and context switching overhead). use threading where you have to do so (for example when use blocking i/o)

in karga, to simplify things, i targeted a constant fps. even collision detection and other non-render stuff doesnt cost much compared to rendering, so if i cannot reach targeted fps, i simply skip rendering for some frames and update the game state only. this method depends on measuring render time, something like this:

if (elapsedTime < expectedElapsedTime) { // sleep here for some time } else { // do some gameUpdate without render }}

with this approach, even on a slow machine updates stay closer to high targeted fps (50 for instance) so you can decide animation indexes etc depending on targeted fps

instead of controling animations and other things (movements etc) from a central location i've also defined a FrameListener interface which lots of my 3d objects implement. so they can 'take care of themselves'

instead of controling animations and other things (movements etc) from a central location i've also defined a FrameListener interface which lots of my 3d objects implement. so they can 'take care of themselves'

Yep, i'm doing it in a similar way. It's just that i have no common listener interface for that but "managers" on top of each entity-class that hold the references to all entities of a type and forces them to update/move/hide...whatever is needed. My timing works different. I'm measuring the time that has passed since the last frame in "ticks". A "tick" in Paradroidz is a 200th of a second IIRC. All my methods take these ticks as a parameter and act accordingly. For example: If i move an entity x units forward for one tick, i move it 8*x units forward if 8 ticks has passed since the last call. This has two drawbacks you have to be aware of:

1. all your algorithms have to be "tick"-able, which causes some extra work from time to time.

2. time taken in collision detection correlates with the length of the translation vector. This can cause the following: Game needs 2 ticks to update all entities, collision detection is called with 2 ticks, needs 1 tick itself due to that. So, you have 3 ticks for the next frame, call collision detection with 3 ticks, which now needs 2 ticks to complete and so on...that will result in a seconds per frame display over time. To avoid that, i'm limiting ticks to a max amount. If it superceeds this value, the game will simply slow down (i theory...it never happened for Paradroidz because collision detection is too fast)