Share on other sites
Quote:
Original post by MikeTacular
Quote:
Original post by CodaKiller
Quote:
 Original post by MikeTacularwhy do you have to change the center of rotation?

When rendering, are you translating before rotating, or rotating before translating? In that picture it looks like you're doing the latter when you want the former. It seems like it should be simple (but maybe I'm missing something):

1) Get the world matrix for each bone
2) Translate to the bone's position
3) Rotate according to the bone's angle
4) Render the stuff connected to that bone

However, if you can get some relative matrix (as opposed to a world matrix) you can multiply the current matrix by that relative matrix and get the new matrix.

P.S. Very nice pictures, it's helping clarify things a lot.

Thats just it, it seems simple but when I actually do it nothing happens, I know it's an error in the way I am calculating it but I have no idea whats wrong.

EDIT: Wait no, I believe it is offsetting the center of rotation but it's way off from where it should be.

[Edited by - CodaKiller on January 20, 2009 6:14:26 PM]

Share on other sites
"D3DXMatrixTranslation( &pos, mesh->bones[i].matrix._41, mesh->bones[i].matrix._42, mesh->bones[i].matrix._43 );"

This provides a ROW MAJOR matrix. You have taken that into account have you?

Try to transpose it, just for fun.

Share on other sites
This may help, it's basically exactly what I do in opengl for rotating around a specified origin:
   glPushMatrix();   if(!translateTo.atOrigin()){      glTranslated(translateTo.x, translateTo.y, translateTo.z);   }   if(!scaleTo.atOrigin()){      glScaled(scaleTo.x, scaleTo.y, scaleTo.z);   }   if(!rotateTo.atOrigin()){      glTranslated(rotateOrigin.x, rotateOrigin.y, rotateOrigin.z);      glRotated(rotateTo.x, 1.0, 0.0, 0.0);      glRotated(rotateTo.y, 0.0, 1.0, 0.0);      glRotated(rotateTo.z, 0.0, 0.0, 1.0);      glTranslated(-rotateOrigin.x, -rotateOrigin.y, -rotateOrigin.z);   }   drawthebone   glPopMatrix()

NOTE: atOrigin() is a function that basically checks to see if the vector is 0, 0, 0

See the rotate part? That's where you can specify to rotate around a specified origin.

However you do that in directx would be it.

Not sure if this is helpful. I store objects with a local translation and scale value and then also a rotation value and a rotation origin. That is what all these points relate to... It sounds like you're already doing this though and the problem lies with your shader (which I am not familiar with), so this is more an explanation to the people asking you why you're doing what you are.

Share on other sites
Quote:
 Original post by M2tMThis may help, it's basically exactly what I do in opengl for rotating around a specified origin:*** Source Snippet Removed ***NOTE: atOrigin() is a function that basically checks to see if the vector is 0, 0, 0See the rotate part? That's where you can specify to rotate around a specified origin.However you do that in directx would be it.Not sure if this is helpful. I store objects with a local translation and scale value and then also a rotation value and a rotation origin. That is what all these points relate to... It sounds like you're already doing this though and the problem lies with your shader (which I am not familiar with), so this is more an explanation to the people asking you why you're doing what you are.

Thats what I'm already doing, I translate it to the origin I want then I multiply it by the rotation and then move it back to it's original position.

Thats at "// I thought the code below would give the matrix the correct center of rotation but it's still at the origin." which is actually working but it's not moving it to the right origin or something else is wrong thats making it the wrong origin, idk...

Share on other sites
Ah, I see, that picture is a "desired effect" so my opengl version transcribed into direct x would probably solve you. I mis-read and thought that second picture with the two bones rotated on the second bone's pivot was what you had working.

Have you made sure your rotation origin is what you think it is? Try stepping through the bugger with a debugger.

and go through my example and make sure each step is actually being done.

Share on other sites
CodaKiller, did see janta's post about the type of matrix D3D functions expect? I just want to point it out again to make sure that you see it. D3D expects row major matrices. However, you're getting a column major matrix.

Share on other sites
I'm not too experienced with directx, but I am familiar with this process that you are trying to do. It looks like you only set inv_world once, instead of for each bone. If you use the same inv_world translate matrix for each bone, they will use the same point of rotation.

Here is an image to hopefully explain better:

[IMG]http://i217.photobucket.com/albums/cc94/Oot_Oot_Ima_Monk/skeletalanimation.gif[/IMG]

Share on other sites
Quote:
 Original post by MikeTacularCodaKiller, did see janta's post about the type of matrix D3D functions expect? I just want to point it out again to make sure that you see it. D3D expects row major matrices. However, you're getting a column major matrix.

Quote:
 NOTE: While Direct3D matrices are technically row major, they have an additional semantic difference to OpenGL matrices which cancels this out; therefore, use this same code for Direct3D.

This is from the PhysX documentation, it's talking about the getColumnMajor44 command and of course I would have made sure I had a working matrix before I would have posted here.

