Sun, Apr 14, 3:16 PM CDT

Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Mar 19 1:03 pm)

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: Cloning Objects


adp001 ( ) posted Sat, 03 June 2023 at 8:33 AM · edited Sun, 14 April 2024 at 9:53 AM

My first approach of a Python Script to the topic "Cloner". I needed something like that to create landscapes.

Important for me is the speed (what I have seen so far of such scripts for Poser, was not very convincing).
Currently my script generates 374 Poser props with a total of over 2 million polygons (5365 per prop) in 15 seconds, aligned on an uneven ground consisting of 374 polygons (on my old and small Dell Optipex Plus with I5 CPU; the machine I usually use for programming and not for graphical stuff :) ).

Preparations: From a Poser standard prop (Cloth Plane?) I made a "ground", which I deformed with the help of the Morph-Brush (ground waves).
In Blender I reduced a free object (plant) to a stem and adjusted the number of polygons drastically down. I then exported the whole thing as a wavefront file for Poser (scaled).

The result can be seen in the picture.

i3yAG2IGATnUNm3hInUz4SIDO6hSI35oSGOG8XCp.png


My script's first task is to provide a generator in the form of a function that returns the center and direction of each polygon as a coordinate and angle, respectively. The direction information is used to "plant" the generated plants vertically into the ground, so to speak.

To make it look a bit more lively, the angle of rotation is randomly redetermined for each generated plant. Another step would be to randomly change the tilt angle a bit as well. For most objects, however, this will not be necessary (such as the plant shown).

nW0qbvHq6zEYIcwDXunav0NbP480kKaCORJNbyud.png

g7yS9R4gpssxUv0LE5blZA2xwEbG6Ekbykzfc402.png

For my needs, the script does everything I need at the moment. However, if there is interest, the whole thing can be further developed here in the forum as an "open source project". Above all a GUI is missing to make it usable for non-programmers.

If you are interested: Reply accordingly.




ThunderStone ( ) posted Sat, 03 June 2023 at 11:17 AM

That's great! Could use it on TerraDome for creating a forest . GUI? I am not a programmer but would like to help out with usability issues. 


===========================================================

OS: Windows 11 64-bit
Poser: Poser 11.3 ...... Units: inches or meters depends on mood
Bryce: Bryce Pro 7.1.074
Image Editing: Corel Paintshop Pro
Renderer: Superfly, Firefly

9/11/2001: Never forget...

Smiles are contagious... Pass it on!

Today is the tomorrow you worried about yesterday

 


adp001 ( ) posted Sat, 03 June 2023 at 12:12 PM · edited Sat, 03 June 2023 at 12:12 PM

73wknfuoKd9AFAdMly6jds27pFgviiE8vJhQNk97.png

That's 748 props now. Randomly selected from a list of props (here now just 2 pieces, but the list of selectable props can theoretically be infinitely long). Two props each were set per polygon.
Number of polygons: 5196125.
Poser needed 50 seconds to generate the props.

By the way, the speed can only be maintained if the clones have the same textures. If you change even a small part of the texture, the speed drops dramatically (I stopped after 10 minutes). So setting random color values with a large amount of props is impossible.

Plants used:

QPkNaSRufKbiGiLTTbi6rUXXAW3TTswOzfN4aT6i.png




adp001 ( ) posted Sat, 03 June 2023 at 12:17 PM
ThunderStone posted at 11:17 AM Sat, 3 June 2023 - #4467030

That's great! Could use it on TerraDome for creating a forest . GUI? I am not a programmer but would like to help out with usability issues. 

Why not! But does it make sense to generate something like this in Poser? Wouldn't it be better to do it in e.g. Blender if the result is not used in Poser (just out of interest)?




adp001 ( ) posted Sat, 03 June 2023 at 12:22 PM · edited Sat, 03 June 2023 at 12:23 PM
Just to have it said: The last render with Cycles didn't take one minute (CPU render).




adp001 ( ) posted Sat, 03 June 2023 at 1:05 PM

