Custom object kill, mark, etc

Discussion about scripting with Python
Post Reply
User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Custom object kill, mark, etc

Post by bolek » Mon Jun 13, 2011 2:44 pm

Welcome.

I wrote custom object kill, mark, etc. Instead of playing with faces or vertices (RF4 Manual (page 168) ) I used new function delivered by RF5 " getNearestPointToObject " , but I noticed kind of bug namely- when getNearestPointToObject returns first and second value which is PointOnObject(vector) and Normal(vector) of that point it changes order of components so you need to put x in place of z and vice versa to get proper position and normal vector.

Have you guys noticed similar problem ?


BTW script works faster than that with works on faces or vertices.

Code: Select all

#--------------------------------------------------
# Function: onSimulationFrame 
#--------------------------------------------------

def onSimulationFrame():
	#vars
	nullVec = Vector.new(0.0,0.0,0.0)
	container01 = scene.getEmitter("Container01")
	obj = scene.getObject("obj")
	emitter = scene.get_PB_Emitter("Emitter")
	#efp emitter first particle
	eFP = emitter.getFirstParticle()
	#-----------
	while eFP:
		#emitter next particle
		eNP = eFP.getNextParticle()
		passP = 1
		pPos = eFP.getPosition()
		pId = eFP.getId()
		pNear = eFP.getNearestPointToObject(nullVec,"obj")
		#problem with getting proper nearest point on object vector and normal vector--
		#npoo -nearest point on object
		nPOO = Vector.new(pNear[0].z,pNear[0].y,pNear[0].x)
		nPOON = Vector.new(pNear[1].z,pNear[1].y,pNear[1].x)
		#------------------------------------------------------------------------------
		diffVec = pPos - nPOO
		dotP = nPOON * diffVec
		if (dotP > 0.0): passP = 0
		if(passP == 1):
			pVel = eFP.getVelocity()
			emitter.removeParticle(pId)
			container01.addParticle(pPos,pVel)
		eFP = eNP
	pass

Uploaded with ImageShack.us
____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/

IoSim
Posts: 329
Joined: Tue Jan 13, 2009 8:09 am

Custom object kill, mark, etc

Post by IoSim » Mon Jun 13, 2011 5:18 pm

Hey Bolek

I've used this function a lot in the c++ SDK and there it works alright, so it appears to be a Python implemenation issue.

Cool to see you writing all these scripts. :)

This last one is infact very similar to one of my latests plugins, where I've implemented it as a daemon.

-Cheers Ole
Ole Lemming
RealFlow plugin developer
IoSim, Creative Thinking Lab
www.iosim.dk

User avatar
bitSeq
Posts: 1044
Joined: Thu Jul 10, 2008 9:48 am
Location: UK - Stuart Armiger
Contact:

Custom object kill, mark, etc

Post by bitSeq » Mon Jun 13, 2011 5:22 pm

Thanks Bolek! will have to test this out :)

User avatar
bolek
Posts: 121
Joined: Thu Nov 27, 2008 10:24 am
Contact:

Custom object kill, mark, etc

Post by bolek » Tue Jun 14, 2011 9:11 pm

Hey!

Hmmm.... weird problem anyway You're right IOSim. Some time ago I wrote RF4 version of mark. Your plugin remainded me of new funciton (getNearestPointToObject) in RF5 so I wanted to check how it works with it... now we now how : )

____________________________________________
http://vimeo.com/bolekcg
http://bolekcg.blogspot.com/

Post Reply

Return to “Python-Scripting”