Home Technical Talk

rotating around local axis instead of global axis

polycounter lvl 18
Offline / Send Message
Soccerman18 polycounter lvl 18
I'm working on a project for work where I'm moving and rotating a model. The way the code is written right now when I rotate a model it rotates around the origin, which becomes a pain when trying to rotate and positon a model correctly. Basically I'm hard coding a model viewer, or something similar to that. If I was able to rotate the model around it's local axis instead of around the origin, that would make it a lot easier to position correctly.

So basically, I have code (in flash) that allows me to rotate a model around the origin. Does anyone know a way to change to code, methods, equations, ideas, anything to get it to rotate around it's local axis?

Replies

  • Soccerman18
    Offline / Send Message
    Soccerman18 polycounter lvl 18
    On a similar note, in gmax when I rotate something it goes in .5 increments, but I have max here at work and I'm not sure what amount it rotates but it's some weird number. So if I want to rotate something exactly 45 degrees or something, I can do that easily in gmax, but in max it is always off by a small amount. Is there some setting in max where I can change how much the rotate increments so it only rotates at .5 degree, or some other number, increments?
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Yeah, in Max, you wanna change the Snap settings - sounds like Angle snap is on in Gmax, but off in Max.
    It's the button on the top menu bar that looks like an illustration of an angle with a red magnet in front of it, click that to enable it. Right-click it if you want the options, I think the default is 5 degrees, I usually change it to 1 or 0.5.

    Don't know about the other thing, I loathe Flash.
  • Eric Chadwick
    Paul Neale has some resources in his tuts section about how to deal with rotations and matrices.

    http://paulneale.com/
  • Soccerman18
    Offline / Send Message
    Soccerman18 polycounter lvl 18
    Thanks for the info. I checked gmax and the angle snap wasn't on, it just automatically went in .5 increments, but angle snap worked in Max.

    I almost got the rotating on the local axis working on friday. How the code works right now is that I take the original object (an array of xyz coordinates for each vertex) and I calculate the rotated values on that, find the difference between the newly rotated object and the original object, and then apply that difference to the object I want to rotate. Right now it works, but for some reason every time I rotate it the object gets larger.

    Well, I'm adding the difference to the object I want to rotate and it gets larger, and if I subtract the difference then it gets smaller. So there's gotta be some part of the equation that I'm missing right now that would keep it the same size.

    I've never worked with flash before this, and I'm just working on code, which isn't very flashy.
  • Soccerman18
    Offline / Send Message
    Soccerman18 polycounter lvl 18
    Well, just thought I'd update those of you who may be interested. I got it working, sorta. Basically I'm taking the object I want to rotate, finding it's center, moving it so that the center is at the origin, rotate it, move it back to it's original location. This doesn't keep the objects original axis, it more of just moves the global axis to the location of the object, but as far as rotating it in the direction I want it to, it works. laugh.gif
Sign In or Register to comment.