$20 to anyone who can figure out whats wrong with this code.

Started by
26 comments, last by phresnel 15 years, 3 months ago
Quote:Original post by M2tM
This 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, 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.


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...
Remember Codeka is my alternate account, just remember that!
Advertisement
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.
_______________________"You're using a screwdriver to nail some glue to a ming vase. " -ToohrVyk
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.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
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:

skeletalanimation.gif
Check out the first gameplay video from my javascript/PHP RTS game
Quote:Original post by MikeTacular
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.


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.
Remember Codeka is my alternate account, just remember that!
Quote:Original post by MortusMaximus
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:

skeletalanimation.gif


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.
Remember Codeka is my alternate account, just remember that!
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]
Remember Codeka is my alternate account, just remember that!
So, out of curiosity, what your mistake?
Quote:Original post by Grafalgar
So, out of curiosity, what your mistake?


Pretty much all of that code was wrong, it needed to be done in a completely different way.
Remember Codeka is my alternate account, just remember that!
Who gets the $20?

This topic is closed to new replies.

Advertisement