Notifications
Clear all

[Closed] Atmospherics and Pflow

He guys,

need some help here.
What I’m trying to do is linking atmospheric gizmos to emitted particles and assign one atmospheric effect per gizmo.
Appending gizmos to particles works fine, but as soon as I start assign effects to gizmos the shit hits the fan.
First thing is that I don’t get one gizmo per effect but all of them and as an additional feature several time the same gizmo.

Second, all my parameters are applied to all effects, not the numbered one(see script and attached file).

on ChannelsUsed pCont do
(
	 pCont.useTM = true
	 pCont.useAge = true
)

on Init pCont do 
(	global theFire = $Exp_Gizm* as Array
	global atmos = fire_effect density:20 explosion:1

)

on Proceed pCont do 
(
	for i in 1 to numAtmospherics do
	(
		deleteAtmospheric 1
	)
--clears all atmospheric effects 

	theFire.pos = [0,0,-1500]
	count = amin #(pCont.NumParticles(), theFire.count)
	for i in 1 to count do
	(
		pCont.particleIndex = i
		theFire[i].transform = pCont.ParticleTM
--appneding the gizmos to the particles

		addAtmospheric atmos
		(getAtmospheric i).phase = (pCont.ParticleAge+1) *20
		(getAtmospheric i).name = i as string
		appendGizmo (getAtmospheric i) theFire[i]
	)
)

on Release pCont do
(

)

Where I’m going wrong?

On a side note, mental ray likes ignor the gizmos transfomation when rendering. Tried with different object and with and without using an ‘at time’ function but no avail.

8 Replies

try this…

on ChannelsUsed pCont do
(
pCont.useTM = true
–pCont.useTime = true
–pCont.useAge = true
)

on Init pCont do
(
global theFire = $Exp_Gizm* as Array
–global atmos = fire_effect density:20 explosion:1
–atmos.numGizmos
)

on Proceed pCont do
(
for i in 1 to numAtmospherics do
(
deleteAtmospheric 1
)

 theFire.pos = [0,0,-1500]
 count = amin #(pCont.NumParticles(), theFire.count)
 for i in 1 to count do
 (
     
     pCont.particleIndex = i
     theFire[i].transform = pCont.ParticleTM
     atmos = fire_effect density:20 explosion:1    -- create new atmospheric
     atmos.phase = (pCont.ParticleAge+1) *20    -- change phase
     atmos.name = "ParticleFire" + i as string        -- change name
     addAtmospheric atmos
     appendGizmo atmos theFire[i]                        -- add gizmo to effect
     
 )

)

on Release pCont do
(

)

the problem you have with this, every time a particle is deleted all gizmos get reassigned. You could use particle ID instead of particle counter so every single gizmo get unique particle assignment…
and, I would create the gizmos in the script

don’t have time to work on this right now but I will come back to this ASAP

cheers,
Bandu

first of all, in the for loop deleteAtmospheric “i” and not “1”…

Irrelevant.

The problem IMHO is that you are trying to create Atmospheric effects at render time. There are things that cannot be done inside a Script Operator like creation of objects, deleting of objects etc. and that’s what you are attempting. The renderer has already collected what is in the scene and you cannot just add a new effect in the middle of the rendering process.

You are supposed to do these things before the rendering starts, that’s why you already have N fire effect gizmos in the scene. You should also add N effects to the effects list before you even start rendering, and just have each gizmo pre-assigned to a corresponding effect, then let the PFlow Script Operator just drive them around.

For your mental ray problem, see this thread and the solution at the end:

http://forums.cgsociety.org/showthread.php?f=98&t=429702&highlight=mental+ray

problem solved if you say it never works Bobo…

I was more interested in the script itself and how to assign right gizmo to the right fire effect.

whatever… :rolleyes:

1 Reply
(@bobo)
Joined: 10 months ago

Posts: 0

It probably would be possible to script this portion inside the on init pcont do() handler where creation and deletion stuff belongs. It just cannot be in the on Proceed handler. Since the gizmos were already pre-created, I don’t see why the effects couldn’t be (with or without script). In the original setup as found on my site and the MAXScript reference, I was using only one fire effect with all 30 gizmos, so I haven’t done this in the past.

You are supposed to do these things before the rendering starts, that’s why you already have N fire effect gizmos in the scene. You should also add N effects to the effects list before you even start rendering, and just have each gizmo pre-assigned to a corresponding effect, then let the PFlow Script Operator just drive them around.

Bobo:
I created the gizmos forehand and they aren’t causing any problems. However I was able to create what I wanted within a script op a few weeks ago, but can’t remember how(not rellay sure about that). Will try to create the FX the same way like I did with the gizmos.
Nice workaround for the mr problem, btw. I found out that playing back the animation with the gizmos selected and autokey on solves the problem as well. Disadvatage of this method is tzaht you will have to delete all the keys everytime you change the Pflow in some way.

Bandu:
Your script looks like one of my previous versions which failed to work.

the problem you have with this, every time a particle is deleted all gizmos get reassigned.

I don’t see this as a problem. As long as ever FX has it’s gizmo I don’t care. It would be more elegant to keep one FX per Gizmo for the lifespan of the particle, but I need results, if a brute force attempt works, I’m fine with it.
Will try the Particle ID way though.
Would be nice if you wouldn’t edit your post all the time, makes it hard to follow the discussion.

yea, sure, sorry… I did as I realized my “i” “1” mistake

Actually it’s not a msitake, just doesn’t make any difference – hence irrelevant.