www.jpct.net

jPCT - a 3d engine for Java => Projects => Topic started by: cyberkilla on February 06, 2007, 01:52:36 am

Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 01:52:36 am
I was just thinking of this. Please tell me if its possible - not if its plausible - I like to do strange things:)....
Its just an example of what I might try...

----
Export model in OBJ format...
----
Make a quick app, to create a list of vertex coords for each "bone".
Perhaps using the pickPolygon to select a few.
----
Save those coords in an xml file.
Also save any skeletal movements.
----
Load actual model in jpct.
----
At load time...
Get mesh somehow, and create a new one, finding the object space coords(same as in modeler? would think so)...
Rotate them around the already found(guessed;)) bone pivots,
and save as a new mesh.
----
Put all the meshes into a keyframe animation like you would with multiple 3ds files, as we once discussed.

Is this possible?


If it is, I would like to make a generic bone editor, and a skeletal-like api,
that could be used if needed.
I do not know how others achieve this effect, but I see it as this:

SimpleVectors,
Rotation Around Pivot(with parent/child)
Storage(in xml) of each bone, its parent/children, and the connected vertexes.
For each mesh vertex, apply rotations.
Make keyframe animation from skeletal stages.

Some form of this is the only thing missing from the jpct features.
It need not be included by default, but as another jar, if needed.

I'd like to do this myself, as my contribution:)
How would I know which vertex is which? Well, by its original coordinate:)
doubles might cause trouble, but I don't own a model that has vertexes in the EXACT same place:)
The bone editor could be programmed to point out these double vertexes, so i dont think its a problem.



Now, whats the point of this? Well, you could get the data for the model, and do the same for clothing, and be able to make a new skeleton animation, without having to manually mess around with all of the clothing sets you've made! I have no idea why I needed to point that out. Its obvious;)

Still, if this is even a tiny possibility, it would be great! An MMORPG game would benefit from such dynamic animation, and it wouldnt have to be blocky.

I heard rolz used a kind of skeleton system by making each limb an object, and rotating them.
It would be like that, but the limbs could be connected, and not hinge-like(I am assuming here, unless you found a way to join the arms with the torso, etc).
Title: Skeletal Animation Idea?
Post by: halcor on February 06, 2007, 10:12:00 am
Maybe you can use Blender to make your skeletal animation and write a Python script (if there isn't one already) that exports bones (Blender Python API for reference how to do that, but shouldn't be hard) in some format.

You then load the hierarchy of bones, mesh rest position and data for each vertex which bone it belongs to. Then you can implement IVertexController that for given frame of the bone animation calculates actual vertex positions (I have very vague idea how you do this exactly, however).
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 11:20:22 am
Sounds good:)

Thanks for responding!

I am beginning to think it is possible to manipulate the vertexes in the way
I would require.

EDIT:
I wonder if there is something already in jpct that allows you to rotate a SimpleVector, around a pivot SimpleVector, in object space:)

This looks like my friend:

Code: [Select]

rotateAxis(SimpleVector axis, float angle)
Rotates the matrix around an arbitrary axis.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 12:55:50 pm
XML Export Prototypes...

Code: [Select]

<skeleton>
<bone name="arm" x="0" y="0" z="0">
<bone name="wrist" x="10" y="10" z="10">
</bone>
</bone>
</skeleton>

This is how the bones are stored. Nested to show parents.

Code: [Select]

<vertexgroups>
<group name="arm">
<vertex  x="0" y="0" z="0" />
<vertex  x="2" y="0" z="3" />
<vertex  x="3" y="2" z="1" />
</group>
<group name="wrist">
<vertex  x="7" y="5" z="0" />
<vertex  x="6" y="5" z="5" />
<vertex  x="5" y="5" z="1" />
</group>
</vertexgroups>

This is how a models vertexes could be mapped into an xml file.

Code: [Select]

<animation>
<sequence name="walking">
<keyframe id="1">
<bone name="arm" rotx="3" roty="2" rotz="1" />
<bone name="wrist" rotx="39" roty="92" rotz="91" />
</keyframe>
<keyframe id="2">
<bone name="arm" rotx="4" roty="5" rotz="6" />
</keyframe>
</sequence>
</animation>

This is how the animation sequences could be stored.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 01:27:30 pm
How might I "pick" a polygon's vertex using Interact2D?

I know I can get the polygon selected, but is there a way to then get the vertex data?

Perhaps I could get the polygon's position in object space, and then run through
the list of vertexes stolen from VertexController, and highlight the closest vertex to the mouse position? Yes, that might work.

Perhaps if I apply the world transformation onto the object space vertex, before
picking.

EDIT:
I think ive found a way to get the vertexed(just vertex 0 for now)...

Code: [Select]

public SimpleVector getClosestVertex(int mouseX,int mouseY)
{
SimpleVector td = Interact2D.reproject2D3D(camera,frameBuffer,mouseX,mouseY);
int[] res = Interact2D.pickPolygon(world.getVisibilityList(),td);

if (res == null)
return null;

Object3D obj = world.getObject(Interact2D.getObjectID(res));  

PolygonManager polygonManager = obj.getPolygonManager();

SimpleVector vertex =
polygonManager.getTransformedVertex(Interact2D.getPolygonID(res), 0);//0-2

return vertex;
}
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 06, 2007, 04:39:52 pm
You may use a simple screen space based algorithm to get the nearest vertex by projecting all three vertices into screen space (using a combination of the PolygonManager and Interact2D) and find the vertex which is closest to the mouse pointer. Should be quite easy to do...
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 06, 2007, 04:42:21 pm
Quote from: "cyberkilla"
This looks like my friend:

