Forum: Poser Python Scripting


Subject: Cloning Objects

adp001 opened this issue on Jun 03, 2023 ยท 21 posts


adp001 posted Sat, 03 June 2023 at 8:33 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.


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).


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


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:





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

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

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):





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

Wow

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sonoma 14.6.1, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


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 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?

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.

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

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

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

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

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. 

More examples of scattering in Poser 12.

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

Create real-time CROWDS with billboards:

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. :)



My Store at Renderosity

My Store at PoserSoftware

Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!


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.


EVargas.Art


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" (:smiley:) 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" (:smiley:) scatter tool as an open source script here in the forum.

Wow cool!

๐’ซ๐’ฝ๐“Ž๐“


(ใฃโ—”โ—กโ—”)ใฃ

๐Ÿ‘ฟ Win11 on i9-13900K@5GHz, 64GB, RoG Strix B760F Gamng, Asus Tuf Gaming RTX 4070 OC Edition, 1 TB SSD, 6+4+8TB HD
๐Ÿ‘ฟ Mac Mini M2, Sonoma 14.6.1, 16GB, 500GB SSD
๐Ÿ‘ฟ Nas 10TB
๐Ÿ‘ฟ Poser 13 and soon 14 โค๏ธ


adp001 posted Thu, 08 June 2023 at 9:43 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 :smiley:.





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. 



My Store at Renderosity

My Store at PoserSoftware

Characters, Body Sculpts, Morph Corrections, Outfits, Python Scripts, Universal Heads, and Videogames!


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?