• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

104 Neutral

About jkeon

  • Rank
  1. Hey, I appreciate the responses everyone thanks! I've been digging into it a bit more and going through some lectures from MIT and UCSD, the good news is that I'm understand the rules of Matrix multiplication and transforming to different spaces but unfortunately I'm still having the same problems. @L.Spiro I tried your matrix but this resulted in the terms canceling each other out so that scale values had no effect. Perhaps if you could explain what that matrix should do in a bit more detail? @Alvaro, @C0lumbo I tried changing the order so that rotation was applied first and then scaling, this did appear to properly preserve the scaling along the local X,Y,Z axis but at the expense of shearing the cube as well. I guess I'm trying to understand why W= S*R*T is the commonly chosen convention as opposed to W = R*S*T as you've recommended for this specific case. For completeness I've tried checking with other engines with my same setup. (1x1x1 unit cube, scaled x 4 in the X axis, x2 in the Y Axis, translated to the right and down and then rotating) The engine most similar to mine in terms of language and platform is Away3D (http://away3d.com/) which is supported by Adobe and also open source so I can dive in and see how they are doing things. They have the exact same problem as I do with this test case which is comforting in that I'm not missing anything obvious but disappointing in that the problem still isn't solved. I fired up Unity3D after that and set up the same test case. Unity does seem to handle it correctly but they have methods specific to rotationAroundLocal and scaleLocal. So the next step will be to do the multiplications by hand and compare with the values spit out from my engine and use unity as an example and see if I can figure out where things are going wrong.
  2. I'm trying to build my own little engine to get more familiar with the concepts of 3D programming. I have a transform class that on each frame it creates a Scaling Matrix (S), a Rotation Matrix from a Quaternion (R) and concatenates them together (S*R). Once i have SR, I insert the translation values into the bottom of the three columns. So i end up with a transformation matrix that looks like: [source lang="jscript"][SR SR SR 0] [SR SR SR 0] [SR SR SR 0] [tx ty tz 1][/source] This works perfectly in all cases except when rotating an object that has a non-uniform scale. For example a unit cube with ScaleX = 4, ScaleY = 2, ScaleZ = 1 will give me a rectangular box that is 4 times as wide as the depth and twice as high as the depth. If i then translate this around, the box stays the same and looks normal. The problem happens whenever I try to rotate this scaled box. The shape itself becomes distorted and it appears as though the Scale factors are affecting the object on the World X,Y,Z axis rather than the local X,Y,Z axis of the object. I've dug through most of my textbooks and there isn't a ton there to go off of. Online, most of the answers say to avoid non-uniform scaling which I understand the desire to avoid it, but I'd still like to figure out how to support it. The only thing I can think off is that when constructing a Scale Matrix: [source lang="jscript"][sx 0 0 0] [0 sy 0 0] [0 0 sz 0] [0 0 0 1][/source] This is scaling along the World Axis instead of the object's local Direction, Up and Right vectors or it's local Z, Y, X axis. Does anyone have any tips or ideas on how to handle construction a transformation matrix that allows for non-uniform scaling and rotation? Thanks!
  • Advertisement