Code: [Select]

rotateAxis(SimpleVector axis, float angle)
Rotates the matrix around an arbitrary axis.
It depends...is rotates around an axis, but still asumes the origin as a rotation oivot. If you don't want that, you would have to subtract the actual pivot from the SimpleVector, do the rotation and add the pivot again. You wrap this in a small method and never think about it again...  :wink:
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 06, 2007, 04:47:07 pm
BTW: I like the rotz-Attribute in the xml-example. Of course it's rotation-z, but rotz in german means snot... :lol:
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 05:20:51 pm
Fantastic!

It is looking quite plausible now!

Im currently working on the import/export api, baring in mind that I would like others to be able to use it.

So, effectively, for my whole game, the source code is now covered in snot :)

I am using software mode in the editor, because it will cause the least trouble.

Screenshots soon. Its a heck of a lot simpler than I thought it was.
Im only doing rotational movement - the specs I have found, include actual translations, but that does not make sense to me! That isnt very bone-like;)

EDIT:
I cannot decide what to call the bone points:)

This is the way I am doing it...
Each bone has an EndPoint Vector. Basically, the end position of it.
The start position is actually the EndPoint of the parent.

Also, the parent endpoint is the pivot of the child bone.
Makes sense to me(EG. A wrist bone rotates around the pivot of the arm its attached to).

End Point is a satisfactory terminology for now;)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 06:45:30 pm
Egon, if you had any spare time(for me, i mean;)), that "rotation around a point" code would be appreciated.
You do not need to though. I haven't even tried it yet. I've just finished all of the importing and exporting code.

Im using "Vertex Groups", which can be bound to "Bones" with the same name.
Just like blender.
Means you can reuse the skeleton, which is, of course, the whole point :wink: .

My next job is the vertex selection in the editor. This will be interesting:)
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 06, 2007, 07:00:41 pm
Well, like so:

Code: [Select]

 SimpleVector pivot=new SimpleVector(...); // The rotation pivot
 SimpleVector vertex=new SimpleVector(...); // The vertex to rotate
 vertex=vertex.calcSub(pivot); // move vertex into "pivot"-space
 vertex.rotate?(...); // Do the rotation
 vertex.add(pivot); // ...move back into former space
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 06, 2007, 07:19:31 pm
Oh, that simple? I actually understand that:)
Thanks;)

Here! The vertex selection works!

(http://www.rpwar.com/betafiles/files/cyberkilla/Screenshot-%20-2.png)

EDIT:
My next task it to allow the positioning/building of the bone structure.
The classes are in order. It is just the graphical part remaining.

Then, I can bind the vertex groups to the structure, and im almost done!

I suggest a vertex weight system. Just a number for each vertex, to dictate how much of the rotation should be attributed to it.

I mean, if there are 5 vertexes next to the rotating joint, they should be warped
depending on their "weights", and the distance from the pivot.

(http://www.rpwar.com/betafiles/files/cyberkilla/Screenshot.png)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 07, 2007, 01:51:47 pm
Im drawing the bones over the top, in 2d, because it gives an "xray"-like feeling.
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 07, 2007, 05:49:18 pm
Looks great. Actually, the real purpose of the IVertexController/PolygonManager was to make such things possible...it's just that no one volunteered until now... :wink:
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 07, 2007, 06:54:28 pm
I hope to have it done soon:)

I do have some problems with the "3d cursor".
Obviously, I could use some sliders to position to cursor, but id rather
have the mouse like they do in blender.

I notice, in Blender, you can turn the model around, and it will move the 3 cursor
along different axis.

I could just have multiple windows, I suppose. Yes, I will try that;)
Title: Skeletal Animation Idea?
Post by: raft on February 07, 2007, 07:09:30 pm
good work and effort cyberkilla :)

since a long time, i was also thinking of a skeletal animation system for karga. however methods differ.

have you ever tried to skin and animate a character in a 3d editor program ? at least for me, it's a damn hard thing. it's really hard to assign vertices to bones with proper weights even with help of sophisticated editor support.

so, i dont think a home made skeletal system will be much usable. i theory you can do it, you can animate your characters but all will be somewhat robotic and should be viewed from far away. rolz did that, but technopolies characters arent zoomed

instead i would take a c++ based open source skeletal system and will try to port it to java and jPCT. instead of supplying some kind of animation/skeleton editor, they typically have exporters for populer 3d editors and some mesh deforming code. ogre3d (http://www.ogre3d.org/) is a good example. it also supports animation blending and facial animation

your effort is really considerable but this is what i think ;)

Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 07, 2007, 07:37:33 pm
I disagree. You cannot know if something is possible until you try:wink:

I have experience with weighting vertexes, and uv mapping, and skeletal animation, from the perspective of someone who makes 3d models.

Programatically, it is not as complex as it appears. I have actually scanned the source code of several C++/OpenGL skeletal implementations, and found them to be overkill for most people.

My method will allow you to import a 3d model, link vertexes to bones, and export them.
Exporting involves:

+ XML file containing the skeletal structure.
+ XML file containing the vertex groups for a specific model
+ XML file containing the rotational keyframes.

At runtime, these files can be loaded(by my api), and the standard mesh interpolation animation sequences can be created.

You can then use the skeletal keyframes any way you want.

You might think, "I could do that in xxxxx 3d modeller". However, this, hopefully will be a way to seamlessly integrate skeletal animations, that can be changed at load time, or runtime, and not interfere with the normal animations.

In addition, there will also be the option of not making mesh animations at runtime, but manipulating vertexes dynamically.
This way is closer to proper skeletal animation, I would guess, but the first method is my personal favourite.

