Switch light by volume

11 votes
Version: 
3
Date Updated: 
10/08/2011

This script switches lights on and off whether they're inside or outside a mesh-volume. The main method is taken from cgtalk


You can also animate the lights


Use a volume to control the lights

Also see this article on my blog

Version Requirement: 
written in 2010. also tested in 2012 Probably compatible with 9
Video URL: 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
grabjacket's picture

Sure Anubis, I've posted the

Sure Anubis,

I've posted the file on my blog, but here's the link direclty.
If the file doesn't work, you can easily recreate the scene by creating an array of 10x10x10 point helpers and a large torusknot in the middle. Let me know what you find out!
Klaas

Anubis's picture

Hey Klaas, nice script. I

Hey Klaas, nice script.
I wish to make some test with your example max scene, but I use Max 2009, so I'll glad if you can send me (at anubiss[at]abv[dot]bg) the scene saved in Max 2009 or export it to FBX. If you choose FBX, pleace be sure that the file format version is FBX200900 then export it.

Thanks in advance,
Anubis

my recent MAXScripts RSS (archive here)

grabjacket's picture

Hey Insanto, I've tested it

Hey Insanto, I've tested it today. At first the method I used was waaay slower because of the repetitive adding and removing the normalmodifier. I've moved that part to a new location in the script, outside of the loop. Now my method (Matan Halberstadts actually) is a bit faster.
average of ten iterations running on a bunch of points and a single volume
10 points check
isPointInVol: 20ms
fn_isObjInsideVolume: 28ms
100 point check
isPointInVol: 199ms
fn_isObjInsideVolume: 144ms
500 point check
isPointInVol: 934ms
fn_isObjInsideVolume: 558ms

So my method is a bit faster. Also check out my blog for the testmethod and testscene.

Graph's picture

thats quite a nice one, would

thats quite a nice one, would you mind testing if your method of determining the volIntersect is faster than mine?

		fn isPointInVol obj pos = --checks if supplied position is inside supplied mesh object
		(
			if superclassOf obj == geometryClass do ;
			(
				local tMesh = obj.mesh; local nVerts=tMesh.numverts; local isInVol = true ;
				for v = 1 to nVerts while isInVol do if asin (dot (getNormal tMesh v) (normalize(((getVert tMesh v)*obj.transform) - pos))) <= 0.0 do isInVol = false ;
				tMesh = nVerts = vPos = undefined ;
				return isInVol ;
			)
		)--END isPointInVol FN

Raphael Steves

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.