PDA

View Full Version : Script operator not working at render time ?


irwit
02-18-2009, 03:12 PM
Hi all

I have a couple of script opertaor, this particular one running in the final step update.

If I scrub timeline and click render it works fine and the view port updates as it should, but when I press render its as if its just ignoring the script completely.

Heres what I have in the final step update.


pf_node_current = particleFlow.scriptRunner() -- current particle system
if (pf_node_current != undefined) then
(
count = pf_node_current.NumParticles()
global megaroadlights = $roadlight* as array

for i in 1 to count do
(
pf_node_current.particleID = i
pf_node_current.particleposition = getvert $roadguide i
megaroadlights[i].position = getvert $roadguide i

)
)


the particles dont update their movement and the lights are not following the verts.

Any help much apprechiated :D

Cheers guys

Will.

JohnnyRandom
02-18-2009, 03:40 PM
Not sure, just some ideas, but is roadguide defined, you have defined roadlight. The script may not be seeing it.

Also you may want to snapshot that mesh then delete it when finished with it. Bobo states that this is an appropriate way to deal with meshes when using meshOp function particle flow.
Something like:

local theMesh = snapshotAsMesh $theMeshObject
local theCount = theMesh.numverts

--functions on mesh verts

delete theMesh


I'll plug Bobo's Pflow Scripting Act II training too, it specifically deals with moving lights. On a side note, to your other post about caching, I also tested one of his scenes with a cache operator and lights and it does work.

irwit
02-18-2009, 03:45 PM
I'll try the snapshot when I get home.

Cheers for help, I had a play with the caching but it worked out just as slow as its a pretty big scene and 500 frames some Im guessing working with teh cache file was just as much an overhead as the file on the fly.

basically my brief keeps changing of what these lights are actually going to do so what was working now isnt and so on. Getting a bit stressful :argh:

Thanks again for the help, apprechiate it :beer:

irwit
02-18-2009, 03:53 PM
Didnt work :(

http://www.mediafire.com/?zmjmnlmt5gy

uploaded the file. If I scrub and press render then fine, but leaving renderer on its own its just not working. :argh:

galagast
02-19-2009, 10:18 AM
Hi, I also stumbled upon a similar problem back then.. here's the thread at orbaz (http://www.orbaz.com/forum/viewtopic.php?t=325).
In the first post, I encountered the same problems where its working in the viewports and not in the renders. The solution (last post) I got was to append an at time t to the lines where I'm getting vertex/knotpoint data. Hopelly (fingers crossed) it would solve your problem too. :D

The t in at time t should denote the time when you want to get the vertex data. In my case, i got the time value within the script operator using pCont.getTimeEnd(). I haven't checked if it would work inside final step update though..

i hope this helps!
Jeff

JohnnyRandom
02-19-2009, 05:03 PM
That may be the ticket.

One of the reasons I found this problem interesting, namely because I've never used the step update scripts other that to see what the defaults did. It acts as if it doesn't like the positioning to geometry. A bug? It works in the viewport why not the render? Wish Oleg or Bobo would chime in :)

I spent some time last night messing around with it and well the best I could get it to work was by adding a new script op to every event the would check the particles position, this had the adverse effect of messing up the lights, so I added another script op in each event to check and replace the lights, works/renders fine for the first event but it seems the particle ID is getting jacked after the collision op. and the lights won't hit their original particles. So frustration aside I am at a loss too. :(

irwit
02-19-2009, 07:21 PM
Cheers for havin a look johnny.

I had same issue with trying to use particleIDs after the first event which is why I used the final step update. Was even more frustrating when I didnt test render it till the end of the day as I was leaving and was like "nooooooooo...." very frustrating!

I was also using the final step update other day to do a completely none PF related script. I just wanted the script to update itself everyframe and hit the same issue, fine in viewport when scrubbing but didnt work render time.

I am kind of fingers crossed Oleg or Bobo would throw some knowledge this way as Im sure it must be something not activated in the code but Ive no idea what ? I'll definately give galagast's idea a go tomorrow but Im not sure about activating timecodes in final step update scripts as you dont seem to need to activate anything in there normally.

Anyway, thanks again for tryin Johnny, and thanks galagast, do apprechiate it :thumbsup:

JohnnyRandom
02-19-2009, 11:52 PM
No problem, I wish I could have figured it out. :curious:

OlegB
02-20-2009, 02:07 AM
If your render differs from the viewport playback with a Script Operator, 95% of the time you did not use at time parameter while querying object/mesh data.

