Particle decals[V0.1 Released!]

Has anyone ever thought to make a particle decal script?
What i mean is this: when a particle hits a selected object, it would be good if a textured plane could be applied to that object.
anyone who thinks this is a good idea please write this- i know not how to python script, and im to lazy to learn.:o

UPDATE:
.Blend with example:
http://addertooth.net/blender/files/splat.blend
Direct link to Script:
http://addertooth.net/blender/files/splat.py

that sounds like a good idea i could use a script like that

mmmhhmmmnn smoke stains is that what it’s for?

i was thinking of blood splats

i don’t know much but I could probably make one that has collision detection over a plane. (i.e. the object it hits has to be a plane).

it’s simple that way, if the x value (or y or z) goes beyond the value of the plane just make an object there… I’ll get to work on it tomarrow…

great idea! and simple too.

Sweet! thanks!

i’m about halfway to a releasable version…

done with version 0.1!
this is merely a functional test. there is no ui and it’s verrrryyy slow (please help anyone who knows python better than I:()

here’s the script in a .blend with an example:
http://addertooth.net/blender/files/splat.blend
and a direct link to the script:
http://addertooth.net/blender/files/splat.py

and here’s the script (for those who hate following links?):

import Blender
from Blender import Ipo


## degrees to radians calc
#180/pi = deg/rad ... pi*deg = 180*rad ... (pi*deg)/180 = rad
pi = 3.141592 #as far as I can remember pi without looking it up

def drCalc(deg):
	rad = (pi*deg)/180
	return rad


scn = Blender.Scene.GetCurrent()




#variables that will be replaced with ui

#effect object name
splat = 'Splatter'
#emitter object name
emit = 'Emit'
#boundries, will use the absolute values
boundry = 5
ab = boundry - 1

start = 2
end = 25







#deselect all
for ob in Blender.Object.GetSelected():
	ob.sel = 0

#select 'Splatter'

splat = Blender.Object.Get(splat)
splat.sel = 1

#get emitter

ob = Blender.Object.Get(emit)
effect = ob.effects[0]

a = start

test = 0
remv = [1]
while a < end:
	i = 0
 	parts = effect.getParticlesLoc(a)
	if not parts:
		break
	
	if test == 1:
		remv.sort()
		remv.reverse()
		print remv
		for x in remv:
			if x < len(parts):
				parts[x] = [ab, ab, ab]
			
				
	#	for x in remv:
	#		parts.pop(x)
	
	#start calculation
	while i < len(parts):
		
		print i
		print len(parts)
		particle = parts[i]
		#deselect all
		for ob in Blender.Object.GetSelected():
			ob.sel = 0


		
		
		#select 'Splatter'

		splat.sel = 1
		
		if particle[0] > boundry or particle[0] < -boundry:
			Blender.Object.Duplicate(0,0,0,0,0,0,0,0,0,1)
			dup = scn.getActiveObject()
			ipo = dup.getIpo()
			iplx = ipo[Ipo.OB_LOCX]
			iply = ipo[Ipo.OB_LOCY]
			iplz = ipo[Ipo.OB_LOCZ]
			if particle[0] > 0:
				iplx[a] = boundry
			elif particle[0] < 0:
				iplx[a] = -boundry
			iply[a] = particle[1]
			iplz[a] = particle[2]			
			dup.RotX = 0
			dup.RotY = 0
			dup.RotZ = 0
			remv.append(i)
		if particle[1] > boundry or particle[1] < -boundry:
			Blender.Object.Duplicate(0,0,0,0,0,0,0,0,0,1)
			dup = scn.getActiveObject()
			ipo = dup.getIpo()
			iplx = ipo[Ipo.OB_LOCX]
			iply = ipo[Ipo.OB_LOCY]
			iplz = ipo[Ipo.OB_LOCZ]
			iplx[a] = particle[0]
			if particle[0] > 0:
				iply[a] = boundry
			elif particle[0] < 0:
				iply[a] = -boundry
			iplz[a] = particle[2]	
			dup.RotX = 0
			dup.RotY = 0
			dup.RotZ = drCalc(90)
			remv.append(i)
		if particle[2] > boundry or particle[2] < -boundry:
			Blender.Object.Duplicate(0,0,0,0,0,0,0,0,0,1)
			dup = scn.getActiveObject()
			ipo = dup.getIpo()
			iplx = ipo[Ipo.OB_LOCX]
			iply = ipo[Ipo.OB_LOCY]
			iplz = ipo[Ipo.OB_LOCZ]
			iplx[a] = particle[0]
			iply[a] = particle[1]
			if particle[0] > 0:
				iplz[a] = boundry
			elif particle[0] < 0:
				iplz[a] = -boundry	
			dup.RotX = 0
			dup.RotY = drCalc(90)
			dup.RotZ = 0
			remv.append(i)
		if len(remv) == 2 and test == 0:
			remv.pop(1)
			test = 1
		i = i + 1
		Blender.Redraw()
			
	
	
	
	a = a + 1

	
	
#deselect all
for ob in Blender.Object.GetSelected():
	ob.sel = 0

#select 'Splatter'

splat.sel = 1

I’ll work on it more soon…

“my doctor says I have a deficient public duty gland” and yet you wrote us all a lovely little script at the least provocation.

I’m yet to try it. do you think it could be used to create little splashes when rain hits hard surfices?

The new getParticlesLoc (blender cvs) does not get argument . It works on the state of the particles at the current frame . You will have perhaps to do :


while a < end:
    i = 0
    Blender.Set('curframe',a) 
    parts = effect.getParticlesLoc()
 

thanks for the advice jms… i’ll change it if/when i get the latest cvs version.
yogyog: of coarse! just make the duplicated object a particle emitter… I’ll work on it for the next release.

things to do:
a) tighten up the script a little
b) get cvs and rework the script alittle (keeping current getparticlesloc() until next version actually comes out)
c) make the collision detection detect better… (right now it can’t tell the dif. between going over 5 and -5 (i.e., it doesn’t rotate to compensate).
d) make a function that (if there’s an emitter on the duplicated object) will change the starttime, and endtime to when the particle hits. (i.e. if the particle hits at frame 13 and the st is 1 and end is 3 then sta and end will be 13 and 16.

…more when I get more time

(thx for crits)