DigiCalimero opened this issue on Jul 14, 2005 ยท 15 posts
DigiCalimero posted Thu, 14 July 2005 at 1:58 PM
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?
nruddock posted Thu, 14 July 2005 at 2:55 PM
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).
DigiCalimero posted Fri, 15 July 2005 at 5:35 AM
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
DigiCalimero posted Fri, 15 July 2005 at 7:45 AM
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
DigiCalimero posted Fri, 15 July 2005 at 8:42 AM
What I'm trying to do basically is get to a certain node of a material in a prop....
nruddock posted Fri, 15 July 2005 at 11:27 AM
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.
DigiCalimero posted Fri, 15 July 2005 at 1:09 PM
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.
nruddock posted Fri, 15 July 2005 at 5:26 PM
The parameter return value is in PNU, the value on the dial is in whatever units you have set (cm would be my guess).
DigiCalimero posted Sat, 16 July 2005 at 7:19 AM
What is PNU? I kept having trouble finding the animated shader param, finally I looked in the cr2 and they get added under the BODY actor....wish they mentioned these things in the manual... Thanks for your help, you happen to work for CL? :)
DigiCalimero posted Sat, 16 July 2005 at 9:14 AM
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
DigiCalimero posted Sat, 16 July 2005 at 9:20 AM
Ok, after reading the regular manual, I found out :) Poser Native units.....ok.....so I guess it's better to use PNU in this tutorial so there are no mixups between people using different real world measurement in their scenes?
Message edited on: 07/16/2005 09:20
nruddock posted Sat, 16 July 2005 at 11:16 AM
No, I don't work for CL. Poser / 3D graphics is (mostly) a hobby.
face_off posted Mon, 25 July 2005 at 9:19 PM
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
DigiCalimero posted Tue, 26 July 2005 at 2:02 AM
Yes, it was sort of an exercise. The script is done now, although for some reason when I add more than one material node that needs to be updated, it doesn't update automatically when I move the light, I have to click to run the script whenever I move the light.
svdl posted Sun, 28 August 2005 at 7:13 PM
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