It means you can make any number of clothing items for a model, and not have to edit each thing manually.
With loading 3ds files into a sequence, youd have to make some form of exporter script for your 3d modeller, which means youd have to upload them all again:)


EDIT:
Please, give me the benefit of the doubt;) Maybe I can change your opinion of the difficulty of bone + vertex binding;)
Title: Skeletal Animation Idea?
Post by: raft on February 07, 2007, 08:06:10 pm
i would prefer to use a professional 3d editor instead of a home made one. if one day you need to hire animators, most possibly they would prefer it too ;)

instead of porting a c++ implementation you can still write your own. my main point is using a proven 3d editor. i wont even use milk shape if there is chance to use 3d max, blender etc

anyway, world would be a boring place if all think the same way ;)
Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 07, 2007, 08:29:53 pm
I'm not talking about a 3d editor.
At no point have I said that Raft:).

It is just a program to animate existing models.
Blender is my modeler;)

Its only for rotating a few pivots and pressing save:).
I wouldn't dream of reinventing the wheel.

I do not mean to sound confrontational. I understand the point you are trying to make, but, I assure you it is not valid, because that is not my aim with the project.
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 07, 2007, 08:37:47 pm
Quote from: "cyberkilla"
... because that is not my aim with the project.
"Project"...that's what it is...moved!  :wink:
Title: Skeletal Animation Idea?
Post by: raft on February 07, 2007, 09:27:42 pm
Quote from: "cyberkilla"
I'm not talking about a 3d editor.
It is just a program to animate existing models.
Its only for rotating a few pivots and pressing save:).


i guess that 'just' and 'only' includes creating a hierarchical bone structure, skinning mesh and animating bones with preferably inverse kinetics and constraints. a big JUST and ONLY :?  if it wouldnt do these, than we're at where we started. i would prefer a 3d studio

anyway, good luck. i'm looking forward for results ;)
Quote
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 07, 2007, 09:37:03 pm
Why would we need Inverse Kinetics? Constraints, yeh, but thats not hard.

Kinetics are mainly for more realistic impact reactions, etc.

To begin with, I am only doing rotational pivots. If you think we need IK,
it will be done, but not right away.

When you look at the bigger picture in that way, this is when you start to think its impossible.
We are by no means where we started though!

Heck, I plan to use this so I have have a million and one different weapons, clothing, vehicles, and control them all generically from one or more skeletal systems!

How is that like what we have now?;)

EDIT:
Skinning mesh? What are you referring to? You just select the vertexes you want bound to a bone.

(http://www.rpwar.com/betafiles/files/cyberkilla/Screenshot-FutureRP%20Bone%20Editor.png)
I will set the 3 of the panes to a fixed angle. TOP, SIDE, REAR
Title: Skeletal Animation Idea?
Post by: raft on February 07, 2007, 10:08:42 pm
Quote from: "cyberkilla"
Why would we need Inverse Kinetics?

because it greatly eases animation. it's the system which moves upper and lower arms properly when you move hand

Quote from: "cyberkilla"
Skinning mesh? What are you referring to? You just select the vertexes you want bound to a bone.

if you just bind a vertex to a bone than the results will be strange. for proper results you should have different parameters about how mesh is deformed (for instance head is never deformed but shoulder parts are higly deformed) or otherwise you shouldnt let camera be close to your character.

Quote from: "cyberkilla"
When you look at the bigger picture in that way, this is when you start to think its impossible.

it's not impossible, 3d max did it for instance ;)

in short, this seems as a really hard task to me
Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 07, 2007, 10:50:16 pm
I get the impression you do not want me to even bother.

I know exactly what they are. What I meant was its not important.
And most importantly, I dont need it, so its not a priority for me.

Skinning mesh - What you speak of is what I was talking about with vertex weighting.

When I spoke of you inundating me with skepticism, I was not referring to the actual impossibility of it, but the reason why nobody has dared try it on this forum.

I fail not understand why I have to defend myself. I'm doing it because I need it,
and if it benefits others, I will be glad.
-------------------
EDIT:
I've read these recent posts, and I would have to say I've overreacted somewhat;)
The point I made still stands though. Simplicity, and doing something a little bit at a time, without looking at the bigger picture too much, is the only way to get anywhere.

Yes, I will implement Kinetics, at some point.

Is there anything else that might be useful?
I cannot think of very much else that is important.

I am, for instance, not implementing the translational data that some skeletal systems use.
The length of bones not being static does not make sense to me.
Perhaps for nonorganic models.

(http://futurerp.net/betafiles/files/cyberkilla/screeny.png)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 08, 2007, 02:52:11 am
More evolved interface now, and after some changes to make the bones
look "bonier", I will be doing a quick rotation interface, and then the binding of the vertexes.

Then its the interesting stuff!!:)

(http://www.rpwar.com/betafiles/files/cyberkilla/boney.png)
Title: Skeletal Animation Idea?
Post by: halcor on February 08, 2007, 09:50:32 am
One feature, that I think will be useful: hardbody self-collision checking. Some algorithm like:
1) begin at the root of the bone hierarchy
2) check if vertices moved by the current bone interfere with faces, formed by vertices which belong to bones that are higher in the hierarchy than the current bone
3) correct rotation so 2) succeeds
4) do 2) recursively for all children bones of the current
5) you do 2)-4) on every bone pose operation so you don't allow self-collision.

Yeah, your project doesn't seem easy but sure is interesting, possible and useful for improving skills. Good luck with it :)
Title: Skeletal Animation Idea?
Post by: raft on February 08, 2007, 01:16:16 pm
cyberkilla,

