Sat, Nov 9, 5:22 PM CST

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: Restarted Wish List


ockham ( ) posted Mon, 03 May 2004 at 5:59 PM · edited Sat, 09 November 2024 at 5:21 PM

Let's see if this will work. It's impractical to get through 100 very old entries, especially when Renderosity is having one of its hissy-fits. Beginning with a repost of the last new request, from BabyDollTX. ...Wonders if it would be possible to script turning off shadow casting for all parts of a figure? anybody tried it?

My python page
My ShareCG freebies


ockham ( ) posted Mon, 03 May 2004 at 6:10 PM

Strangely enough, that's not possible. The visibility of each part is controllable from Python, but not the Cast Shadows. (It seemed so inevitable that I went ahead and wrote most of the script just now, only to find that the necessary function isn't there!)

My python page
My ShareCG freebies


Ajax ( ) posted Wed, 05 May 2004 at 9:41 PM

Attached Link: Ambient Occlusion

Sheesh, what a shame. Something to control all of those object properties like cast shadows, polygon smoothing, bending etc would have been great. I've got a big, complicated wish. I'd love to see something that does ambient occlusion. Ambient occlusion is used to fake radiosity as well as to product grime maps where grime fills nooks and crannies of a model. It's the procedure behind plugins such as DirtyNuts for Cinema 4D. What I have in mind is something that outputs the results as a greyscale image using the template of the object concerned, so you can then use that image as a texture that dulls the object in the places that should be dark/dirty. A google search will turn up lots of info on ambient occlusion, but I've picked out one particular link and posted it above because it explains the technical aspects pretty clearly I think.


View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message


Ajax ( ) posted Wed, 05 May 2004 at 9:47 PM

Attached Link: DirtyNuts

Here's an example of using the same approach to create dirt maps with DirtyNuts.


View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message


ockham ( ) posted Wed, 05 May 2004 at 10:02 PM

Some of those properties are reachable. Polygon smoothing is. (ockhamsbungalow.com/python/SmoothOnOff.zip) I really thought Cast Shadows would be accessible, because it's an "old" menu choice. But no. I'll look at the dirt. Somebody (Shadownet?) asked me about this once before, and frankly I don't quite see the purpose.... Or rather, I don't see why it needs to be done at run-time. Is there a reason why this can't be done as part of painting the texture map?

My python page
My ShareCG freebies


ockham ( ) posted Wed, 05 May 2004 at 10:41 PM

Maybe I do see the point after all. The Problem: a UV map is a set of flat projections, with no reference to the actual angle of any side. Let's say I want to show raindrops on the upward-facing parts of a car, by 2D methods. (Displacement map.) The UV map won't tell me which facets are really facing upward at this moment, but Python can get that info from the model itself at this moment. The script would then (1) translate these facets to the UV locations; (2) pick up a (specified) bitmap that is solidly covered with 2D raindrops; (3) OR the pixels of the bitmap with the original displacement map, weighting the mix so that more of the raindrop bitmap is mixed where the real surface is facing upward right now; (4) reapply the mix to the model before rendering. Is that close to your idea?

My python page
My ShareCG freebies


Ajax ( ) posted Wed, 05 May 2004 at 10:41 PM

It was probably me that asked you about it. No, there's no reason you can't paint the map by hand, it's just a total pain doing it. The idea of something like this is that you can save yourself days of agonizingly dull mucking about by running the script and getting a jpeg that shows you exactly where you need to put your grime. I see the script as being a time saver that helps you create your texture map. When you work with models of buildings or industrial objects, there are often parts which intersect and should have grime at the intersection point, but which do not have the intersection point marked on the UV map. This means that to figure out where to put the grime, you have to take a guess, draw it on the texture, render, see how well you guessed, then adjust your texture and repeat until you've managed to put the grime in the right spot. It takes ages. Even something that just draws the intersection lines onto the UV map would be tremendously helpful, but something like DirtyNuts will not only find those correct spots on the UV map for you, but will also draw the grime there so you can just composite it with your colour map to get a nice dirty texture.


View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message


andygraph ( ) posted Thu, 06 May 2004 at 5:54 AM

ok repost my idea about a python many usefull for animator: - tracking 2d/3d for P4 PP and later - example: You import a footage in poser (in footage a real ball red move up and down) with this python i can lock the color of this ball to the hip of a character. note: Maybe will better create a parent from a marker() (you would can rename inside the python interface) and a joint of the character. About the rotation of body part will see later ... ()this marker can move with tracking from a color or a contrast luminace zone best regards; Andygraph


