Tue, Oct 1, 5:31 PM CDT

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2024 Oct 01 3:49 pm)



Subject: Question for python users.


xantor ( ) posted Sat, 17 February 2007 at 9:34 AM · edited Tue, 30 July 2024 at 2:59 AM

Is there any way, using python, that you can find the centre of a figure part like the chest or collar or an eye and print it up on the screen?

With rigging figures it can be very difficult to centre a bone on a part of the figure properly and things like eyes and wheels don`t work properly without being centred.


adp001 ( ) posted Sat, 17 February 2007 at 10:00 AM

Enter the Joint Editor and set the centerpoint to value 0.0. No Python needed.




xantor ( ) posted Sat, 17 February 2007 at 10:07 AM

That works for body parts in the centre of the figure like the neck, but it doesn`t work for things like eyes.


svdl ( ) posted Sat, 17 February 2007 at 10:10 AM

There's two ways I can think of right now:

  • create a bounding box around the body part (iterate over all the vertices and use the minimum/maximum x,y and z coordinates) and calculate the center of the box.
  • calculate the average of all x,y and z coordinates of all vertices.

Both methods have their problems. Let's start with the eye. Usually an eye has a cornea, which protrudes a little from the spherical surface of the eyeball itself. The bounding box method would give you a center that lies slightly in front of the actual center of the eyeball - it'll be off by 1/2 the protruding distance of the cornea.

The "average vertex" method: there probably will be more vertices at the iris, pupil and cornea of the eye, so that the calculated center (center of gravity in this case, assuming all vertices have equal "weight") will be shifted towards the iris/pupil/cornea.

In general, the bounding box method will do the job fairly well, but vertices of the body part that "stick out" have a great influence on the calculated center.
The "average vertex" method or "center of gravity" method is less susceptible to the position of vertices on the outer limits of the body part, but clusters of vertices close to each other (in the case of a collar including the breast, the nipple area would be such a cluster) tend to have a strong influence.

In short, Python can help. But it will not provide a "one size fits all" answer.

For perfectly symmetrical objects, such as wheels, the Python method will give you the "perfect" answer. The center of gravity method will have a higher precision than the bounding box method.

The scripts are quite simple. Give me a couple of minutes, and I'll have them for you.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


PhilC ( ) posted Sat, 17 February 2007 at 10:18 AM

While you guys were typing I wrote it. If you would like to email me I'll attach it by reply.

Used the center of bounding box method.

pcooke@philc.net 

We should really get out more :)


svdl ( ) posted Sat, 17 February 2007 at 10:25 AM · edited Sat, 17 February 2007 at 10:28 AM

Phil, you just beat me to it. I just finished the bounding box script...
CenterVertBB.zip

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


svdl ( ) posted Sat, 17 February 2007 at 10:28 AM

Just installed some updates to my server, it'll be unavailable for the next 10 minutes

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


xantor ( ) posted Sat, 17 February 2007 at 10:36 AM

Svdl I was just about to say that I couldn`t download your script.

philC I sent you an e-mail.

Svdl I want your script as well and I realize that with non symmetrical body parts the centering will be slightly off but I know that there is nothing that can be done about that.


svdl ( ) posted Sat, 17 February 2007 at 10:42 AM · edited Sat, 17 February 2007 at 10:43 AM

Server is up again.
And here is the center of gravity script: CenterVertGravity.zip

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


xantor ( ) posted Sat, 17 February 2007 at 10:50 AM

Great, thank you.


xantor ( ) posted Sat, 17 February 2007 at 5:32 PM

Svdl your script doesn`t seem to work properly I got two different centre points for the eyes so I entered them anyway, the right eye worked perfectly but the left eye was still wrong.


svdl ( ) posted Sat, 17 February 2007 at 6:00 PM

Just ran a few tests on a zero pose Victoria 3 figure.
Left eye: center according to Joint Editor - (0.012, 0.677 , 0.025)
Center according to CenterVertBB: (0.01233 , 0.67723 , 0.0271) - you see the effect of the Z shift due to the cornea
Center according to CenterVertGravity: (0.01233 , 0.67723 , 0.02921) - you see the effect of the higher vertex density at the pupil, iris and cornea.

Right eye: center according to Joint Editor: (-0.012 , 0.677 , 0.025)
Center according to CenterVertBB:  ( -0.0123304047156  ,  0.677230507135  ,  0.0271565997973 )
Center according to CenterVertGravity:  ( -0.0123304255137  ,  0.677230347301  ,  0.0292094542762 )

Looks fine to me. The deviations from the Joint Editor values were expected.

Could it be that the left eye group contains some stray vertices that throw the center off? Such things have happened to me when I was rigging a figure, and sometimes hunting down the stray vertex is quite difficult.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


Spanki ( ) posted Sat, 17 February 2007 at 6:06 PM

I usually just pull the values straight out of my modelling app (C4D) and scale them accordingly (move the decimal over a few places, since I scale by 1000).

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.


xantor ( ) posted Sat, 17 February 2007 at 7:30 PM · edited Sat, 17 February 2007 at 7:31 PM

Svdl, sorry I forgot that the eye was not a perfect sphere. :blushing:

Spanki, I didn`t model the figure, I am only rigging it.


Spanki ( ) posted Sat, 17 February 2007 at 7:37 PM

So you don't have a modelling app that can load .obj files?  If you do, it may have better tools to allow you to determine the center of meshes.

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.


xantor ( ) posted Sat, 17 February 2007 at 7:40 PM

I do have a modelling app but I don`t know if the numbers it shows can be used in poser, I am not very good at doing decimal division either.


Spanki ( ) posted Sat, 17 February 2007 at 8:07 PM

file_369300.gif

The problem with V3's eyes is that it's not even a complete sphere (see image).  You could run into similar problems.

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.


Spanki ( ) posted Sat, 17 February 2007 at 8:11 PM

...since I scale .obj files up by 1000 when I import them, I simply move the decimal over 3 places to the left.  So, for example, 27.127 becomes 0.027127 or just 0.027 when rounded to 3 places.

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.


Spanki ( ) posted Sat, 17 February 2007 at 8:17 PM

...if you want to do this inside Poser, and you have polygon edges at the center to go by, then you can also hide all other bodyparts, then use the orthographic camera views (top, front, left, right, bottom, rear), enable one of the wireframe preview modes and adjust it pretty close that way (using the polygon edges as a guide).

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.