dont get me wrong. i wasnt trying to be sarcastic or underestimate your efforts. all i was trying to say is, such a tool and effort would be of much use if it somehow makes use of populer animation tools

of course this is your project and so you're the boss ;) and as halcor said it is very improving

good luck with it..
Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 08, 2007, 02:02:29 pm
Halcor, that sounds like a good idea. I will try that at some point.

Raft, I would not be surprised if I end up trying to load a skeletal model file,
such as MD3(?), or others. Im sure some are simpler than others:)

EDIT:
This is a little "bonier";)

(http://www.rpwar.com/betafiles/files/cyberkilla/Screenshot-Bone%20Editor.png)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 08, 2007, 03:50:05 pm
I am having a problem with the 3d cursor, but its not a big deal:)

You see, since the view has perspective, the mouse position also has perspective, so its not always positioned exactly where you click.

I dont think its a bit problem though, and i have gotten around it by drawing a line from the mouse cursor to its actual position, with the depth included.
I suppose its the only way. Its not a huge deal.

EDIT:
Yup, fixed now. Im quite happy with it. Perspective makes it look a little quirky, and that is not a bad thing;)

EDIT2:
I am going to try to draw 3d crosshairs, to show the perspective more clearly:)

EDIT3:
Bone movement and rotation time!:D
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 08, 2007, 06:42:23 pm
I have looked at some 3d model formats with skeletons, and ill be honest with you...

I cannot find a single one which is simple enough to be worthwhile starting.

I will go ahead with my own format, with apis to load it in jpct, and a small application to load/save the skeleton data.

I dont have the time to start something like MD4(which I cannot find decent docs on), or the .x file format, which is just rediculous.

Whats more, Blender hasn't managed to save ANY skeletal animation for me into any format that allows it!

I really do not see any problem with making my own xml based format.
My only real concern is that my implementation may not be compatible with existing formats.
At the end of the day, who cares?
If I finish this, it should provide a fast, free, easy to grasp method of skeletal animation in jPCT.

If you already have the skeletal animations made in a modeller, Im sure I will eventually manage to support this;)
Title: Skeletal Animation Idea?
Post by: manumoi on February 08, 2007, 07:33:34 pm
Have to say, you are damn good cyberkilla.... Really interesting work :P
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 08, 2007, 08:37:48 pm
Thank you :wink:
Title: Skeletal Animation Idea?
Post by: raft on February 09, 2007, 05:38:30 pm
it is quite a progress cyberkilla ;)

Quote from: "cyberkilla"
I dont have the time to start something like MD4(which I cannot find decent docs on), or the .x file format, which is just rediculous.

Whats more, Blender hasn't managed to save ANY skeletal animation for me into any format that allows it!


i will say this risking looking too contrariety :roll: i wouldnt go after a proprietary format like MD4 since it misses the point: you still cant use well known 3d tools.

it's much like, using series of 3ds files for keyframe animation instead of md2 format. what do we have for md2: milkshape and a commerical unstable exporter for 3d max. i didnt wanted to use both so i went after loading animation from 3ds files

i would ideally will try to stick ogre3d's (http://ogre3d.org) (or another good open source one's) skeletal animation format and will try to implement it on top of jPCT. it has exporters  (http://ogre3d.org/index.php?option=com_remository&Itemid=74&func=selectcat&cat=5) for all populer 3d tools including blender, 3d max, maya etc. similar to your one it also exports to xml files. this way we have ready animation editors and exporters and we can save our efforts for the real animation part with jPCT

Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 09, 2007, 09:15:13 pm
Well, I did not know that it was xml format! :)

I will look into it! It will save me making a parser. Thank you Raft;)


Oh, Raft, i've looked into this format! I understand a lot of this format!

Perhaps something can be done!:)

EDIT:
You must be joking! This format is fantastic! Its human comprehendable:O

Im sure my opinion will change in a few hours, after i have tried to import it:D

Egon, i will ignore skeleton for now, and just load the standard data. I will try to copy what you did in your example posted here:P
Title: Skeletal Animation Idea?
Post by: raft on February 09, 2007, 09:38:20 pm
glad to hear that  :D
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 09, 2007, 10:23:54 pm
Skeletal file..
Code: [Select]

