Forum: Poser Python Scripting


Subject: What is the mystery frame incrementer?

HartyBart opened this issue on Aug 12, 2021 ยท 13 posts


HartyBart posted Thu, 12 August 2021 at 10:31 PM

In the 2018 YouTube Poser video "Python Scripting Poser for Pseudo 3D" we see this (just about, as it was very badly filmed):

anim.jpg

Which I have out of curiosity reconstructed as this:

walker.jpg

What is the curious scene.setFrame increment command being used here (partly circled in red)? It looks like a Greek letter?



Learn the Secrets of Poser 11 and Line-art Filters.


HartyBart posted Tue, 24 August 2021 at 12:08 PM

I now think it may be ka=10 which is apparently an obscure maths formula used to raise things by powers of 10.

But then how does ka=10 + k make sense?

Adding import math to the script header does not make the script run.



Learn the Secrets of Poser 11 and Line-art Filters.


primorge posted Wed, 01 September 2021 at 6:29 AM

I've seen ka in Poser files before. It's similar to other shader tree designations such as ks(specular) or kd(diffuse), in this case it indicates ambient... not at Poser to check and this is just a guess, it might be totally unrelated but maybe noteworthy.


structure posted Mon, 06 September 2021 at 3:16 AM Forum Coordinator

from what I can tell, both ka and h would need a value, there is nothing telling the script what ka is - it is not a poser object or you would see something like

scene.SetFrame(poser.kCMDka * 10 + h)

it is likely a frame counter as in :

scene.SetFrame( ka * 10 + h )

Since setframe requires a frame number

SetFrame
Explanation
Set the current frame number. All frame numbers in PoserPython are relative to
a starting frame of 0. For this reason, a frame number in Python is 1 less than the
equivalent frame as referenced from the Poser GUI.
Arguments
Enter a valid frame number.
Syntax
 SetFrame( frame )
Example
scene.SetFrame(23)

and the only options available are the increments :

SetFrameOptions
Explanation
Set the values for frame rate and increment.
Arguments
Enter two integer values, for frame rate and frame increment respectively
Syntax
 SetFrameOptions( rate,  increment )
Example
moviemaker.SetFrameOptions(24, 4)

so ka is likely the start frame, multiply that 10 and add h for the resulting frame number ( I am sure there is a typo with the " = " )

Locked Out


HartyBart posted Wed, 08 September 2021 at 12:29 PM

Thanks very much. I've got a little further, but I'm at the point where I'm just guessing now. Still, the only error being thrown by the non-working script seen below is that there is " an unsupported operand type(s) for * ".

walker.jpg



Learn the Secrets of Poser 11 and Line-art Filters.


structure posted Tue, 05 October 2021 at 12:45 PM Forum Coordinator

if you could paste the code - I could try it out - finding it difficult to type atm. 

Locked Out


HartyBart posted Wed, 06 October 2021 at 2:29 PM

# Auto walker, to be used with Poser Walk Designer

import math

import poser

scene = poser.Scene()

actor = scene.CurrentActor()


sceneFigure = "Andy2"

figure = scene.Figure("Andy2")

body = figure.Actor("Body")

yRotateParam = body.Parameter ("yRotate")


frames = scene.SetNumFrames(360)

ka = actor.SetRangeConstant(10,349)


# Figure walks 10 frames then turns, then walks ten frames

for angle in range(10,360,10):

    scene.SetFrame( ka * 10 + h )

    yRotateParam.SetValue(angle)

    scene.DrawAll ()



Learn the Secrets of Poser 11 and Line-art Filters.


HartyBart posted Wed, 06 October 2021 at 3:48 PM

Test of HTML pre and code :

<pre>Your code here</pre> 

<code>Your code here</code>

No, that doesn't work.

'''

does this

'''

No, that doesn't work either.



Learn the Secrets of Poser 11 and Line-art Filters.


HartyBart posted Wed, 06 October 2021 at 3:54 PM

```

Can code be enclosed in backticks?

```

Or in [code]bracketed code blocks[/code]?

No, those don't work either.



Learn the Secrets of Poser 11 and Line-art Filters.


structure posted Wed, 06 October 2021 at 5:00 PM Forum Coordinator

ok first you have no value for h

multiplying a tuple  (ka) will loop the tuple between the 2 numbers x times

e.g.

print( 10 * (36, 30) )

results in the output 

(36, 30, 36, 30, 36, 30, 36, 30, 36, 30, 36, 30, 36, 30, 36, 30, 36, 30, 36, 30)

trying to add the h 

results in an error

>>> ka = (10, 349)

>>> h  = 90

>>> print (ka * 10 + h)

Traceback (most recent call last):

  File "<pyshell#2>", line 1, in <module>

    print (ka * 10 + h)

TypeError: can only concatenate tuple (not "int") to tuple

>>> 

to make a turn at the end of each 10 frames doesn't need a complicated formula 

class anim:
    def createAnim(self, parm, frame):
        for i in range(0, 4):
            frame += 10
            scene.SetFrame(frame)
            parm.SetValue(parm.Value() + 90)
            scene.DrawAll()

Locked Out


structure posted Wed, 06 October 2021 at 5:13 PM Forum Coordinator

# Auto walker, to be used with Poser Walk Designer

import poser
scene = poser.Scene()


class Anim:
    def createanim(self, parm, frame):
        for i in range(0, 4):
            frame += 10
            scene.SetFrame(frame)
            parm.SetValue(parm.Value() + 90)
        scene.DrawAll()


body = scene.Figure(scene.CurrentFigure().Name()).Actor("Body")
if body:
    yRotateParam = body.Parameter("yRotate")

    frames = scene.SetNumFrames(360)

    # Figure walks 10 frames then turns, then walks ten frames
    Anim().createanim(yRotateParam, 0)

Locked Out


3dcheapskate posted Wed, 06 October 2021 at 11:24 PM

An auto walker, eh?

For use with Poser Walk Designer ?

D'you think it'd work for a millipede ? ๐Ÿ˜ƒ

I couldn't find any info on the walk designer (well, to be honest I didn't actually look) and ended up cobbling together a load of callbacks over there The first four segments of a millipede - not sure if this'll go anywhere :) | HiveWire 3D Community

So I'm intrigued by what you're doing here as it may be a better approach...



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



HartyBart posted Thu, 07 October 2021 at 12:40 PM

Thanks Structure, I'll test that soon when I have time. So, it sounds like the mystery line was being used by the scripter to save having to write/calculate a string of numbers.

3dcheapskate - the original video was by Bill Nye. He made a 10-frame walk cycle with the Poser Walk Designer, and then every ten frames had the script rotate the figure. He was making flat-colour 'psuedo 3D' walking sprites for Flash.


I assume if you have a maybe five frame walk for each leg of a millipede, simply swinging back and forth, then you could apply that to all legs, but then stagger the timing on each so as to get the flowing 'ripple effect' of a millipede's legs?  Once you have that, then the whole creature could be made to walk around in a circle. How you would then make it wiggle a bit I don't know.



Learn the Secrets of Poser 11 and Line-art Filters.