Thu, Oct 3, 6:19 AM CDT

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: JointVertexWeights and TwistVertexWeights


kuroyume0161 ( ) posted Sat, 13 November 2004 at 1:10 PM · edited Thu, 03 October 2024 at 6:15 AM

Anybody have experience using these two Poser Python methods?

Each returns a [FloatType list] for an Actor, but not certain how many vertex weights will be returned. I'm guessing that it would equal the number of Actor vertices (?). But then children affect their parents, so this may include them, or just be a composite of the weights on the Actor including its childrens' influences. Uncertain.

Thanks for any input!

Message edited on: 11/13/2004 13:11

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


ockham ( ) posted Sat, 13 November 2004 at 2:13 PM

You roused my curiosity. I don't know what it's for, but it's interesting! After a bit of playing: The number of entries is exactly the same as the number of verts. Seems to be a very sparse array, though; lots of zeroes. Not every part has an array, and most parts seem to have the set only for one dimension. I'm guessing that this tells how the joint moves in a vector form. The verts that have 1.0 for "x" will move (for Bend) on an arc with radius = 1.0 * current scaled length; those with 0.5 for "x" will Bend on an arc with radius = 0.5 * length. Does that make sense? Stewer will undoubtedly know the true answer.

My python page
My ShareCG freebies


ockham ( ) posted Sat, 13 November 2004 at 2:56 PM

Better guess: After more playing, it looks like the weights indicate which vertices need the most distortion when the joint bends in this direction. The facets that keep their shape under this rotation have zero entries in the list.

My python page
My ShareCG freebies


kuroyume0161 ( ) posted Sat, 13 November 2004 at 3:45 PM

Right, that's what I was expecting. Most likely, the values are between 0.0 and 1.0. Actually, you're close. They indicate the amount of influence of the joint on the vertex. 1.0 means move with the joint, 0.0 means don't move at all, inbetween (blend zone) means move with a percentage of joint movement.

But, since my Python experience is very limited, how did you go through the list. Here's my untested code for printing them out:

<br></br>
# --------------------------------------<br></br>
# VertexWeight Info<br></br>
# --------------------------------------<br></br>
def printWeights(weights):<br></br>
i = 0<br></br>
for wgt in weights:<br></br>
print " ", i, ": =", wgt<br></br>
i = i + 1<br></br><br></br><br></br>
# --------------------------------------<br></br>
# Hierarchy Info<br></br>
# --------------------------------------<br></br>
def printHier(actor, numTabs):<br></br>
if(not actor):<br></br>
return<br></br>
tab = ' ' + ' __ '*(numTabs-1) + '_'<br></br>
print tab, actor.Name()<br></br>
children = actor.Children()<br></br>
if(children):<br></br>
for child in children:<br></br>
printHier(child, numTabs+1)<br></br><br></br><br></br>
# --------------------------------------<br></br>
# Define a function to print out the vertex weights of a Poser
Actor.<br></br>
# Use some globals so the we can tally them as we go<br></br>
# --------------------------------------<br></br>
def printActorWeights(iActor):<br></br>
maxName = 20<br></br>
print " ", iActor.Name(), ' '*(maxName - len(iActor.Name())),<br></br><br></br>
# --------------------------------------<br></br>
# Returns<br></br>
# --------------------------------------<br></br>
axis = ["x", "y", "z"]<br></br>
for a in axis:<br></br>
weights = iActor.JointVertexWeights(a)<br></br>
if (weights):<br></br>
printWeights(weights)<br></br>
else:<br></br>
weights = iActor.TwistVertexWeights(a)<br></br>
if (weights):<br></br>
printWeights(weights)<br></br>
else:<br></br>
print "No Weights for axis ",a<br></br><br></br><br></br><br></br>
# --------------------------------------<br></br>
# Get the Poser scene object...<br></br>
# --------------------------------------<br></br>
scene = poser.Scene()<br></br><br></br>
# --------------------------------------<br></br>
# For every figure in the scene,<br></br>
# print out how many polygons it has (if it has geometry)<br></br>
# and keep a total as we go<br></br>
# --------------------------------------<br></br>
figs = scene.Figures()<br></br>
for fig in figs:<br></br>
print fig.Name()<br></br>
body = fig.Actor('Body')<br></br>
print " Hierarchy:"<br></br>
printHier(body, 0)<br></br>
print<br></br>
print " Actor info:"<br></br>
actors = fig.Actors()<br></br>
for actor in actors:<br></br>
printActorWeights(actor)<br></br>

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


ockham ( ) posted Sat, 13 November 2004 at 3:54 PM