<skeleton>
<bones>
<bone id="3" name="RightHip">
<position x="0.018071" y="12.328736" z="0.337703"/>
<rotation angle="3.141593">
<axis x="0.880204" y="0.461116" z="0.112310"/>
</rotation>
</bone>
<bone id="8" name="LowerBack">
<position x="0.018071" y="12.328736" z="0.337703"/>
<rotation angle="3.141593">
<axis x="0.000000" y="1.000000" z="0.000000"/>
</rotation>
</bone>
<bone id="9" name="LeftHip">
<position x="0.018071" y="12.328736" z="0.337703"/>
<rotation angle="3.141593">
<axis x="0.874147" y="-0.474570" z="-0.103201"/>
</rotation>
</bone>
<bone id="11" name="RightLeg">
<position x="-0.000000" y="1.968476" z="-0.000000"/>
<rotation angle="2.100223">
<axis x="-0.472563" y="0.829659" z="0.297239"/>
</rotation>
</bone>
<bone id="15" name="RightShoulder">
<position x="-0.000000" y="1.881597" z="-0.000000"/>
<rotation angle="0.413654">
<axis x="0.178409" y="0.000000" z="0.983956"/>
</rotation>
</bone>
<bone id="13" name="LeftShoulder">
<position x="-0.000000" y="1.881597" z="-0.000000"/>
<rotation angle="0.432727">
<axis x="0.169547" y="0.000000" z="-0.985522"/>
</rotation>
</bone>
<bone id="6" name="Back">
<position x="-0.000000" y="1.881597" z="-0.000000"/>
<rotation angle="0.050140">
<axis x="0.999550" y="0.000000" z="0.029989"/>
</rotation>
</bone>
<bone id="12" name="LeftLeg">
<position x="-0.000000" y="2.081492" z="-0.000000"/>
<rotation angle="2.049232">
<axis x="-0.479882" y="-0.811331" z="-0.333849"/>
</rotation>
</bone>
<bone id="17" name="RightAnkle">
<position x="0.000000" y="5.975729" z="-0.000000"/>
<rotation angle="1.311481">
<axis x="0.133203" y="0.990822" z="-0.022988"/>
</rotation>
</bone>
<bone id="0" name="RightArm">
<position x="0.000000" y="4.264647" z="0.000000"/>
<rotation angle="2.324231">
<axis x="-0.008142" y="0.039086" z="0.999203"/>
</rotation>
</bone>
<bone id="5" name="LeftArm">
<position x="-0.000001" y="4.301442" z="0.000000"/>
<rotation angle="2.310072">
<axis x="-0.008011" y="-0.038973" z="-0.999208"/>
</rotation>
</bone>
<bone id="18" name="Neck">
<position x="-0.000000" y="5.087479" z="-0.000000"/>
<rotation angle="0.051003">
<axis x="-0.982660" y="0.005384" z="0.185337"/>
</rotation>
</bone>
<bone id="2" name="LeftAnkle">
<position x="0.000000" y="5.929240" z="0.000000"/>
<rotation angle="1.556054">
<axis x="0.115952" y="-0.993096" z="0.017762"/>
</rotation>
</bone>
<bone id="7" name="RightFoot">
<position x="0.000000" y="5.335332" z="-0.000000"/>
<rotation angle="2.866626">
<axis x="-0.250014" y="0.964834" z="-0.081167"/>
</rotation>
</bone>
<bone id="4" name="RightWrist">
<position x="-0.000000" y="5.281136" z="0.000000"/>
<rotation angle="3.108084">
<axis x="-0.202590" y="0.972544" z="0.114521"/>
</rotation>
</bone>
<bone id="1" name="LeftWrist">
<position x="-0.000000" y="5.346117" z="-0.000000"/>
<rotation angle="3.029640">
<axis x="-0.199838" y="-0.972209" z="-0.121960"/>
</rotation>
</bone>
<bone id="10" name="LeftFoot">
<position x="0.000000" y="5.371225" z="-0.000000"/>
<rotation angle="2.717594">
<axis x="-0.223131" y="-0.970102" z="0.095468"/>
</rotation>
</bone>
<bone id="14" name="RightHand">
<position x="-0.000000" y="4.096985" z="0.000000"/>
<rotation angle="0.385538">
<axis x="0.234160" y="-0.965373" z="-0.114999"/>
</rotation>
</bone>
<bone id="16" name="LeftHand">
<position x="0.000000" y="4.132011" z="0.000000"/>
<rotation angle="0.308810">
<axis x="0.288363" y="0.949124" z="0.126531"/>
</rotation>
</bone>
</bones>
<bonehierarchy>
<boneparent bone="RightLeg" parent="RightHip" />
<boneparent bone="RightShoulder" parent="LowerBack" />
<boneparent bone="LeftShoulder" parent="LowerBack" />
<boneparent bone="Back" parent="LowerBack" />
<boneparent bone="LeftLeg" parent="LeftHip" />
<boneparent bone="RightAnkle" parent="RightLeg" />
<boneparent bone="RightArm" parent="RightShoulder" />
<boneparent bone="LeftArm" parent="LeftShoulder" />
<boneparent bone="Neck" parent="Back" />
<boneparent bone="LeftAnkle" parent="LeftLeg" />
<boneparent bone="RightFoot" parent="RightAnkle" />
<boneparent bone="RightWrist" parent="RightArm" />
<boneparent bone="LeftWrist" parent="LeftArm" />
<boneparent bone="LeftFoot" parent="LeftAnkle" />
<boneparent bone="RightHand" parent="RightWrist" />
<boneparent bone="LeftHand" parent="LeftWrist" />
</bonehierarchy>
</skeleton>


XML for model
Code: [Select]

