Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
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
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
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
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
[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
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
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
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
My python page
My ShareCG freebies
Content Advisory! This message contains nudity
My python page
My ShareCG freebies
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
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
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
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
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
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
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.
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