nruddock ( ) posted Thu, 06 May 2004 at 5:01 PM

file_108037.gif

#6 and #7 If you have P5 you can do part of this with Nodes in the material room. What is needed is the angle between the Normal and the global Y axis. From **Y**.**N** = |Y||N|cos(g), we want g (but have to settle for just cos(g)). Y = (0, 1, 0) length 1 N = (x, y, z) length 1 giving y = cos(g)

Which is equivalent to the N and component nodes in the picture.


Ajax ( ) posted Thu, 06 May 2004 at 5:58 PM

Yeah, you can handle what Ockham was talking about in post 6 with that. It's a very different thing to ambient occlusion though. Also, you can't bake it to an image map. I might try to put togethers some pictures to show what I'm looking for.


View Ajax's Gallery - View Ajax's Freestuff - View Ajax's Store - Send Ajax a message


nruddock ( ) posted Thu, 06 May 2004 at 8:16 PM

file_108038.gif

More examples would be good. I've seen this page [Ambient Occlusion](http://www-viz.tamu.edu/students/bmoyer/617/ambocc). To me it looks similar to what the ProbeLight node does, but I could be mistaken. ([The Probelight node](http://www.keindesign.de/stefan/poser/probelight.html) and [An Efficient Representation for Irradiance Environment Maps](http://graphics.stanford.edu/papers/envmap)) Single overhead spotlight, left half normal, right half with ProbeLight nodes plugged into Alternate_Diffuse.


PabloS ( ) posted Wed, 12 May 2004 at 10:06 PM

.


LeeMoon ( ) posted Sun, 16 May 2004 at 6:28 AM · edited Sun, 16 May 2004 at 6:31 AM

Don't know if this is possible/worthwhile...
I've just bought the P5 upgrade for Mac and it has this nifty script to calculate the distance from camera to object. So, when doing DOF renders it gets me most of the way to setting things up properly. What I'd like to suggest is:
A script that will generate the camera to obj distance and also calculate the "in focus" range based on the other camera settings. Apply those calculations to 2 simple planes (which are parallel to the camera plane) marking each side of the "in focus" range. This would provide visual markers for the focal zone so you can clearly view what will be in/out of focus before rendering.
Don't know if it can be done - or even if anyone else wants to see it (LOL!)
Thanks everyone!
Lee

Message edited on: 05/16/2004 06:31


nruddock ( ) posted Sun, 16 May 2004 at 7:45 AM · edited Sun, 16 May 2004 at 7:49 AM

Attached Link: http://www.keindesign.de/stefan/poser/dof_p5.html

I knew I'd seen something somewhere recently. A starting point for a more featureful DOF script ?

Message edited on: 05/16/2004 07:49


LeeMoon ( ) posted Sun, 16 May 2004 at 11:16 AM · edited Sun, 16 May 2004 at 11:30 AM

It's me again. :)
Thanks for the pointer to Stefan's DOF/P5 tutorial. That was the first place I went when I started experimenting with DOF. He did a good job of explaining it.

Now that I've been thinking about my request for a DOF script, it hit me that what I really want is a way to figure out what value to put into the F-Stop field in the Render Options panel. Finding the Focal Distance is trivial thanks to the existing script(s). It would be nice to see a graphical representation of the Focus Plane (perfect focus plane), the Near Focus Plane (everything between this plane and the camera is fuzzy) and the Far Focus Plane (everything behind this plane is fuzzy). I'm not sure if knowing the Focal Distance and the camera's Focal value are sufficient to calculate the F-Stop to achieve clear focus within the bounding box of the Near and Far Focal Planes.

Oh, since I've been toying with all of this today, I've got a "no script required" method of deriving the Focal Distance directly within Poser. This method seems to work fine so far, but I've only used it in a few test renders.

Here's the method:

  1. Create a new empty scene (lit as you please.)
  2. Load a cube prop.
  3. Scale it up to around 750%
  4. Z-scale it down to 0.5%
  5. Make sure the Main Camera is set to it's standard position (looking straight along the z-axis.)
  6. Parent the flattened cube to the camera.
  7. Goof around with the cube's origin until it's directly in the middle of itself.
  8. Set the cube to be non-shadow casting, not visible in ray tracing, display origin and make it transparent. You should end up with a flat plane (displayed as the standard preview transparent screen door effect) with the green origin lines marking the exact center of the plane.
  9. Moving the camera should keep the cube prop centered directly in the view.
  10. Use the cube prop's zTran dial to move the plane closer/further away from the camera. This is the Focal Distance (well, the Absolute Value of it) that you will use to plug into the Render Options/DOF box.
  11. Load some items into the scene and ONLY USING the zTran dial, move the cube plane in and out. Where the plane intersects the object(s) will be your zone of focus. Enter the zTran value into the Render Options "Focal Distance" field (don't forget to enter it as a positive number!) Depending on your F-Stop, things will get fuzzy in front of and behind this plane. I've found that using the plane to lock focal distance on gives much finer control over where focus occurs.

Sorry about the long post. I hope this inspires or helps someone! :)
Lee