Maybe I should make clear that cloning is not only possible with plants :)

I think I'll do the next tests with strands of hair. Maybe some algorithm can be found, with which one can generate hair automatically.




adp001 ( ) posted Sat, 03 June 2023 at 3:52 PM · edited Sat, 03 June 2023 at 3:52 PM

The more props or polygons there are in total, the slower Poser will be when creating the props. The small computer I'm developing the script on (compared with my graphic workstation) has 16 Gig RAM and creates 1122 props with a total of 5580475 polygons in 125 seconds (so no linear slowdown, but almost exponential :)). The subsequent rendering goes quickly. However, if you move any prop to a different position, e.g. in the Hirarchy editor, Poser takes a seemingly infinitely long time until it reacts again.

I have run the script several times in a row. The result of the time needed is always the same and there were no problems. The number of polygons varied between about 4 and 6 million, depending on which props were randomly selected.

At this point, praise to Poser 12: During hours of testing with a really large amount of props and polygons, there were no crashes. Memory leaks do not seem to exist. The props are deleted and regenerated as expected.

Here is the result: 1122 props generated, 3 props per ground polygon, randomly selected from a set of 4 different props (where 2 props have the same geometry but different textures):

fdJfPJaK25wQtnhtgvnRtnEPA0VJcCoNvtVBGSLz.png




Y-Phil ( ) posted Sun, 04 June 2023 at 5:16 AM

Wow

PhYl.


Win10 on i7 8700K@4.3Ghz, 64Gb, Asus TUF Gaming RTX 4070 OC Edition, 2x 2Tb ssd + 6+4Tb hd  + 1x 8Tb hd + 1 10T NAS, Poser 11, Poser 12  and now Poser 13 


FVerbaas ( ) posted Mon, 05 June 2023 at 7:34 AM
Forum Coordinator

Looks good! 

I do not know whether you're in for suggestion, but would it be useful to distribute the objects with type, density, scale and rotation based on a map? Say a .png with an alpha channel: density read from alpha, scale from value, rotation from hue, type from saturation, or something like that? 


adp001 ( ) posted Mon, 05 June 2023 at 9:28 AM

FVerbaas posted at 7:34 AM Mon, 5 June 2023 - #4467187

Looks good! 

Thank you.

I do not know whether you're in for suggestion, but would it be useful to distribute the objects with type, density, scale and rotation based on a map? Say a .png with an alpha channel: density read from alpha, scale from value, rotation from hue, type from saturation, or something like that? 

The basics for maps are already implemented :)

I thought I use RGB as channels and alpha to mark the ground. I think RGB is easier to handle. Others use groups as mask where to allow clones. But I think that's too rough in many cases.

Right now I'm trying to figure out when Poser says "now I need a few minutes" and turns a deaf ear. This morning I had a test running that was gasping for air for 2 minutes after about 200 props were generated. So far I haven't figured out when and why this happens.





FVerbaas ( ) posted Mon, 05 June 2023 at 9:48 AM · edited Mon, 05 June 2023 at 9:52 AM
Forum Coordinator
adp001 posted at 9:28 AM Mon, 5 June 2023 - #4467194

The basics for maps are already implemented :)

Good!

I thought I use RGB as channels and alpha to mark the ground. I think RGB is easier to handle.

Maybe you're right. I named hue and saturation and value because of the similarity in function. 

Others use groups as mask where to allow clones. But I think that's too rough in many cases.

Fully agreed. I made same comment to the others also. 

Right now I'm trying to figure out when Poser says "now I need a few minutes" and turns a deaf ear. This morning I had a test running that was gasping for air for 2 minutes after about 200 props were generated. So far I haven't figured out when and why this happens.

Maybe faster to make one prop and just add to geometry, one group per clone. This would not burden Poser scene definition as much and also make scene management easier for the user. With the clones as groups in the prop geometry one can still approach and manage them individually, but also transform, delete, change texture of the whole lot in one go.




