Sun, Feb 9, 3:10 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2025 Feb 09 1:04 pm)



Subject: Is there a Python Script for this? (Poser/BVH fix)


tvining ( ) posted Sat, 21 November 2009 at 1:00 PM · edited Mon, 05 August 2024 at 12:28 AM

I am having a problem with my imported BVH files in Poser,  in that they contain Forearm Side-Side data when, anatomically, that should remain at zero and any movement like that should be in the Shoulder Twist. My BVH files do contain Shoulder Twist data, so I can't simply transfer the Side-Side data to the Shoulder Twist, the values need to "add."

It occurred to me that a Python script to do this would compare the Forearm Side-Side keyframe values to the Shoulder Twist keyframe values, and then add the Side-Side values (either positive or negative) from the Forearm to the Shoulder Twist, so a Side-Side of, say -30 plus a Twist of +10 would yield a Shoulder Twist of -20. The Forearm Side-Side values would then be all set at zero.

I tried this manually on a few frames and it seems to work, but I was wondering if a Python Script exists for this? (I'll ask this in the Python forum as well.)

Thanks--Tim


ockham ( ) posted Sat, 21 November 2009 at 1:59 PM

This should do what you want....   I haven't tested it.
If the real parameter names are different (like 'side-side' instead of 'Side-Side')
you'll need to fix that.

============

import poser
scene=poser.Scene()
fig=scene.CurrentFigure()
lfore=fig.ActorByInternalName('lForeArm').Parameter('Side-Side')
rfore=fig.ActorByInternalName('rForeArm').Parameter('Side-Side')
lsh=fig.ActorByInternalName('lShldr').Parameter('Twist')
rsh=fig.ActorByInternalName('rShldr').Parameter('Twist')
for f in range(scene.NumFrames()):
     scene.SetFrame(f)
     lsh.SetValue(lsh.Value()+lfore.Value())
     rsh.SetValue(rsh.Value()+rfore.Value())
for f in range(scene.NumFrames()):
     scene.SetFrame(f)
     lfore.SetValue(0.0)
     rfore.SetValue(0.0)

My python page
My ShareCG freebies


tvining ( ) posted Sat, 21 November 2009 at 3:39 PM

Thanks, Ockham! It works great! I think I may need to take into account another rotation--fixing the twist created a Forearm Bend issue in some places--but I'll need to figure out what needs to be done...

Thanks so much!--Tim


tvining ( ) posted Sun, 22 November 2009 at 12:27 AM

Well, I'm flummoxed. Your python script works exactly as I described, but I apparently didn't account for some other dynamic that I can't seem to figure out. There's probably a mathematical way to describe it, but basically there needs to be some calculation/adjustment to the bend and twist of the forearm at the same time to compensate for the side-side going to zero. I worked with it for a while to no avail so far, but I'll work at it some more. It's all math, right? So there has to be some logic to it...

Thanks again--Tim


ockham ( ) posted Sun, 22 November 2009 at 9:10 AM · edited Sun, 22 November 2009 at 9:11 AM

Hmm.  Thinking out loud...

First, it's possible that the BVH was recorded on a different style of rigging?

Assuming it's a valid rig:

When the forearm is bent, side-side on forearm should be exactly the same motion
as twist on shoulder.  (Except for a slight variation because the joint center isn't
going to be precisely centered, but this shouldn't be highly noticeable.)

But when the forearm is straight, there should be no side-side at all.

Including this exception in the script (with a little "tolerance" around zero)

import poser
scene=poser.Scene()
fig=scene.CurrentFigure()
lfore=fig.ActorByInternalName('lForeArm').Parameter('Side-Side')
rfore=fig.ActorByInternalName('rForeArm').Parameter('Side-Side')
lsh=fig.ActorByInternalName('lShldr').Parameter('Twist')
rsh=fig.ActorByInternalName('rShldr').Parameter('Twist')
for f in range(scene.NumFrames()):
     scene.SetFrame(f)
     if abs(lfore.Value()) > 3.0:  # do the change only when forearm is bent
         lsh.SetValue(lsh.Value()+lfore.Value())
         rsh.SetValue(rsh.Value()+rfore.Value())
for f in range(scene.NumFrames()):
     scene.SetFrame(f)
     lfore.SetValue(0.0)
     rfore.SetValue(0.0)

My python page
My ShareCG freebies


tvining ( ) posted Mon, 23 November 2009 at 11:14 AM

file_443634.jpg

Thanks, Ockham--unfortunately that made things worse--the twist became jerky with big sections shifted up or down.

The original bvh is recorded with the NaturalPoint mocap system, captured to their skeleton, then streamed to Daz M4 via their plugin for Daz Studio, then exported to BVH and imported into Poser, so it's quite a journey and I'm frankly amazed that it works as well as it does. This Forearm Side-Side issue is mostly a problem at more extreme values since less extreme values aren't that noticeable. That said, it would be nice if there was a way to fix it.

I'm sending some screen shots of what I am getting. It may be coincidence, but note in the final manually adjusted version I used the Side-Side value to alter the Twist and Bend of the Forearm, and those values seem to make it look right, tho when I tested this with other places it didn't work as well, so it's not that consistent, from what I can tell.

Thanks again!--Tim


ockham ( ) posted Mon, 23 November 2009 at 11:30 AM

Ah.  So it has gone through a different form of rigging.  There's probably no neat
"mechanical" way to solve the problem.  

Maybe you could simply adjust the joint parameters of the forearm so the Side-Side
doesn't look like Mike has grown an extra joint?  Ideally that angle should have the
same center pivot as the Bend, but it looks like the center is off.

My python page
My ShareCG freebies


tvining ( ) posted Mon, 23 November 2009 at 1:08 PM

Okay, thanks! I'll give that a try and let you know how it goes.

--Tim


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.