Message edited on: 05/16/2004 11:19

Message edited on: 05/16/2004 11:21

Message edited on: 05/16/2004 11:30


Netherworks ( ) posted Fri, 02 July 2004 at 10:05 AM

Need to add some code to a script to determine if a morph target has actual deltas or not. If you could just tell me what python logic to use it would help out quite a bit :)

.


Connatic ( ) posted Sun, 08 August 2004 at 5:58 PM

After reading a thread on this topic I thought it would make a good Wish List contender - How about a python script to enable the Cameras to be visible in the workspace and to be manipulatable? The thread mentions that this is possible using the hierarchy editor, but a python script would be much better.


ockham ( ) posted Sun, 15 August 2004 at 6:00 PM

Here you go. As usual, change the ~ tildes to tabs. import poser for OneActor in poser.Scene().Actors(): ~if OneActor.IsCamera(): ~~OneActor.SetOnOff(1)

My python page
My ShareCG freebies


darken666 ( ) posted Mon, 16 August 2004 at 9:08 AM

Saw an intersting idea here at http://www.renderosity.com/messages.ez?ForumID=12356&Form.ShowMessage=1875704 and was wondering if someone could make a python script that will do the following: 1. create a toon light shader with the light color at white and dark color at grey, and then plug that into the alt-diffuse. 2. move the current diffuse texture node over to the toon shader, setting the diffuse value to zero on the main diffuse. 3. not affect any other settings. 4. do this for an entire scene or at least a whole object at a time. I don't know python so I don't know if this is possible or not, but the settings yield a good result so I'm hoping there's a way to automate things. I'm going to try to learn enough python to do this myself, but I'm not sure how difficult the task is.


ockham ( ) posted Mon, 16 August 2004 at 9:15 AM

This is most likely impossible. Python can't reach the P5 materials system (nodes, shaders) in any direct way. May change in a later version, but for now, the materials are just out of Python's reach.

My python page
My ShareCG freebies


stewer ( ) posted Mon, 16 August 2004 at 10:37 AM

Ambient Occlusion (at least, the popular ray traced kind) will not be possible as a Python script, unfortunately. This is something that would need to be implemented as a shader node, like in Pixels:3D. However, we have been using something incredibly similar to AO for a long time now: These "global light sets" are very close to depth map based AO, see this page. Looks familiar, doesn't it? You can actually bake AO to textures and use them in Poser. I did that with a custom shader in Pixels that would export me the rendered shading a as a texture, but it still needs some major improvements. It should be possible to do it with pther programs that support texture baking, e.g. 3ds or C4D.


andygraph ( ) posted Mon, 16 August 2004 at 10:56 AM

hem hem ... the "python bvh mixer" ? ;-)


Connatic ( ) posted Mon, 16 August 2004 at 6:35 PM

I tried the Visible Camera script, but got an error. I removed the tildes and tabbed the rest of the lines over once and twice. Maybe I am doing something wrong. I selected a camera and activated the script, getting a syntax error.


ockham ( ) posted Tue, 17 August 2004 at 12:58 AM

file_108039.gif

Try it this way, via the attached text. Copy the text, rename it to a .py file. I just tested it, and it worked for me in P4.

My python page
My ShareCG freebies


ockham ( ) posted Tue, 17 August 2004 at 1:01 AM

I'll think about the mixer again. Yesterday I was playing with BVH files and realized it's necessary!

My python page
My ShareCG freebies


andygraph ( ) posted Tue, 17 August 2004 at 4:02 PM

i agree ;-)


darken666 ( ) posted Tue, 17 August 2004 at 10:22 PM

Hmm That'll have to go on the list of things to wish for in the next poser iteration I guess. Is there a way to alter a MAT file to the same effect? If all else fails I suppose I can just see if theres a way to batch replace material listings or something like that.


svdl ( ) posted Fri, 27 August 2004 at 8:01 PM