Here's how I moved them. This is obviously not a general-purpose script..... it just moves them in some direction, proportional to their vertex weight, so you can see which areas move more and which move less. You'd have to manually edit the "z" to the other dims. import poser scene=poser.Scene() TheFig=scene.CurrentFigure() OneActor=scene.CurrentActor() Geom=OneActor.Geometry() L=OneActor.JointVertexWeights("z") # Hold the list for i in range(Geom.NumVertices()): ~V=Geom.Vertex(i) ~V.SetZ(V.Z()*(1.0+L[i])) # Move in proportion scene.DrawAll()

My python page
My ShareCG freebies


kuroyume0161 ( ) posted Sat, 13 November 2004 at 4:51 PM · edited Sat, 13 November 2004 at 4:52 PM

[Cue "Mission Impossible" theme music]

Here's your mission, if you choose to accept it. What would be really cool would be some way to actually "paint" the vertex weights onto the figure so that someone can see a visual representation of the weights (I'm thinking LightWave and Cinema4D style display).

[/Cue]

This message will self-destruct in ...
I lie. :)

My code works, but it also seems to crash unexpectedly with an unknown error code = -50. (?) Works for the most part otherwise. I'm printing out the weights to file for an entire Figure's actors, so might be blowing the stack or heap for Python scripting.

Message edited on: 11/13/2004 16:52

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


ockham ( ) posted Sat, 13 November 2004 at 4:53 PM

Yup, sounds like a stack-blow error. I'll see if there's a way to color the points.

My python page
My ShareCG freebies


kuroyume0161 ( ) posted Sat, 13 November 2004 at 5:53 PM

Found the solution to the error - the console output was not only slowing down the file write considerably, but it was causing the blow out. I'll try the same. If you have Poser 5, shader nodes may be an interesting approach.

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


ockham ( ) posted Sat, 13 November 2004 at 6:11 PM

Yes, the console output gets jammed up way too easily. I'm just about there on the coloring.... this raises some interesting possibilities.

My python page
My ShareCG freebies


ockham ( ) posted Sat, 13 November 2004 at 7:23 PM

file_141174.jpg

Here's a first working version. The script is built to do the Z axis, but I've given you the alternate lines (remmed out) to form the other 5 possible scripts. To use, just select a body part and hit the script. It paints the vertex weights on the body. I think you'll see how to make make finer color gradations, if that's desirable.....

My python page
My ShareCG freebies


ockham ( ) posted Sat, 13 November 2004 at 7:24 PM

Content Advisory! This message contains nudity

file_141175.jpg

Here's poor Misaki after a body-painting session.

My python page
My ShareCG freebies


kuroyume0161 ( ) posted Sat, 13 November 2004 at 10:26 PM · edited Sat, 13 November 2004 at 10:27 PM

Looks weird, but cool. I haven't had as much success. I'm trying to use red-yellow instead of grey gradiations. Instead, I'm getting blue - almost like SetDiffuseColor() in Poser 5 is (b,g,r) and not (r,g,b). Strange.

I'm going to keep playing with it to see what can be done. :I

Almost forgot: Thanks for the script!! I'd be lost otherwise.

Message edited on: 11/13/2004 22:27

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


ockham ( ) posted Sat, 13 November 2004 at 10:36 PM

I believe P5 has a separate DiffuseValue variable, which affects the other settings.... I don't see a way to set that in Python. Try SetTextureColor?

My python page
My ShareCG freebies


kuroyume0161 ( ) posted Sun, 14 November 2004 at 1:11 AM

file_141177.jpg

This is very fun!! ;I Python in Poser 5 is definitely not the same as PP, but I have finally managed to paint all of a figure's actors on any axis from red to yellow (0.0 to 1.0). I've attached the script for you to modify. Thanks for the enjoyment and challenge!!!

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


kuroyume0161 ( ) posted Sun, 14 November 2004 at 1:12 AM

file_141179.jpg

And here's an image showing the results using the Y axis.

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


kuroyume0161 ( ) posted Sun, 14 November 2004 at 1:13 AM

Note that the eyes and hip do not get painted because they don't have JPs. In a general sense, their weights are all 1.0 by default.

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


ockham ( ) posted Sun, 14 November 2004 at 11:19 AM

Looks good! I'm trying to think of "real" uses for the facet-by-facet painting method. It's obviously a good tool for model-building; visual indicator for various types of internal info.

My python page
My ShareCG freebies


stewer ( ) posted Sun, 14 November 2004 at 4:54 PM

Ooooohhh....this is so cool! I'm away for a couple of days and you guys do this - cheers to you! lifts glass


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.