Originally Posted by: rollemops Hi topspin - then I am soon unemployed.
Nope, just kidding ;-)
That sounds very interesting. Especially if you don't want to get stuck with the cranky DAZ API, but just need an idea generator in the right direction. And if you share the generated script as CC - even with GPT4 as author - there is nothing wrong with it IMHO.
So, I don't really think that Chat GPT is "the author", any more than suggesting than ECMA Script is "the author". Now, when it randomly starts sending me scripts, unsolicited, with "my ideas of some scripts for you" . . . that would be different. But here, I'm asking it for something, its making me a script, I stick it into Daz and . . . well, I call that a convenience.
But if you think, say, of compiler design-- I don't see how its all that different, just that its now got a natural language interface. The "AI" thing -- well, there are some things there that are smart, like knowing that the idea I had about lights actually only applies to _some_ Daz lights, not all.
Originally Posted by: rollemops
Did you use the free basic version to create the script? I haven't tried it - but as a "directional guide" it looks usefull.
I've got the paid version of ChatGPT4,
Not sure if it does 3.5.
I doubt it would put anyone out of a job -- but might increase the popularity and utility of scripting in Daz. With Daz, pretty much any useful script is going to be very context dependant, you have to know just what you want, and how your scene is set up, to make use of scripts. So I think this can help people along, like a template, but I'll push it farther -- haven't asked it to analyse a scene yet, but I'll try.
It also can help with Poser Python (though I don't have Poser installed anymore and can't test whether this works, but now am curious)
Q. I'd like to have a Poser Python script in which the luminance property of a named material "C" varies inversely with the distance between two polygons. That is, I'd like C to get brighter when the polygons it is applied to get closer to a null, and darker when farther away. Can you do this?
A.
Yes, I can help you write a Poser Python script for that purpose. In this example, I'm assuming you have a Poser scene with two objects, each with a single polygon, and a null object representing the point of reference. Here's a basic script that demonstrates how to achieve this effect:
import poser
import math
# Constants
MATERIAL_NAME = "C"
MAX_DISTANCE = 5.0 # Define the maximum distance between polygons, in scene units
MIN_LUMINANCE = 0.0
MAX_LUMINANCE = 1.0
def distance_between_points(p1, p2):
return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2 + (p1[2] - p2[2])**2)
def update_luminance(scene):
# Get the objects from the scene by name
poly1 = scene.Actor("Polygon1")
poly2 = scene.Actor("Polygon2")
null_object = scene.Actor("Null")
# Calculate the distance between each polygon and the null object
poly1_pos = poly1.WorldCenter()
poly2_pos = poly2.WorldCenter()
null_pos = null_object.WorldCenter()
distance1 = distance_between_points(poly1_pos, null_pos)
distance2 = distance_between_points(poly2_pos, null_pos)
# Calculate the average distance
avg_distance = (distance1 + distance2) / 2
# Map the average distance to the luminance range [MIN_LUMINANCE, MAX_LUMINANCE]
normalized_distance = min(avg_distance / MAX_DISTANCE, 1)
luminance = MAX_LUMINANCE - normalized_distance * (MAX_LUMINANCE - MIN_LUMINANCE)
# Update the luminance property of the material "C"
material = poly1.Material(MATERIAL_NAME)
material.SetDiffuseColor((luminance, luminance, luminance))
# Apply the updated material to both polygons
poly1.SetMaterial(MATERIAL_NAME, material)
poly2.SetMaterial(MATERIAL_NAME, material)
# Update the scene to reflect the changes
scene.Update()
# Get the current scene
scene = poser.Scene()
# Update the luminance based on the distance between polygons and the null object
update_luminance(scene)
This script calculates the distance between the center of each polygon and a null object, then averages those distances. The average distance is mapped to a luminance value in the range [MIN_LUMINANCE, MAX_LUMINANCE] and applied to the material named "C". Finally, the script updates the scene to reflect the changes.
You might need to adjust the constants at the beginning of the script, such as the maximum distance and the material name, to match your specific scene setup.
Edited by user Friday, March 31, 2023 10:38:56 AM(UTC)
| Reason: Not specified