1

(36 replies, posted in General)

Yes your code works perfectly in my project too.
Your "CopyTransformation" function as it is in your zip file is everything I needed.
In my first post about this problem I wrote that the part that I suspected was not working was this:

  //Bone copys from Ragdoll's part (DOESN'T WORK)
        MMatrix4x4 myMatrix = characterEntity->getMatrix()->getInverse() * (*ragdollPart->getMatrix());
        MObject3d* parentBone = bone->getParent();
        if(parentBone)
            myMatrix = parentBone->getMatrix()->getInverse() * myMatrix;
        bone->setEulerRotation(myMatrix.getEulerAngles());

And indeed replacing this with your code solved everything. Now the ragdoll works fine. smile
It was that "no scale" trick that was missing.

2

(36 replies, posted in General)

Ah! You did it!
And there's no need to call armature->processBonesLinking() or bone->computeLocalMatrix().
Thank you very much anael.

3

(36 replies, posted in General)

I've disabled the physics (commented every part of code which has something to do with the physics).
Ragdoll parts have now no parent-child relationships, no physics and no constraints.
Copying the bone rotation and position from the armature to the ragdoll, the result is what is seen in the first image that I've posted (the one on the left): http://forum.maratis3d.com/viewtopic.php?pid=6377#p6377, as expected.
Which is the default position of the armature, the same that it's on the Blender file.

If this is of any help, in the Blender file the bones in their default position (as seen in the image) are considered to be at rotation zero (0,0,0) on the 3 axis. In Maratis tough it's not the same, because if I set them at (0,0,0) they all point straight to the axis +Y.

4

(36 replies, posted in General)

Your code as it is makes everything blow up, similarly to the previous image that I've posted.
But I think we're on the right path.
I remember having tried something similar in the past: http://forum.maratis3d.com/viewtopic.php?pid=5562#p5562
although the situation was a bit different. But yes, I also thought about the offset so I guess this is the way to go.
Still, the code as it is doesn't seem to work.

If nothing works I could use that old code of mine, but it's not that good because it uses a specific axis which may be different depending on where the bone is (e.g. leg and arms need a different calculation). So using matrices should be better.

5

(36 replies, posted in General)

Yes, the order is important but I got it right.
I use a makehuman mesh (basic rig), the bones are already put in a decent order in the mesh file and there is only one root bone, so your code solution is not required.

Anyway, both my original code and yours give the same result.
So the bug is not about the order.

6

(36 replies, posted in General)

Not quite right.
http://oi62.tinypic.com/1zqwpsk.jpg

LOL.
In the processChilds function of your code I think this lines:

        // compute parenting (parent matrix * child local matrix)
        copyTransformation(entity, bone, object);
        (*child->getMatrix()) = (*bone->getMatrix()) * (*child->getMatrix());
        processChilds(entity, child);

should actually be:

        // compute parenting (parent matrix * child local matrix)
        copyTransformation(entity, child, object);   //   <--------
        (*child->getMatrix()) = (*bone->getMatrix()) * (*child->getMatrix());
        processChilds(entity, child);

otherwise it doesn't make sense.

Compiling with this correction I get the exact same result of the first image that I've posted (the one on the right), which is: the rotation is not quite right.

So as I thought it's not about the order. IMHO some matrix operation is not correct. Or the bug may be somewhere else, but I triple-checked every single line of my code.

7

(36 replies, posted in General)

My for loop is

for(i=0; i<bonesNumber; i++)

and the mesh has one single root bone, which is bone 0.
After each bone is rotated, I do:

armature->processBonesLinking();
armature->updateBonesSkinMatrix();

inside the brackets of the for loop, and then I process the next bone (i++).
So I don't really think that the problem is about order.

I will try your code anyway and let you know.

8

(36 replies, posted in General)

Well it's actually complex for me too, I've still not grasped matrices and stuff quite well I guess eheh.

Tutorial Doctor wrote:

Perhaps a visual cue for that would be something you could add.

There's no need. Since I never change the position (only at the start) and I change only the orientation of the bones, you can be sure that the orientation is simply what goes from a red dot to the other. The position changes automatically thanks to parent-child relationships between the bones, as a "side-effect" of the rotation changes.

9

(36 replies, posted in General)

I'm back working on my ragdoll system and I have problems.

I have a ragdoll made of ragdoll parts.
Each ragdoll part is just a parallelepiped entity which visually simulates the bone.
Each ragdoll part is in world space (they are parented only with constraints).
I have a characterEntity and its armature.
The armature should "follow" the ragdoll (and this is what is not quite working).

First, at the start of the game, I position and rotate each ragdoll part, copying the position and rotation from the bones.
Then, I let the physics run and each step I do the inverse: I rotate every bone to match the ragdoll part rotation, so the mesh should animate and fall down to the floor.

It works almost fine but there is some kind of offset, e.g. the leg's bone is ~15° off on the X axis in respect to the ragdoll part, the arm's bone ~ the same, etc.
The ragdoll is currently only about the skeleton, so it's not about e.g. the arm not being perfectly in line with the bone or uncorrectly colliding: I'm making a ragdoll of the skeleton only. Only when this works, I will attach actual body parts for the collisions.

