3D shape math help
by Vern Jensen · in Torque Game Builder · 08/27/2007 (4:01 pm) · 1 replies
I could really use some help or advice regarding math for 3D shape rotation. I have the image of a galaxy, which I'd like to rotate in 3D space, such that it seems that the galaxy is rotating about its center. That is, while it rotates, the center of the galaxy (also the center of the 512x512 image) stays in the same place in 3D space.
Naturally, I could do this with a normal sprite, and just set it to rotate, but then the camera is directly facing the galaxy. I'd actually like the galaxy to be not quite centered with the camera, off by perhaps 20 degrees or so, so that as it rotates, some parts of the image come closer to the camera while other parts go farther away. Slightly. But otherwise, the galaxy should rotate exactly the same -- it should rotate about *it's* own center.
Problem is, when I try to set up angular velocity in Torque to achieve this, I can't seem to figure out what to use to get this to happen.
I use 90, 0, 0 for the initial rotation setting of the 3D shape if I want the galaxy to be like a normal sprite -- facing the camera directly. So then I use 110, -20, 0 for my "slightly off" setting. If I then set up an auto rotation of, say, 5 for the Z angular velocity value, then the galaxy's center doesn't stay in the same location in 3D space. Is there any way to achieve this?
I'm willing to code in script if necessary. I just don't really even know where or how to start in terms of the math process for figuring this out. I did have a linear algebra course in college, but the details are fuzzy, and I'm not sure I could remember it if I had to. Not sure I have to either... I guess I'm hoping there is a simple solution.
Thanks in advance!
Naturally, I could do this with a normal sprite, and just set it to rotate, but then the camera is directly facing the galaxy. I'd actually like the galaxy to be not quite centered with the camera, off by perhaps 20 degrees or so, so that as it rotates, some parts of the image come closer to the camera while other parts go farther away. Slightly. But otherwise, the galaxy should rotate exactly the same -- it should rotate about *it's* own center.
Problem is, when I try to set up angular velocity in Torque to achieve this, I can't seem to figure out what to use to get this to happen.
I use 90, 0, 0 for the initial rotation setting of the 3D shape if I want the galaxy to be like a normal sprite -- facing the camera directly. So then I use 110, -20, 0 for my "slightly off" setting. If I then set up an auto rotation of, say, 5 for the Z angular velocity value, then the galaxy's center doesn't stay in the same location in 3D space. Is there any way to achieve this?
I'm willing to code in script if necessary. I just don't really even know where or how to start in terms of the math process for figuring this out. I did have a linear algebra course in college, but the details are fuzzy, and I'm not sure I could remember it if I had to. Not sure I have to either... I guess I'm hoping there is a simple solution.
Thanks in advance!
Torque Owner Brian Ratte
Hope that helps.
Brian