3d animation in lwjgl? how? or better 2d?

Started by Greenleon, September 18, 2008, 18:51:42

Previous topic - Next topic

Greenleon

Hello,

I am new here, as you can see. We started to write a multiplayer jump and run game in Java and tribbed over lwjgl. Actually we focus on the server stuff, player management and network stuff. But shortly we will have to start the display-coding.

We have to ask ourselves if we want to do it 3d or 2d. None of us has experience in this area, so I am asking you.
What we need is player-animations. It would not be to hard to write it 2d, I guess. But what about 3d. I would prefer 3d, because of .. better looking ;).
But are there even methods in lwjgl to do 3d animations?

Leon

irongiant

I'm not quite answering your question but this may help...

JME is a 3D engine: http://www.jmonkeyengine.com/

Slick is a 2D engine: http://slick.cokeandcode.com/

Both are based on LWJGL.

Evil-Devil

Animations in 3D can be done in two ways. Vertexbased animations or skeletal animations. Both of them requires a lot of work but the skeletal animation gives you way more free room and you won't be limited to your predefined animations.

Greenleon

First - thanks!

We want to put our efforts in gameplay, not so much in the animation coding. I hoped there is already an abstract system implemented in lwjgl. On the other hand we are not looking for a complete engine. All we need, is a bunch of code, that manages the animation.
Animation btw. You mentioned skeletal and vertexbased. Can you explain the difference. I understand skeletal animations but I never heard of vertex based.

jME is a bit 2 big for us... as I said, we just need animation methods. We can handle the terrain on our own - I hope.

wolf_m

Quote from: Greenleon on September 19, 2008, 14:51:53
jME is a bit 2 big for us... as I said, we just need animation methods. We can handle the terrain on our own - I hope.
The question is what you want to do in detail. Do you want to build trivial animation loops per animated meshgroup with a 3D modeling suite and import that into your engine to trigger it when necessary? Like keyframe animations based on bezier curves with static meshes (rotations, scaling, translations)? Or do you want per-vertex deforming dependant on associated bones influence as well?

The first is easy to implement by yourself if you've got basic display code, the second is hard to implement. The second is called skeletal animation. Pointer:
http://en.wikipedia.org/wiki/Skeletal_animation

Please refine your request.

Greenleon

I do not think we need skeletal animation. But if we chose the 3d way, we would definitely need the option to import models from blender or whatever.
The gameplay is 2d-style -> we  only need x and y... But it would be smart if the models look a bit voluminously.
I have to admit, that I do not really understand the techniques you are describing ;) but as far as I understand, the first one is enough for us, with a couple of pre-definded animations (in a format, that can be generated from a common 3d modeling suite) that we can trigger ingame. I have absolutely no experiences in that area but we hope we will find an animator when our project advances.

You say it is not too hard to code that?

wolf_m

If it's a 2D game, I'd suggest prerendering your animations in Blender with an alpha-channel for transparency.
In your game, you then use the rendered frames as in classical animation.
So that means that each frame, you reference the texture onto a quad according to which frame you are in in your character animation.

That would mean you wouldn't have to import anything and there would be no detail limit to your models (apart from resolution, of course).
The disadvantage of that technique is that seemingly 3D dynamic lighting would require you to implement normal mapping and make normal maps for your renders, again per frame.
It's by far the easiest method to animate stuff in realtime.

Do you understand what I'm saying?

The method I described above is a bit overpowered for 2D games, I'd say.

Greenleon

I mostly understood. ;)
What I do not really like about your Idea is that , afaiu your method limits our possibilities for effects a bit. What we want to add (later in development) are 3d-like effects. I am thinking about small camera-pans if you change direction and probably splatter-effects (no humans) xD. The cam pans are almost impossble if we go 2d.

Can you reckon how much work it is to code a simple 3d display-method with animations. Or where to get such a method, we can slighly alter and then use.

wolf_m

Quote from: Greenleon on September 19, 2008, 18:04:50
I mostly understood. ;)
What I do not really like about your Idea is that , afaiu your method limits our possibilities for effects a bit. What we want to add (later in development) are 3d-like effects. I am thinking about small camera-pans if you change direction and probably splatter-effects (no humans) xD. The cam pans are almost impossble if we go 2d.

Can you reckon how much work it is to code a simple 3d display-method with animations. Or where to get such a method, we can slighly alter and then use.
Making a 3D game happen means implementing a camera, realizing texture mapping onto polygon soups, coding the lighting and additional effects like environment mapping or shadows, building a reasonable physics system, in your case adding a keyframe animations system, thus implementing bezier curves and possibly doing animation blending so that going into a new animation happens smoothly, coding the importer.. And all the stuff I forgot, of course.

It's not something that codes itself, but it's not hard at all. Many of the topics are "solved", so you just have to do research, meaning reading papers, howtos etc.
A problem is that such a codebase can get rather large and complicated, so you would have to design ahead.
And there are already engines out there that can do it all for you, you just have to read the manuals and code accordingly; see above.

As for material on animation, I recommend browsing gamedev.net, checking out wikipedia, figuring out how Blender does it and writing prototypes.

There are diverse pitfalls for beginners, like rotations, optimizations, synchronization of events, designing metastructures, .. I can't spell everything out for you. Engine development is a rather large topic.

What I can tell you in any case that 3D animation isn't just a matter of a chunk of code. To integrate animation into an engine, you have to design everything for it.
After all, it consumes memory, uses computing cycles, gives you events to handle, should react on events, is asynchronous in one regard and synchronous in the other... Blablabla. It's an integrated system, so it's not trivial in any case.

The animation system I told you about above does things in the following way:
In a frame
For each animated mesh
Is current mesh animation frame a keyframe?
Yes: Copy rotation, location, scale from keyframe to mesh
No: Interpolate rotation, location, scale from previous and next keyframe via bezier curves, linearly or whatever floats your boat, apply to mesh

So it's rather simple in theory, as you can see. As you will see once you're familiar with the details, it's rather simple in practice, as well; at least when you've got the pitfalls covered. But it's limited and obviously flawed, for example, you can see the seams between meshes when they animate; or the data overhead is rather large; or it needs a lot of interpolation, so it is expensive.

wolf_m

Note that if you import the bezier curves' defining data as well and precompute the individual values, you can simply look up what translation/rotation/scale value you have to apply, so that kills the interpolation problem.

Greenleon

Thanks for that educational post.
I guess this a bit too much for us at the current state and aim of the project.
To be honest, I hope to find a small 3d engine to use. Coding all from scratch would not bring the wanted result because of our not existing experience. Probably it will happen later.

I'm not looking for something like jME, which is ways too large. Just a couple of methods that handle animation stuff and an importer as you call it. I am currently coding the "physics" system, which is almost done.

Do you know, where to find such a thing?

If not - we will go 2d. We can move to 3d later then.

Thanks anyway,
regards
Leon

wolf_m

I don't have anything else on my radar right now. But don't be so quick with dismissing jme - they do a lot of things you'd have to do anyway. And you can simply omit and later delete the stuff you don't need.