Forum: Poser Python Scripting


Subject: WorldToScreen() - unclear about what it returns.

3dcheapskate opened this issue on Dec 23, 2023 ยท 10 posts


3dcheapskate posted Sun, 31 December 2023 at 3:03 AM Online Now!

I just nailed together a crappy bit of python to print the world space coordinates and the result of the WorldToSpace() conversion. Here's what it outputs when I have a 1PNU vertical square centred at the origin and view it via the dollycam which is positioned on the positivbe Z axis looking at the origin



So it's definitely not camera space in the way I was thinking of camera space.


Here's the 'code' (peril sensitive sunglasses recommended for viewing). I've totally given up trying to post correctly formatted code on Renderosity forums, so this is just a cut-and-paste from Notepad++


import poser,random


# I put my scripts into a class simply to avoid possible conflict with stuff in the __main__ module.

class cheapskatesTemporaryClass(object):

def main(self):

# Get Poser version for doing version-specific stuff

poserversion = '0'

posermainversion = '0'

try:

self.poserversion = poser.AppVersion()

temp = self.poserversion.split('.')

self.posermainversion = temp[0]

except:

pass

poser.DialogSimple.MessageBox("1")

scn = poser.Scene()

curact = scn.CurrentActor()

curgeom = curact.Geometry()

vcnt = curgeom.NumVertices()

wvlist = curgeom.WorldVertices()

poser.DialogSimple.MessageBox("vcnt = "+str(vcnt))

i=0

triplet=[0.0,0.0,0.0]

curcam = scn.CurrentCamera()

trp=[0.0,0.0,0.0]

trp = curcam.WorldDisplacement()

print '\nCamera position ('+str(trp[0])+', '+str(trp[1])+', '+str(trp[2])+')'

while i < vcnt:

poser.DialogSimple.MessageBox("Vertex"+str(i))

dbg ='Vertex ' + str(i) + ' World ('

curv = curgeom.WorldVertex(i)

dbg = dbg + str(curv.X()) +', '+str(curv.Y())+', '+str(curv.Z())+');'

triplet = scn.WorldToScreen(curv.X(),curv.Y(),curv.Z())

dbg = dbg + ' Screen (' +str(triplet[0]) +', '+str(triplet[1])+', '+str(triplet[2])+');'

print dbg

i = i + 1

# Inform the user that it's all done

poser.DialogSimple.MessageBox("All done")

poser.DialogSimple.MessageBox("Running 3DCheapskates XXX.py script\n\n(N.B. You should see a similar message when the script finishes. If you don't then the script has crashed!)")

cheapskatesTemporaryInstance = cheapskatesTemporaryClass()

cheapskatesTemporaryInstance.main()

poser.DialogSimple.MessageBox("3DCheapskates XXX.py script all done.")




The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).