adp001 ( ) posted Mon, 05 June 2023 at 10:29 AM
FVerbaas posted at 9:48 AM Mon, 5 June 2023 - #4467195

Maybe faster to make one prop and just add to geometry, one group per clone. This would not burden Poser scene definition as much and also make scene management easier for the user. With the clones as groups in the prop geometry one can still approach and manage them individually, but also transform, delete, change texture of the whole lot in one go.


This is definitely the faster method. However, it is also not as user-friendly because you can no longer edit the individual clones (correct position, set textures, etc).

Right now, I'm generating the props using Poser's Python methods and copying the textures using a set of functions I published a while back. This is pretty fast overall - significantly much faster than loading each prop with Poser's library functions, for example.

Despite the possible alternative (which I might include as a second option), I would very much like to know where Poser got the hiccup.

Another alternative is to generate an OBJ file directly. Then you don't have the problem that you don't get the groups generated (Poser doesn't allow groups in self generated props).

But before we discuss further about possible features: Would you be interested in helping with the implementation/programming?




FVerbaas ( ) posted Mon, 05 June 2023 at 1:09 PM
Forum Coordinator
adp001 posted at 10:29 AM Mon, 5 June 2023 - #4467198

But before we discuss further about possible features: Would you be interested in helping with the implementation/programming?

Sure, as far as my limited capabilities go, of course. 

Just drop me a sitemail.





Ken1171_Designs ( ) posted Mon, 05 June 2023 at 7:57 PM

Isn't this what the "Scatter Tool" does?

full_5a365e7a62ac4016f4aa4c5ba621062e.jpg

You can scatter 3D or 2D objects over 2D or 3D surfaces with or without surface alignment. It can create entire forests using billboard trees that use only 1 polygon that can render super-fast, and won't slow Poser down.

image_df95405047efa98a19998f7be3909d05.jpg

All of these examples were scattered over the default Poser GROUND plane.

image_c35c6cd703dbc049d750b584799ee70d.jpg

image_b2aa822fa7669ef8389f0bceae77da55.jpg

Here's an example of scattering over 2D and 3D surfaces with surface alignment.

image_fad43380ff0bd118cb224371cb37dfbf.jpg

Surface alignment can be calculated even over morphed 3D objects.

image_251d4315f5fc4a707e1205abdbc7ec88.jpg

You can even scatter figures of you like, with or without surface alignment. 

image_2cb664f0a99b9dc01e3d5ae8c6f09962.jpg

The interface is very simple. Below is the new version for Poser 12 and 13, which added some new features, like scattering over custom areas we can PAINT with the Group Tool. 

image_c469e43a9bf9b5b7685242ffa2c9386d.jpg

More examples of scattering in Poser 12.

image_848d086907d4c65e696b4c76d36a24af.jpg

image_ca0d3ef1a03ec6b10347a2543e0a0b07.jpg

image_6c88ecd1292393937459ffecd55a7e47.jpg

Here's how you paint scattering areas with the Group Editor directly on the surface:

image_3daafa6e85def65d759a9f4b198f1951.jpg

Create real-time CROWDS with billboards:

image_530e4e97bea9c9467c217f126831d01b.jpg

Each person is a single poly, so Poser won't even notice there is a 100 people on the scene. They auto-follow the camera, so they are always facing the right way for renders. 

There is an older version for Poser 11 (Python 2), and a new one for Poser 12 and 13 (Python 3). 

Hope this helps. :)


adp001 ( ) posted Wed, 07 June 2023 at 6:03 AM
Ken1171_Designs posted at 7:57 PM Mon, 5 June 2023 - #4467241

Isn't this what the "Scatter Tool" does?

No.

Your tool would be a start, if the source code would be available.
This is the Python forum after all. It's about coding by yourself. And learning. Less about buying.

Furthermore: Your tool is too slow to generate several hundred props. And you can't limit areas to materials or colors used there, or use the color scheme to manipulate the generated scatter props.

Whoever needs the tool like you offer it will have already bought it. There is certainly no need for the advertising here.

