Thread: still workin on this last problem...

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743

    Question still workin on this last problem...

    So I am still working on this last rotation problem. I have tried various glTranslatef() calls, and cant figure out how to get it to rotate around the pivot point of this mesh.

    Here is some data about the mesh:

    X:
    min: -0.5
    max: 0.5
    size: 1
    center: 0

    Y:
    min: -0.9
    max: -0.299
    size: 0.6
    center -0.599

    Z:
    min: 1.75
    max: 3.5
    size: 1.75
    center: 2.625


    A picture is attached at the bottom showing the point i want to pivot the mesh on.

    I have tried doing glTranslatef's to the various min, max, and center points on the mesh to see if I could get it to work properly, but it wont work.

    It keeps making a big huge circle as it rotates instead of rotating around that one point I want to rotate on.
    My Website

    "Circular logic is good because it is."

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    for those who are interested, here is my process of doing things:


    glPushMatrix ( );

    glTranslatef ( pivot points as parameters );

    glRotatef ( rotations that need to be done );

    draw the things that need to be drawn

    glPopMatrix ( );
    My Website

    "Circular logic is good because it is."

  3. #3
    Can somebody plz explain to me the differences between meshes, models, brushes, etc.?

  4. #4
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    model = a whole 3d model

    mesh = a small piece of that 3d model, for example, if the model was of a human, there would probably be a mesh for the lower leg, a mesh for the upper leg, etc.
    My Website

    "Circular logic is good because it is."

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    In order to translate any object around a certain point then you must translate it by that amount BEFORE you transform it to world space. If you transform it to world space then translate it, it will be translated from the world center...not the object center. This will cause the object to rotate in one huge circle.

    So you want to translate this object in local or model space before you transform it to world space. Also make sure that when you create your model it is created around 0,0,0. If not when you rotate it, it will also do some strange stuff.

    But since you cannot possibly re-create the model around rx,ry,rz you simply translate the center by the vector needed to get the center of rotation.

    To test this try it. In your 3D program just translate all the vertices by a set amount or offset the object on x or y just a bit. Then load the mesh and rotate it. It will rotate around that point.
    Essentially you are doing the same thing when you load the original model (created with center at 0,0,0) and then translate it by a vector to change the center of rotation.

    Let's say we have a 3D square. It's created with center at 0,0,0. Now let's rotate it. Of course it will rotate around 0,0,0. But now let's move the square's local coords by 10 units. Now rotate it. It will rotate around a point 10 units from the square. Following me here?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM