Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
Probably easiest to run a script each time the light is updated.
There are alternatives however.
It might be possible to set up an ERC connection between the light position channels and (an animated) node input, or use Parameter update callbacks (these wouldn't re-estabish on loading without some text editing though).
I think I'll try the SetCallBack, but I'm still struggling with the basics :)
This is really the first time I'm trying Python and using it with Poser and I'm going step by step. For example I'm just trying to see if I get the xtran param of Light 1, but when trying to test the script, it prints out this:
Parm object at 0x0E24D538
It seems it returns the object instead of the objects property....
The script so far:
try:
scene = poser.Scene()
thelight = scene.Actor("Light 1")
lightX=thelight.ParameterByCode(poser.kParmCodeXTRAN)
print lightX;
except:
print "bleh"; >>EDIT I had to add .Value(), ok makes sense :) But the Lights xTran is: -191.743249 and the printout reads: -0.73148703575
Message edited on: 07/15/2005 05:45
Well another thing, I have not idea why this is giving me an error:
scene = poser.Scene()
thelight = scene.Actor("Light 1")
lightX=thelight.ParameterByCode(poser.kParmCodeXTRAN).Value()
lightmat=thelight.FindMaterialByName("Preview");
print lightmat;
it says:
AttributeError: FindMaterialByName
Message edited on: 07/15/2005 07:46
Message edited on: 07/15/2005 07:46
cough Documentation Typo cough
The actual method name is "Material"
Getting nodes is only possible in P6 using
lightMat = theLight.Material("Preview")<br></br>tree = lightMat.ShaderTree()
If you want this to also work in P5 (or avoid having to navigate the shader tree in P6), you need to set the node input to animating, which will create a parameter on the figure / prop, which can then be manipulated by a callback on the light parameter.
Take a look at the "parmCallback.py" sample script to see how to set up callbacks.
Ah damn manuals.....I get the impression there's not a lot of help for newbies to learn Python for Poser although it looks quite powerful. The reference manual has almost zero examples. I looked at callbacks and I think I understand how they work, but do you have any idea why I get such different numbers for the xtran? Seems I have to multiply them with 262...something to get the actual xtran of the light.
The thing is I need to do this part of that tutorial:
" are multipled by the normalized vector from the main light (0.742592, 0.513875, -0.429522). To work this vector out, take your main light, convert it to a spotlight (if its not one already), take the X, Y and Z coords (xTran, yTran and zTran from the Transform section of the light info in Poser) of the light and sum the square of coordinates. Then take the square root of this sum (which is called the Vector Length in mathematical terms.) and divide the original light coordinates by this number. This gives you the Normalised vector for the main light "
I've gotten the callbacks to work, the mat node updates automatically as I move the light, but what are these PNU measurements? Can I use them directly in the case of this tutorial?
Message edited on: 07/16/2005 09:16
Hi Digi.... I'm not absolutely sure what you are trying to do here. Are you trying to write a python srcipt to automate the process in the tutorial? If so - there is already one to do that.
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
Personally I don't like working in Poser Native units, I prefer "real-world" units (usually cm). But PoserPython only works in PNU.
The easiest way to find out what conversion factors you need is by loading a primitive into an empty scene, set the units to PNU in preferences, then move the prop to xTran=1.000.
Switch back to your preferred unit and read the xTran dial on the prop - there's your conversion factor.
Message edited on: 08/28/2005 19:14
The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter
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.
I'm following this great tutorial about skin shading: http://www.users.on.net/~pkinnane/RealSkinShaderTutorial.html and the author says he uses a python script to automatically enter the xyz coords of a light into some material nodes. How is that done? Would such a script need to be run every time you adjust the light position, or do you run it once and the material nodes update?