<mesh>
<submeshes>
<submesh material="Material" usesharedvertices="false">
<faces count="226">
<face v1="0" v2="1" v3="2"/>
<face v1="3" v2="4" v3="5"/>
<face v1="6" v2="7" v3="8"/>
<face v1="9" v2="10" v3="11"/>
<face v1="12" v2="13" v3="14"/>
<face v1="15" v2="16" v3="17"/>
<face v1="18" v2="19" v3="20"/>
<face v1="21" v2="22" v3="23"/>
<face v1="24" v2="25" v3="26"/>
<face v1="27" v2="28" v3="29"/>
<face v1="30" v2="31" v3="32"/>
<face v1="33" v2="34" v3="35"/>
<face v1="36" v2="37" v3="38"/>
<face v1="39" v2="40" v3="41"/>
...
</faces>
<geometry vertexcount="646">
<vertexbuffer positions="true" normals="true" texture_coords="1" texture_coord_dimensions_0="2">
<vertex>
<position x="-2.913142" y="20.374107" z="-0.964990"/>
<normal x="-0.521091" y="0.654126" z="-0.548254"/>
<texcoord u="0.347413" v="0.082054"/>
</vertex>
<vertex>
<position x="-3.583804" y="19.777540" z="0.756352"/>
<normal x="-0.800524" y="0.402764" z="0.443782"/>
<texcoord u="0.414900" v="0.085874"/>
</vertex>
<vertex>
<position x="-2.933356" y="20.344515" z="1.095103"/>
<normal x="-0.534601" y="0.614500" z="0.580166"/>
<texcoord u="0.375958" v="0.041235"/>
</vertex>
<vertex>
<position x="-2.913142" y="20.374107" z="-0.964990"/>
<normal x="-0.521091" y="0.654126" z="-0.548254"/>
<texcoord u="0.347413" v="0.082054"/>
</vertex>
...
</vertexbuffer>
</geometry>
<boneassignments>
<vertexboneassignment vertexindex="0" boneindex="5" weight="1.000000"/>
<vertexboneassignment vertexindex="0" boneindex="6" weight="1.000000"/>
<vertexboneassignment vertexindex="0" boneindex="13" weight="1.000000"/>
<vertexboneassignment vertexindex="1" boneindex="5" weight="1.000000"/>
<vertexboneassignment vertexindex="1" boneindex="6" weight="1.000000"/>
<vertexboneassignment vertexindex="1" boneindex="13" weight="1.000000"/>
<vertexboneassignment vertexindex="2" boneindex="5" weight="1.000000"/>
<vertexboneassignment vertexindex="2" boneindex="6" weight="1.000000"/>
.....
<vertexboneassignment vertexindex="644" boneindex="18" weight="1.000000"/>
<vertexboneassignment vertexindex="645" boneindex="18" weight="1.000000"/>
</boneassignments>
</submesh>
</submeshes>
<skeletonlink name="Body-Armature.skeleton"/>
</mesh>

Title: Skeletal Animation Idea?
Post by: raft on February 09, 2007, 10:47:24 pm
seems as you will go after ogre3d's skeleton format  :D why dont you have a look at ogre3d's code to have an idea how it's loaded and used.

just a suggestion ;)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 09, 2007, 10:56:51 pm
Might do that;)

I like this stuff. Nothing is easier to read than an xml file.

Those C++ struc's were not "my cup of tea";)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 01:16:49 am
Egon, on your importer, you do not use any information about faces, or normals.

I do see a calcNormals, so you must be doing that yourself.
Do you think it will make much difference? I know that in blender, you sometimes have to manually flip some face normals, because you just dont work automatically.

Should I ignore them for now?


Oh, one more thing;)....
I have doubt with how the vertexes are stored.
I read they have three vertexes for the first triangle, and one for the rest.
I had better look into it more - it is, after all, the first time i've parsed a 3d model file;)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 03:21:26 am
Loading from Ogre format:D
Okay, okay, it is messed up, but it looks very similar to the original;)
Ive just got the vertex offsets a little wrong:)
Im surprised it looks this good to be honest;)

(http://www.rpwar.com/betafiles/files/cyberkilla/Screenshot-Bone%20Editor-3.png)
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 04:02:10 am
They do not seem to share vertexes.
Not that disabling this makes any difference to the way my mesh looks:P
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 10, 2007, 12:24:03 pm
Quote from: "cyberkilla"
Egon, on your importer, you do not use any information about faces, or normals.
calcNormals() creates the vertex normals. The face normals are automagically in jPCT. There's no way to set them from the outside. In my loaders i don't care about them (how should i when i can't set them) and i don't care about the vertex normals either an dlet them calculate by the engine. I've never really seen the sense in storing them in the file... :?:
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 01:18:30 pm
Yes, it seemed a bit strange to me also.
I wish I know show they stored these damned vertices;)
Cannot really find any proper documentation on the xml format.

In the MD2 format, the triangle vertice's seem to be grouped.
In Ogre XML they are a long list of verticis, and do not seem to work for me.

I have tried creating triangles "3 at a time", and also incrementing the vertex array, but similar results:)

I notice, in the Blender importer, it just called an "addVertex" function.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 02:51:44 pm
Got it! It needed my to convert Quads into Triangles:D
Isnt triangles slower to render than quads though Egon?

(http://futurerp.net/images/tmp/Screenshot-Bone%20Editor-5.png)
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 10, 2007, 07:49:04 pm
Quote from: "cyberkilla"

Isnt triangles slower to render than quads though Egon?
Not really. OpenGL converts them to triangles anyway and so does almost every software renderer, mine included.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 07:54:56 pm
Well, fantastic:) No problem here then.

One thing I am concerned about, is the vertex sharing.
The model claims it doesn't support it,
and the method to disable it in jPCT claims it is performance degredating.

Each triangle has its own unique vertexes. It is simpler to load though, Ill grant them that;)
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 10, 2007, 09:23:21 pm
I would ignore this "problem" for now. If the format doesn't support it, disable it. If it becomes a real problem in the future, we can think again about how to handle it better.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 10, 2007, 10:36:11 pm
Egon, I want to keep to the style you  prefer, so have you any opinions on how I should implement skeletons?

I was thinking about having all skeletal-enabled loaders to return a SkeletalObject3D(name can change:)).

This will encapsulate all methods for object manipulation.

There will be two modes. Something like...

#1. SkeletalObject3D.createAnimations() - make mesh animations from skeleton.
#2. On-the-fly vertex changes, IK support, etc.

The 1#. mode will be made first.
The code isn't very hard:O I am, at the moment at least, very impressed by the easy of creation here.
Bones are rotated around an axis vector, by an amount in radians.
I might get confused with skeleton/model object/world spaces, but thats about it.
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 11, 2007, 01:18:05 pm
Sounds good to me. Do it in whatever way YOU prefer. Many things in jPCT are not the way they are because i prefer them that way but because of historical reasons. If something doesn't fit your needs, just do it different...
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 11, 2007, 01:25:09 pm
Understood:)