There is something about mixing BVHs on the net. Can't remember the link, but it's a dissertation by an American student, from 2001 I believe. He's done quite some research on joining a walk sequence to a run sequence and stuff like that. I assume that's what you want?

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


svdl ( ) posted Fri, 27 August 2004 at 8:14 PM

The only way I can think of accessing the material room is having the script save the current scene, open the PZ3 as a text file, manipulate the right lines, save again and then force Poser to reload the scene - I'm not even sure the "revert to saved" command is accessible from Python. Very clunky. Heck, I wish Curious Labs would build their programs the way Microsoft and many Java programmers do, exposing functionality via a programmatic interface, and the user interface just calls the programmatic interface. A simple practice that'll make sure your app is always fully scriptable.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


Connatic ( ) posted Fri, 27 August 2004 at 9:01 PM

Thanks Ockham, The "make camera visible script" is very useful.


svdl ( ) posted Fri, 27 August 2004 at 9:35 PM

A wish: a callback utility that'll make sure the hierarchy window opens with all its trees collapsed instead of fully expanded. Very useful when parenting something in large scenes.

The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter

My gallery   My freestuff


FyreSpiryt ( ) posted Sat, 04 September 2004 at 12:37 PM

I learned a neat trick for working with lighting. When you're trying to get a light set to look right, you render the scene multiple times, each time with only one light on. Then you bring the renders into an image editor, layer them, and set all but the bottom layer to "screen". This simulates what the lights will look like when they're all rendered at once, and you can adjust the intensities by changing the layer opacities until you get the effect you like. For complex scenes, it can be much faster than tweaking a light, rendering to see how it looks, tweaking again, and so on.

Unfortunately, it can be a pain to turn manually off all the lights but one, render, turn that one off and another one on, and so on. Also, Poser 5 seems to lose the light's shadow settings (shadows on or off, raytraced or depth mapped) when you turn it off, and you have to reset them and hope you remember which is which.

What I'd love is a script that notes each light's shadow settings, turns them all off, renders and saves a series of images with only one light turned on with the proper shadow settings, then turns them all back on with the right shadow settings when it's done.


ockham ( ) posted Sat, 04 September 2004 at 2:21 PM · edited Sat, 04 September 2004 at 2:22 PM

I'll do that. Should be easy to strip down
from my LightPanel.

It won't be quite as automatic as
it should be, because Python can't save
finished renders to disk for some stupid
reason.

So there are two possible ways to go:BR>

  1. Leave its renders stacked up in the Poser
    interface, where you can click on them
    to examine or save manually.

  2. If you're not animating, the script could
    put each light into one frame. Then you
    could save the animation as an Image Sequence
    in the usual way.

Which is better?

Message edited on: 09/04/2004 14:22

My python page
My ShareCG freebies


FyreSpiryt ( ) posted Sat, 04 September 2004 at 2:41 PM

Ooh, thank you! Can you leave renders stacked up? I thought Poser would only allow one image window at a time, but I've never tried it. If so, that might be the best way for me. But I'm not animating, so either one would be fine. Whichever's easier for you! Thanks again!


ockham ( ) posted Sat, 04 September 2004 at 3:03 PM · edited Sat, 04 September 2004 at 3:07 PM

Okay, I'll do it the stacked way. One other fussy little point: I'm pretty sure most light sets are simply numbered, so the script will take the lights in numerical order, leaving "Render 1" as the scene with Light 1 alone. If the light set has named lights, as is true of SnowSultan's "Globall", this might be less satisfactory. (I think the underlying internal name is still a number.)

Message edited on: 09/04/2004 15:07

My python page
My ShareCG freebies


ockham ( ) posted Sat, 04 September 2004 at 5:04 PM
FyreSpiryt ( ) posted Sat, 04 September 2004 at 10:14 PM

It worked just perfectly! It rendered all of the images as expected, settings were fine, and it didn't have any trouble with named light sets. Thank you so much! This will save me oodles of time! *<:)


ockham ( ) posted Mon, 06 September 2004 at 2:28 PM

Great! Incidentally, I just pulled the intensity of the unused lights down to zero instead of turning them off. Seemed easier, and apparently it works just as well.

My python page
My ShareCG freebies


FyreSpiryt ( ) posted Mon, 06 September 2004 at 5:13 PM

Does it put the intensity back where they were set before, or does it go to 100? I only tried it on sets with all the lights at 100, but I do sometimes use lower intensities.


ockham ( ) posted Mon, 06 September 2004 at 9:25 PM

It puts back the original for each.

My python page
My ShareCG freebies


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.