OK. So basically you want an animation hierarchy, which in this special case you want to add some procedurally generated random rotations at each joint to make identical models look slightly different. In addition to rotations scaling effects (among others) would be handy. Building or finding a library for animation hierarchies is the way I would go. Additionally with this is place you could augment your system to support things like wind based effects. Ultimately quaternions fit the problem much better than matrices.

Exactly, so my problem is now building this library wih rotation / scaling.

I was also thinking about wind effects and maybe falling trees, so were on one line

Scaling is really easy, but im having no clue about rotations.

1 dimensional rotation is simple:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public static Vector2f[] rotate(Vector4f src, float rotation){ Vector2f[] dst = new Vector2f[4]; float sin = sinf(rotation); float cos = cosf(rotation); float wsin = sin * (src.z / 2); float wcos = cos * (src.z / 2); float hsin = sin * (src.w / 2); float hcos = cos * (src.w / 2); dst[0] = new Vector2f(src.x + wcos - hsin, src.y + hcos + wsin); dst[1] = new Vector2f(src.x - wcos - hsin, src.y + hcos - wsin); dst[2] = new Vector2f(src.x + wcos + hsin, src.y - hcos + wsin); dst[3] = new Vector2f(src.x - wcos + hsin, src.y - hcos - wsin); return dst; } |

but now the problem is creating an functon like this:

1 2 3
| public static Vector3f rotate(Vector3f src, Vector3f point, Vector3f rotation){ } |

quaternions and matrices sounds good, and looks like it is an solution, bu i have no clue about how to use them.

I have tryd to understand them on wikipedia or math tutorials, but im really clueless how to use them inside an function.

Basicly im just trying to find out how create this function (in java and / or glsl(wind effect) ).

If there is some precreated code somewhere, its fine to, reverse enginering the solution would still give me the information i need.