Thanks,
Oleg B.

irwit
02-20-2009, 07:30 AM
If your render differs from the viewport playback with a Script Operator, 95% of the time you did not use at time parameter while querying object/mesh data.

Thanks,
Oleg B.


Cheers Oleg,

Could you tell me where the at time goes in the following code, Im using this in the final step update part of PF.

pf_node_current = particleFlow.scriptRunner() -- current particle system
if (pf_node_current != undefined) then
(
count = pf_node_current.NumParticles()
global megaroadlights = $roadlight* as array

for i in 1 to count do
(
pf_node_current.particleID = i
pf_node_current.particleposition = getvert $roadguide i
megaroadlights[i].position = getvert $roadguide i

)
)

JohnnyRandom
02-24-2009, 08:51 PM
Cheers Oleg,

Could you tell me where the at time goes in the following code, Im using this in the final step update part of PF.


Man, this was starting to get on my nerves, I couldn't for the life of me figure out how to grab the time from anywhere but the pflow system even then the getTimeStart/End() function doesn't work (not directly anyway), so what comes me? Use the particle age. As long as you don't alter it it should be fine. I am still curious if there is another way but for now...

try this, it works:
pf_node_current = particleFlow.scriptRunner() -- current particle system
if (pf_node_current != undefined) then
(
count = pf_node_current.NumParticles()
roadlights = $roadlight* as array
theTime = pf_node_current.particleAge
theMesh = at time theTime snapshotAsMesh $roadguide

for i in 1 to count do
(
pf_node_current.particleID = i
pf_node_current.particleposition = getvert theMesh i
roadlights[i].position = pf_node_current.particleposition
)
delete theMesh
)

I also think it may be better to have two systems, one for the left and one for the right, this way your first particles will remain your first. As it is particle 1 and particle 58 start off as the first particles on the geometry, which will more than likely cause some confusion later. Just clone the mesh and use a mesh select->vertex and grab the vert count, use a standard birth op with that count and a position object w/ selected verts.

irwit
02-25-2009, 10:03 AM
Man, this was starting to get on my nerves, I couldn't for the life of me figure out how to grab the time from anywhere but the pflow system even then the getTimeStart/End() function doesn't work (not directly anyway), so what comes me? Use the particle age. As long as you don't alter it it should be fine. I am still curious if there is another way but for now...

try this, it works:
pf_node_current = particleFlow.scriptRunner() -- current particle system
if (pf_node_current != undefined) then
(
count = pf_node_current.NumParticles()
roadlights = $roadlight* as array
theTime = pf_node_current.particleAge
theMesh = at time theTime snapshotAsMesh $roadguide

for i in 1 to count do
(
pf_node_current.particleID = i
pf_node_current.particleposition = getvert theMesh i
roadlights[i].position = pf_node_current.particleposition
)
delete theMesh
)

I also think it may be better to have two systems, one for the left and one for the right, this way your first particles will remain your first. As it is particle 1 and particle 58 start off as the first particles on the geometry, which will more than likely cause some confusion later. Just clone the mesh and use a mesh select->vertex and grab the vert count, use a standard birth op with that count and a position object w/ selected verts.



That's brilliant mate! Cheers! :thumbsup:


I guess it is a bit of a workaround to find the current time but whatever works imo, surely there must be a command to get current frame time in a final step script. Hopefully Bobo might still make an apperence in here.

Anyway, cheers man, owe you a beer! :beer:

JohnnyRandom
02-25-2009, 05:31 PM
The brilliance award goes to Jeff (Galagast) he found this function: getUpdateTime()

pf_node_current = particleFlow.scriptRunner()
if (pf_node_current != undefined) then
(
count = pf_node_current.NumParticles()
megaroadlights = $roadlight* as array
obj = $roadguide
t = pf_node_current.getUpdateTime()

for i in 1 to count do
(
pf_node_current.particleID = i
pos = at time t polyop.getVert obj i
pf_node_current.particleposition = pos
megaroadlights[i].position = pos
)
)

irwit
02-25-2009, 06:54 PM
So thats 2 beers I owe then! Sweet, thats such a HUGE help! Cheers guys

Just noticed you're from Saltlake City, I'm over there in september, youll have to let me know wheres worth going for a beer and if your about I can actually get a round in.

Thanks again for the help

Will.

JohnnyRandom
02-25-2009, 09:20 PM
Cool, drop me a line, I'm always up for a couple :D

CGTalk Moderation
02-25-2009, 09:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.