Share on other sites
Quote:
 Original post by MortusMaximusI'm not too experienced with directx, but I am familiar with this process that you are trying to do. It looks like you only set inv_world once, instead of for each bone. If you use the same inv_world translate matrix for each bone, they will use the same point of rotation.Here is an image to hopefully explain better:[IMG]http://i217.photobucket.com/albums/cc94/Oot_Oot_Ima_Monk/skeletalanimation.gif[/IMG]

inv_world is just to bring the object back out of model space, it's not possible to compute it for each bone since then it would be the same thing as using identity on all of the matrices.

Share on other sites
Aha! This explains exactly what I need to do! Finally found something! Whats sad is I was doing something similar but then I thought it was wrong and just delete it.

[Edited by - CodaKiller on January 21, 2009 11:47:06 AM]

Share on other sites
So, out of curiosity, what your mistake?

Share on other sites
Quote:
 Original post by GrafalgarSo, out of curiosity, what your mistake?

Pretty much all of that code was wrong, it needed to be done in a completely different way.

Who gets the $20? Share this post Link to post Share on other sites Quote:  Original post by VerManWho gets the$20?

No one really had an effect on me finding that tutorial or any type of positive effect on the problem, so I would have to say no one.

Share on other sites
Treat yourself ;)

Quote:
 Original post by CodaKillerWhat do you mean? There is nothing to debug, I just don't know how to do the math needed and I have payed someone for helping me before, it's not a big deal.I figure if I have wasted over 80 hours of my life on something it's well worth $20 to find the answer. Debugging can allow you to see the values of variables line by line. You could see if the values are being properly updated. If not, you can track from where the improper values are coming. You might have, for example, watched the rotations and positions as they changed and seen that not only was the results not as expected, but that it was a flaw in the algorithm. Then again, as we see, the problem was more deep than originally thought. Debugging might not have helped as much as I expected, but familiarizing your self with the basics of debuggers (marking breakpoints and hovering over variables to see their values) can be very helpful, especially for finding problems in heavily mathematical sections of code. If you're using Visual C++ (which I use ONLY for its debugger and occasional code that requires it), you can just set a breakpoint, compile, and start debugging. And my point wasn't I don't want you to waste your money, my point is I don't want that going on here. I don't care where you waste your money as long as it's not here (though it's not like I have any authority or can stop you, nor will I comment on it anymore). [Edited by - Splinter of Chaos on January 21, 2009 8:10:18 PM] Share this post Link to post Share on other sites To Splinter: I don't actually have a problem with him offering money for a service, or help on figuring out a problem. It's not really any different from the "Help Wanted" forum. If he wants to offer somebody$20 as incentive, it's between him and whoever accepts the offer. Now, had it been an unethical offer (say, to help with homework), that's a different story. But I see no ethical compromises here.

You may feel that the good nature of the people here, offering help for free, is perhaps cheapened by someone who offers money for the same thing, or that it opens the door for other people making the same offers, but I do not consider that a problem. People do, after all, have a choice in how they want to spend their money / how they want to provide help.

Personally, I give him kudo's for finding a way to get people to pay attention, even though it ended up being for naught.

Share on other sites
Quote:
 Original post by Grafalgar But I see no ethical compromises here.

I don't find it unethical, I find it uncomfortable.

Quote:
 You may feel that the good nature of the people here, offering help for free, is perhaps cheapened by someone who offers money for the same thing, or that it opens the door for other people making the same offers, but I do not consider that a problem.

Reminds me of what happened in the indy crowd recently. An allegedly (haven't played it) great game called Braid, which everyone seems to love, comes out, and people can't stop bitching about it being 20 bucks. That's actually normal for an indy game, I thought, but they'd been so spoiled by 10 and 15 dollar indy games that weren't all that great that 20 was for some reason unreasonable.

(I'm not saying Braid's price was immoral, I'm just explaining the effect it had on the group psychology of that instance.)

If people got in the habit of offering 20 dollars for bugs on these forums, the experts might feel cheated when someone comes and asks for that free exchange of information. The people posting problems might feel cheated by not receiving the same level of help. It would be unfair to people who either could not afford it or didn't think it was worth it. As Kant would say, this is not a universalizable act. But, I'm not a Kantian philosopher and I don't believe this was immoral because I don't think it'll catch on. (I examine situations morally by action and environment, not intent. If it caught on, I still wouldn't consider this immoral still because the environment didn't suggest it would.)

I wasn't going to respond to that (I said I wouldn't), but then you hinted that this would be fine on a wider scale.

Quote:
 People do, after all, have a choice in how they want to spend their money / how they want to provide help.

But it would not be true to say people can chose how they want to get help. You can't ask for help in physics help under the DX topic or in DX help under the networking thread. I feel that applies to this situation, but I can see why you do not.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628402
• Total Posts
2982472

• 9
• 10
• 9
• 19
• 24