I like the idea of extending Object3D, because it means you can use it like any other object, to the largest degree possible.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 11, 2007, 11:03:01 pm
I'm moving onto skeletal loading now, and I have discovered a few things...

Firstly, the keyframes in the OrgeXML format seem to be timed, however, the timing is linear, in that it goes up in increments, almost like a sample rate of in-modeler movement, and not actually the frames where I moved the models.
This means I can treat the movements as one object, which is handy, to say the least!

It only supports one skeleton per model, but multiple bones per vertex.
This is what "blending" is referring to. I do not know of the correct algorithm to do this, but I will mess around with it, until everyone is happy.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 12, 2007, 01:30:22 pm
Encouraging logs...:)

Code: [Select]

Loading model(s) from OgreXML format...
Loaded from InputStream(198664bytes)
Loading skeleton data...
Loaded from InputStream(109988bytes)
New bone(RightHip)
New bone(LowerBack)
New bone(LeftHip)
New bone(RightLeg)
New bone(RightShoulder)
New bone(LeftShoulder)
New bone(Back)
New bone(LeftLeg)
New bone(RightAnkle)
New bone(RightArm)
New bone(LeftArm)
New bone(Neck)
New bone(LeftAnkle)
New bone(RightFoot)
New bone(RightWrist)
New bone(LeftWrist)
New bone(LeftFoot)
New bone(RightHand)
New bone(LeftHand)
Loading bone hierarchies...
Bone hierarchy loading completed.
Loading animation sequences.
New animation track(RightHip)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LowerBack)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftHip)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightLeg)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightShoulder)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftShoulder)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(Back)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftLeg)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightAnkle)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightArm)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftArm)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(Neck)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftAnkle)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightFoot)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightWrist)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftWrist)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftFoot)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(RightHand)
Loading track keyframes,,,
Track keyframe loading completed.
New animation track(LeftHand)
Loading track keyframes,,,
Track keyframe loading completed.
Animation sequence loading completed.
Skeletal data loading completed.
Found new submesh!
Disabling vertex sharing.
Creating triangle data.
Loading vertex->bone assignments...
Vertex->bone assignment completed.
OgreXML model(s) loading completed.
Model Loaded..
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 13, 2007, 12:45:25 pm
It rotates!!!!!

Wow! It works, although, its rotating everything around the wrong pivot:P

I think i need to rotate all of the skeletal pivots:D
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 15, 2007, 03:58:58 am
Its alive! My strange cube-like snake arks it's back!

Skeletal animation is basically finished!
Well, Ive tested rotation, and its working perfect:)
The translation keyframes should work too, but I havent made any models to test it yet:D
May I just ask... Is anyone interested in skeletal animations for their projects here?

(http://futurerp.net/betafiles/files/cyberkilla/Screenshot-BoneEditor.png)

EDIT:
I will also be making a simple java utility, to convert several skeletal model formats into my own, also free format:).
Why? why? Because I want to support multiple skeletons! Cant think of a more convienient way to, for instance......

Put a cape on a human model, allowing the cape to move on its own, and
move with the models legs and arms!
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 15, 2007, 09:42:55 am
Looks cool... :shock:  I can't wait to play around with it. There have been quite a few attempts to add something like this to engine (not by myself) but no one ever completed anything...to be honest, i think that no one has ever started. Great work!
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 15, 2007, 04:07:09 pm
Online documentation of the skeletal api.

Some things to finish today...

-Auto sort bone hierarchy.

Oh, and I really should be rotating the normals. I didnt do that, because I didnt think it to be a priority.
I think I will add a method to set this on/off, because it will surely provide additional cpu usage, that might not even be noticable.

http://www.rpwar.com/cyber3/doc/

#### Opinions are welcome, and appreciated! ####

Oh, here is the source. Commented:)

The api is free. Im not making it gpl, because its restrictive. Neither is it public domain.

Credit me for making it, but do as you please:)
I really hope someone other than me finds it useful.
http://www.rpwar.com/cyber3/jpctSkeletalAPI.jar---IGNORE THIS. NEEDS UPDATED


Oh! I haven't implemented Inverse Kinetics yet, but i will. If you need it sooner,
you could do it yourself, which would be nice:)
I really don't think it will be hard.
Title: Skeletal Animation Idea?
Post by: manumoi on February 15, 2007, 06:59:31 pm
Hello, I am very interested by what you have done for my own project... Currently, don t have time to work on my code ... But i hope things will be better after the end of march... Will come back to you at this moment.

Great job.

Manu


PS:  Maybe it would be cool to have a code sample on how to use your API
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 15, 2007, 08:46:50 pm
Yes, good idea:)

By the way...

jPCT XML Loader in use now.
Animation changing permitted.
Axis correction complete.

Problems...
Pivot inheritance of rotation matrix during animation seems a bit off.
Almost inverted. Im confident ill have it fixed tonight:)
After that, I will do more screenshots, and provide examples.

Its really just a Loader.loadOgreXML(),
then setAnimation("idle")
and calling advanceAnimation on the skeletalObject3D:)

Couldnt be easier;)
Title: Skeletal Animation Idea?
Post by: raft on February 16, 2007, 02:28:30 am
hey, what a progress cyberkilla, i'm quite impressed  :shock:   as others i'm looking forward for screen shots  :wink:

how much is your implementation compatible with ogre3d's format at the moment ?

Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 16, 2007, 11:02:11 am
Well, I can export something in blender, and load it, along with its skeleton, and uv mapping:).

I havent fully tested the uv, but it seems fine.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 19, 2007, 10:49:10 pm
In case you did not notice, I have basically finished it!

