Results 1 to 7 of 7

Thread: finding out the object's center

  1. #1
    Member Contributor
    Join Date
    Feb 2004
    Location
    Gainesville, Florida
    Posts
    51

    finding out the object's center

    hello,

    i am a newbie in OGL and I'm in a problematic situation. you see, i have model with all its co-ordinates but it is not at the origin. so when i rotate it, it revolves around the origin and not about the origin.so i think i should first translate it to the origin and then rotate it and then translate it back to the original positio. the problem is how do i find the displacement between the origin and the model's center to translate it to the origin. please help me.

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: finding out the object's center

    Just add all vertices of the object and then divide that result by the number of vertices, and then you should have the center of that object.

  3. #3
    Member Contributor
    Join Date
    Feb 2004
    Location
    Gainesville, Florida
    Posts
    51

    Re: finding out the object's center

    hi
    thanx for your reply, but you see, this is a huge model with many number of vertices ranging to 4000 vertices. so how do i go about it?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    380

    Re: finding out the object's center

    the number of vertices shouldn't be a problem, just precalculate the center using Panzer's method and store it with the model information. The only problem I can imagine is if the model's center or rotation isn't at its center of mass, but for most models Panzer's method will work

  5. #5
    Member Contributor
    Join Date
    Feb 2004
    Location
    Gainesville, Florida
    Posts
    51

    Re: finding out the object's center

    hi,

    let me get this right. you're telling me to add all the x , y, z positions seperatley and divide them by the no. of vertices. is that correct?

    thanx for the help.

  6. #6
    Senior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: finding out the object's center

    Yes, that's right. But if, as chowe6685 said, your center lies at the objects center of mass then it won't work.
    But normally that isn't the case and my method works.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Jan 2004
    Location
    Los Angeles, CA, USA
    Posts
    219

    Re: finding out the object's center

    The other way, of course, is to find the min/max for x, y, and z, and use the center of that bounding rectangular solid.

Similar Threads

  1. Rotating an Object around its center.
    By avanindra in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 11-19-2009, 12:04 PM
  2. object to screen center
    By tyua in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-13-2009, 08:51 AM
  3. Rotating an object around its center
    By yarp in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-26-2004, 04:36 AM
  4. automatically center 3d object ???
    By holyburak in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 11-18-2003, 01:10 AM
  5. Rotating object around own center?
    By korogui in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-13-2003, 06:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean