Forum Coordinators: RedPhantom
Poser - OFFICIAL F.A.Q (Last Updated: 2024 Nov 29 7:57 am)
My python page
My ShareCG freebies
"max-min loop on WorldVert.X and WorldVert.Y" should be "max-min loop on WorldVert.X and WorldVert.Z"
My python page
My ShareCG freebies
Ah. Now I understand. VERY useful idea. I hope you've thought about multiplication... Numbers can get huge in this situation. Trying 20 hairs and 20 costumes and 10 lighting schemes, makes 4000 renders. At least you should warn the user of the number of combinations. On the camera question, I'm sure you can reach all the necessary values in Python. Hmmmm... You've caught my interest. I'll try to make a simple "Zoom-to-extent" script, as Maclean suggests; you can then incorporate this code in your larger script if you want.
My python page
My ShareCG freebies
I know nothing about python, so I can't help, but a 'zoom extents' shouldn't be difficult, I'd imagine. It's just a question of calculating the maximum extents of whatever's in the scene. I would assume that max, et al, do it with bounding boxes, and since poor poser at least has those, that might be a hook to start from. mac
Yup, the zoom itself turned out to be easy. (And it works -fairly- fast, which surprised me; I assumed it would take a long time to run all the vertices.) What's harder is moving the camera back and forth (DollyX and Orbit Y) so that it points straight into the center of the actual scene. Should get that solved later tonight.
My python page
My ShareCG freebies
Question: should ZTE act on all cameras in the name of "automation", or should it skip the Face and Pose, or what?
My python page
My ShareCG freebies
Attached Link: http://ockhamsbungalow.com/Python/ZoomToExtent.zip
In case anybody's following this thread, I made a pretty good ZTE script. See later message with "Zoom To Extent" in title, for more detail.My python page
My ShareCG freebies
Hello Again!
I just made some tests with your script, ockham. It pointed me to the right direction. But I found, that it would be better for me, not to move the camera, but instead "point it" to the center of the scene and adjust the scaling. Here is the result:
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
import math
import poser
scene = poser.Scene()
RadToDeg = 360.0 / math.pi
DegToRad = math.pi / 360.0
#-----------------------------------------------------------------------------
MaxX = -10000.0
MinX = 10000.0
MaxY = -10000.0
MinY = 10000.0
MaxZ = -10000.0
MinZ = 10000.0
for OneActor in scene.Actors():
if OneActor.IsBodyPart() or OneActor.IsProp():
if OneActor.IsLight(): continue
if OneActor.IsCamera(): continue
if OneActor.Name() == "UNIVERSE": continue
elif OneActor.Name() == "GROUND": continue
try:
OneGeom = OneActor.Geometry()
VertCount = OneGeom.NumVertices()
for i in range(VertCount):
OneWV = OneGeom.WorldVertex(i)
X = OneWV.X()
Y = OneWV.Y()
Z = OneWV.Z()
if X < MinX: MinX = X
elif X > MaxX: MaxX = X
if Y < MinY: MinY = Y
elif Y > MaxY: MaxY = Y
if Z < MinZ: MinZ = Z
elif Z > MaxZ: MaxZ = Z
except:
pass
CenterX = (MaxX + MinX) / 2.0
CenterY = (MaxY + MinY) / 2.0
CenterZ = (MaxZ + MinZ) / 2.0
ExtentX = abs(MaxX - MinX)
ExtentY = abs(MaxY - MinY)
ExtentZ = abs(MaxZ - MinZ)
try:
actor = scene.Actor("CenterBall")
print "Delete CenterBall"
except:
pass
else:
scene.SelectActor(actor)
scene.DeleteCurrentProp()
scene.LoadLibraryProp("Runtime:Libraries:Props:Primitives:Box.ppz")
actor = scene.CurrentActor()
actor.SetName("CenterBall")
actor.SetParameter("Scale", 0.0)
print "Created CenterBall"
print actor.Name()
actor.SetParameter("xTran", CenterX)
actor.SetParameter("yTran", CenterY)
actor.SetParameter("zTran", CenterZ)
cam = scene.CurrentCamera()
cam.PointAt(actor)
cam.SetParameter("Point At", 0.5)
scene.DrawAll()
print "x", cam.Parameter("DollyX").Value()
print "y", cam.Parameter("DollyY").Value()
print "z", cam.Parameter("DollyZ").Value()
print "focal", cam.Parameter("Focal").Value()
print "scale", cam.Parameter("Scale").Value()
print "ExtentX", ExtentX
print "ExtentY", ExtentY
Extent = max(ExtentX, ExtentY)
print "Extent", Extent
dx = cam.Parameter("DollyX").Value() - CenterX
dy = cam.Parameter("DollyY").Value() - CenterY
dz = cam.Parameter("DollyZ").Value() - CenterZ
d = math.sqrt(dx * dx + dy * dy + dz * dz)
print dx, dy, dz, "distance", d
f = cam.Parameter("Focal").Value()
r1 = Extent * 4 * f
r2 = d + 1.41
s = r1 / (r2*100)
print "Scale", s
cam.SetParameter("Scale", s)
This works .. mostly .. or should I say sometimes? Perhaps someone have suggestions how to improve it a little bit more?
Thanks again to you ockham, your help is very usefull ...
Attached Link: http://www.pmrk.de/Haare/ZoomToExtentV2.py
Here is the newest Version of ZoomToExtent. Now it works pretty fine. If anyone is interested, follow the link RalfThis 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.
I'm just working on a Python Script which makes it possible to combine a so called "studio-file" with several Characters or faces or hairs and so on. The camera can automatically rotated. Its like a very intelligent batch-program.
For this it would be very nice, if the camera is adjusted correctly.
I know, that I could point the camera to one object, but this does not guarantee that everything is visible.
Any help would be very helpful
Please find below a snapshot of my "studio-batch-program" (in Python) which has until now, no name ...