I certainly don't want to step on your toes, but: The goal is to develop the whole thing here publicly. Open source and the way users need it.




EVargas ( ) posted Wed, 07 June 2023 at 7:01 AM

Folks, with all due respect, and trying not to heat up the conversation, I'd like to express my support for adp001.

This question of cloning objects is recurrent, and although solutions and workarounds already exist, there is certainly always room for improvement. There is still the issue of effective instancing etc...

I particularly use commercial solutions for modeling, texturing and others. But it's my preference, as I've learned and got used to that workflow, and it's still within my budget for the time being (which I hope to be able to maintain for some time to come).
Despite this, I think it's incredible and I will never criticize initiatives such as the Blender Foundation, for example, which popularized access to impressive 3D creation tools.

One area where I use open source solutions a lot is in web development, and I am extremely thankful it exists.

I think Ken's comment could certainly have been more subtle and respectful as it enters a thread that only seeks to help people. And a thread like this takes a lot of time for those who are participating / contributing. Especially the insertion of links and promotional images, as I doubt that everyone here reading this matter has not already known your solution.


Store | Website

"Art exists so that reality does not destroy us" - Friedrich Nietzsche


adp001 ( ) posted Thu, 08 June 2023 at 5:59 AM

@evargas: Thank you.

I have corresponded with user @FVerbaas and we have more or less decided to develop a "real" (😃) scatter tool as an open source script here in the forum.




Y-Phil ( ) posted Thu, 08 June 2023 at 9:20 AM
adp001 posted at 5:59 AM Thu, 8 June 2023 - #4467413

@evargas: Thank you.

I have corresponded with user @FVerbaas and we have more or less decided to develop a "real" (😃) scatter tool as an open source script here in the forum.

Wow cool!

PhYl.


Win10 on i7 8700K@4.3Ghz, 64Gb, Asus TUF Gaming RTX 4070 OC Edition, 2x 2Tb ssd + 6+4Tb hd  + 1x 8Tb hd + 1 10T NAS, Poser 11, Poser 12  and now Poser 13 


adp001 ( ) posted Thu, 08 June 2023 at 9:43 AM · edited Thu, 08 June 2023 at 9:44 AM
Y-Phil posted at 9:20 AM Thu, 8 June 2023 - #4467419
Wow cool!

Yes, I think so too :)
However, I'll open a new thread for it. And hope that we will not be harassed again by monstrous advertising 😃.





Ken1171_Designs ( ) posted Thu, 15 June 2023 at 2:28 PM

You guys would be surprised how many times I have seen people in the forums saying no scripts for Poser were ever made since Poser 12 was released. This probably happens because none of my script releases were advertised on the Rendo newsletter since 2020, and products get quickly buried on the store pages after a day or two, never to be seen again. 

I posted here because I was told by another user that someone here was saying Poser doesn't have a script for scattering objects. I don't usually read the forums, so I took their word on it, and showed my solution for those who are interested - I didn't mean to intrude. Every now and then somebody points me to a forum where someone is asking for a specific script, and I show them what I have.

I find it both shocking and disappointing when customers can't find what they want in the store, and assume it doesn't exist. Happens quite often - especially when it comes to scripts. Seems like FINDING products at Rendo leaves something to be desired. Just wanted to put things in perspective before you guys jump to conclusions about why I posted here. I apologize if it seemed like an intrusion. 


bwldrd ( ) posted Thu, 15 June 2023 at 3:32 PM

I have ken1171's tools and while good, there is always room for things with similar yet different functionality :)   I like the idea of being able to paint on where the objects scatter which his does, but I miss the being able to just randomly scatter props from a selected directory (instead of having to be in scene) which some of the earlier scripts (https://www.renderosity.com/marketplace/products/106855/i13-f68-gardentime-landscape-generator-for-poser)  did.

More choices is a good thing I believe :)

--------------------------------------------------------------------------------

Consider me insane if you wish, but is your reality any better?


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.