My code is actually pretty long, complex, and separated into classes and files, I just can't post it all. But I'm pretty sure the problem is only about matrices and rotation, and lies here:

[...]
        //Ragdoll's part copys rotation from bone (works perfectly fine)
        MMatrix4x4 boneWorldMatrix = (*characterEntity->getMatrix()) * (*bone->getMatrix());
        ragdollPart->setEulerRotation(boneWorldMatrix.getEulerAngles());
[...]
        //Bone copys from Ragdoll's part (DOESN'T WORK)
        MMatrix4x4 myMatrix = characterEntity->getMatrix()->getInverse() * (*ragdollPart->getMatrix());
        MObject3d* parentBone = bone->getParent();
        if(parentBone)
            myMatrix = parentBone->getMatrix()->getInverse() * myMatrix;
        bone->setEulerRotation(myMatrix.getEulerAngles());
[...]

http://oi61.tinypic.com/1zdxkpe.jpg
The grey lines are the ragdoll parts. They are in "x-ray mode".
The red little squares are the bones (the head of every bone).
In the image on the left, the game is just started, and everything is right. The ragdoll parts are positioned and rotated copying the bones position and rotation from the armature.
As soon as I activate the physics (only one step of physics), you can see how the bones don't match the ragdoll parts correctly.

I've sent a pull request. If it's ok, I can then do the other pages.

Oh ok Doxygen automatically puts the link when it finds a class name.
But what if in the wiki I've something like this:

all the properties that will be used by the [[MPhysicsContext|physics engine]].

How can I simulate this in the header file?

12

(33 replies, posted in General)

I used Allegro too ehehe nice piece of software.
But Game Maker is what I used more for 2D, despite all its disadvantages.

Hi.
There are old information which was input manually e.g. bottom of MOEntity page.
I can easily put the general description of the class before the API list simply moving it before

{{:classMOEntity}}

but what about the old API information like this one:
http://wiki.maratis3d.org/index.php?tit … ties#Ghost
I guess it should be moved on the header files, although in this case you may loose the links inside the text.

14

(36 replies, posted in General)

Yes, it works, and if the bones really overlap you can also simply do

bone->setRotation(targetBone->getRotation());

and that's enough. In other cases your code works better.
So, yeah, the problem lies somewhere else in my code.
Debugging time! lol
Thanks for the help.

15

(36 replies, posted in General)

Mmm.. doesn't work.
I'll try to set up a very simple and basic scene to do some testing with. It will take some time but at least I can be sure the error is somewhere else, I have too much code here.

16

(36 replies, posted in General)

Yes, in the same armature. So, for example, the arm is controlled by two overlapping structures of bones and I want one to overlap the other copying rotation and position. Position works (using the code of your first post in this thread), rotation doesn't (with the code I posted last).

17

(36 replies, posted in General)

Here I am again with my total lack of success with matrices and rotations. And I'm sorry to post again but I've lost way too much time on this trying to get it to work.
I'm trying to copy the rotation from a bone to another bone.
You provided me the code for copying the rotation from an object to a bone, here http://forum.maratis3d.com/viewtopic.php?pid=5346#p5346 , so I thought that basing on that, I could do:

                MMatrix4x4 myMatrix = (*entity->getMatrix()) * (*boneToCopyFrom->getMatrix());
                MObject3d* parentBone = bone->getParent();
                if(parentBone)
                    myMatrix = parentBone->getMatrix()->getInverse() * myMatrix;
                bone->setEulerRotation(myMatrix.getEulerAngles());

but the final rotation is not as expected.
p.s. I want to copy bone world position to bone world position.

18

(4 replies, posted in Engine)

Ooook thank you.

19

(4 replies, posted in Engine)

No, I want to add keys that are not recognized. I was not able to find how Maratis read the input (from square one I mean, at the lowest level of abstraction) so I don't know what to change.

20

(4 replies, posted in Engine)

Can I have an example on how to do that?
Let's say I want to be able to use the Numpad +.
Thanks.

21

(1 replies, posted in External Tools)

It uses autohotkey, you can't use it with Maratis.
Actually you can't use any GUI maker with Maratis, because you will always need some sort of interface between Maratis and the GUI maker so to be able to use buttons, etc, so you will always need C++ code.

22

(16 replies, posted in General)

I can't reproduce the problem. Does changing the renderer (fixed/standard) change anything?

23

(61 replies, posted in Editor)

It's in the to do list.

24

(15 replies, posted in General)

@zester

255 wrote:

in informatics "proxy" is only the net intermediate server.

25

(15 replies, posted in General)

It may has sense in english language (I don't know), but in informatics "proxy" is only the net intermediate server.
In programming it's more correct to use the words "object","instance", "clone", "copy". Where "object" is the actual data in memory and the other words are the clones objects which just "points" to the original data and so use less memory.