I have the javaDoc API URL, and the link to the source jar itself.

Opinions are appreciated!;)
http://www.jpct.net/forum/viewtopic.php?p=4395#4395
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 20, 2007, 10:30:43 am
I hope to be able to give it a try next week...i'm still busy working on something else but after that, i'll have a look at it for sure.
How about adding it to the download page? Should i host a stable version myself or do you want to keep it in your hands and i'm just linking to it?
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 20, 2007, 11:56:43 am
You can host it if you want: ).

It seems pretty stable to me.
The javaDoc should be included in the source jar too.

Should I upload a binary version too?
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 20, 2007, 12:35:52 pm
Binary would be cool. What is its target VM? 1.5?
Title: Skeletal Animation Idea?
Post by: raft on February 20, 2007, 07:21:40 pm
Quote from: "cyberkilla"
May I just ask... Is anyone interested in skeletal animations for their projects here?

sure, i'm quite interested with your skeletal api and willing to use it in karga in the future but only after you began to use it in your project (which means it's effectively tested) and also after i'm convinced it's suitable for close camera positions ;)
Code: [Select]
r a f t
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 20, 2007, 11:27:31 pm
Quote from: "EgonOlsen"
Binary would be cool. What is its target VM? 1.5?


I do tend to target for this, but I am certain I can knock the support down a lot.
There is very little used that restricts it to 1.5.

I will endevour to increase the vm support, so it can be more useful to others.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 20, 2007, 11:29:04 pm
Quote from: "raft"
Quote from: "cyberkilla"
May I just ask... Is anyone interested in skeletal animations for their projects here?

sure, i'm quite interested with your skeletal api and willing to use it in karga in the future but only after you began to use it in your project (which means it's effectively tested) and also after i'm convinced it's suitable for close camera positions ;)
Code: [Select]
r a f t


Very wise. I will be implementing it in a day or so, and it must be able to support close camera angles for my own project, so I hope I can accommodate you;)
Title: Skeletal Animation Idea?
Post by: EgonOlsen on February 23, 2007, 12:05:53 am
I've zipped the sources, the docs, a jar with the binary (compiled for 1.4) and  the example models and uploaded the whole thing. I'm linking to it from the download page. Please let me know if it's ok or if you would like me to change something.
Title: Skeletal Animation Idea?
Post by: cyberkilla on February 23, 2007, 01:07:25 am
That is great:).

I will be sorting the animation out for my own project tomorrow morning,
so I will have some better models to test.

The two that I linked to work fine, but perhaps a more detailed animation would prove the point a little better.


I appreciate you linking to it.
Some screenshots of my FutureRP project will be available soon also - it would be great to get some opinions on the interface i've been working on;)
Title: Re: Skeletal Animation Idea?
Post by: cyberkilla on April 16, 2007, 10:02:18 pm
I forgot I did this :D

I will try to get the bone weight ratios working and upload a new version in the next week or so.

My php based game is taking even longer than I thought ;)
Title: Re: Skeletal Animation Idea?
Post by: halcor on April 17, 2007, 11:53:01 am
This is because of the Hofstadter's Law (http://en.wikipedia.org/wiki/Hofstadter's_law) ;)
Title: Re: Skeletal Animation Idea?
Post by: cyberkilla on May 16, 2007, 04:49:48 am
How right you are:)
Title: Re: Skeletal Animation Idea?
Post by: ToddMcF2002 on May 30, 2007, 08:16:38 pm
Just a general question about skeletal animation "in game": 

What is the logic of ingame skeletal animation vs. keyframe meshes?  I'm guessing less memory/resources for skeletal animation?  Flexibility to add animations without redeploying the mesh?  I'm a 3DMax Biped user and I've made the comical attempt to export from Max to Ogre3D's format using oFusion.  That was certainly not a pleasant experience.  If I recall it was complaining about vertexes having multiple bone weights and it was removing them during export!  I have NO confidence in a plugin that makes vertex weighting decisions after I carefully assigned them.

I've been a bit suspicious about ingame support for skeletal animation because I'm worried about "when things go wrong".  I can fix issues in max with skin envelopes and vertex weighting - but unless the tool is developed in the game engine itself how can you be certain the mesh translation will work as expected?  Meshes seem "safe".  The Unreal franchise uses meshes only if I recall.

On the other hand clearly skeletal animation "in game" is popular.  Ogre3D does it.  Torque does it.  Not sure how many others but clearly its popular.  Just curious why?  Resources?  Too many model formats to support? 

Title: Re: Skeletal Animation Idea?
Post by: Remo on May 30, 2007, 10:15:57 pm
Well one of the advantages would be parametric animation.
Title: Re: Skeletal Animation Idea?
Post by: ToddMcF2002 on May 30, 2007, 10:31:29 pm
Sorry not so familiar with that term.  Do you mean like mixing and matching animations such as having the legs running, walking or standing combined with various separate upper body animations like waving or arms folded?

Title: Re: Skeletal Animation Idea?
Post by: cyberkilla on June 04, 2007, 02:23:38 pm
For me personally, the advantage is that I can use multiple models, giving them the same skeletal keyframes.

So, people can dynamically swap their character models without me having to animate mesh keyframes manually.
Title: Re: Skeletal Animation Idea?
Post by: fireside on May 15, 2008, 04:09:35 am
Is this project still active?  Skeletal animation would be useful for me.
Title: Re: Skeletal Animation Idea?
Post by: cyberkilla on May 17, 2008, 03:05:54 pm
It's paused, I suppose:)

I am STILL working on the PHP/Mysql RPG website I spoke about months ago!

It is taking a long time to finish.
I do intend to return to this project though.