ScriptSpot

Forum topic · Scripts Wanted

LED eyes

By Mantichore · 2012-01-09

Description

Hi, I'm new to Maxscript, have 3 years c++ experience, and about 5 years of 3d studio Max experience.
I'm looking for an easy way to animate Led eyes for a robot (like EVE in WALL-E).
So I was hoping if anyone could help me with this, or if there is already a script that could be used for this.
The ideal solution would be something with a window where you have a button for each LED (sphere). Each button controls the visibility/luminosity of the LED(on or off).
Here's a visual example I made for clarity:
http://imageshack.us/photo/my-images/812/examplef.jpg/

It's for my graduation movie (third bachelor year in animation), so there's no budget...

Comments (11)

Hi Mantichore,

barigazy · 2012-09-05

you make very interesting short movie.
Is this advertisement for a product, or some peronal project?

Mantichore · 2012-09-10

It was my Bachelor graduation movie, for my third year of animation at RITS (art university in Brussels, Belgium).
the assignment was to make a short animation for children, minimum 1 minute, subject/story was our own choice (but the teacher had to agree).

just suggestion

Anubis · 2012-01-10

You said never learn maxScript, so you expect some complete working script? Well, I haven't so much time. You wish as well to animate this via dialog but with varied amount of objects? If so you'll need dynamicly created dialog (check in the help for

rolloutCreator

functions). Also to note that only the Spinner UI-controller has #controller property which simplify it 'binding' to animatable property. To wire CheckButton (or other UI-control) you'll need CustomAttributes.

What I can helps atm anyway is to hint you to use (or at least give it a try) Materail Modifier. This way you can create only 1 (MultiSub) material (with 2 sub materails) and using it for all spheres. Next, apply unique (not instance) mat-mod to each object, and then you can animate the

materialID

of this modifiers.
The good news in that approach is that you can accomplish your animation without scripting. Another good news, - I have a few scripted examples, very simple and readable at my web site (here). You can watch short videos there too, on what each script do. The third one show very basic usage of Materail Modifier animating method.

Cheers!

jos · 2012-01-09

How do you see your LED lights. controlled by lights or illumination map, or..?

Mantichore · 2012-01-09

What I had in mind was that each LED in the array is made of two spheres on exactly the same space (one sphere with a very light colour and a high self-illumination, the other very dark).
And each button in the array controls which sphere you show. So, when a button is ON, the corresponding LED sphere with the light material is visible (the other not visible). When the button is OFF, you switch the visibility, and the dark sphere becomes visible, the other becomes hidden.

But the actual materials don't really matter, that's no problem for me.
It's just the rigging/button thing I can't do. (It's been three years since i did some c++ programming, so a bit rusty there and I'm not familiar with the MAXScript language)

so no lights needed, just a bunch of spheres, if possible with a user-adjustable amount, so you can add more/less LED's.

PS: I just saw you are a DAE student? Me too, I was one of the first to graduate, but we never had MAXscript. I'm currently a student at RITS in Brussels. So if you want I can continue in Dutch :)

br0t · 2012-01-09

I dont know if it would be a great joy to create and link all those buttons to the spheres or use it for animation. Maybe you can just select the LEDs you want to change and use 2 or 3 buttons to edit their state. I gave it a try here, each Sphere has a simple Standard Material and the script changes its Diffuse and SelfIllumination. To make sure the material changes dont propagate on other objects, you can use the "make unique" button.


try(destroyDialog roLeds)catch()

rollout roLeds "LEDs" width:130 height:133
(
	button btnOn "On" pos:[4,40] width:59 height:55
	button btnOff "Off" pos:[68,40] width:58 height:55
	button btnUnique "Make materials unique" pos:[4,5] width:122 height:30
	button btnInvert "Invert" pos:[4,99] width:122 height:30
	
	on btnOn pressed do
	(
		for s in selection where superClassOf s == GeometryClass do
		(
			try
			(
				with animate on
				(
					s.material.Diffuse = color 255 0 0 
					s.material.SelfIllumAmount = 100
				)
			)
			catch(print "Error - wrong material on selected object?")
		)--end for
	)--end on
	
	on btnOff pressed do
	(
		for s in selection where superClassOf s == GeometryClass do
		(
			try
			(
				with animate on
				(
					s.material.Diffuse = color 85 0 0 
					s.material.SelfIllumAmount = 0
				)
			)
			catch(print "Error - wrong material on selected object?")
		)--end for
	)--end on
	
	on btnUnique pressed do
	(
		-- if the material is shared among the objects, changing it will affect more objects than it should
		for s in selection where s.material != undefined do
		(
			theMat = copy s.material -- copy and reassign each material to avoid instances
			s.material = theMat
		)--end for
	)--end on
	
	on btnInvert pressed do
	(
		for s in selection where s.material != undefined do
		(
			try
			(
				with animate on
				(
					if s.material.Diffuse == color 255 0 0 then
					(
						s.material.Diffuse = color 85 0 0
						s.material.SelfIllumAmount = 0
					)
					else
					(
						s.material.Diffuse = color 255 0 0
						s.material.SelfIllumAmount = 100
					)
				)
			)
			catch(print "Error - wrong material on selected object?")
		)--end for
	)--end on

)
createDialog roLeds

The "with animate on" context will use the standard tangents, so if you want a harsh switch, change them to linear.

Cheers

Mantichore · 2012-01-10

wow, thanks!
I wanted the multiple buttons for an easier visualisation when animating (like when you use a facial rig to control facial expressions).
But your script does what I want, which is the most important. So again, thank you.
if you want I'll put your name in the end credits when my movie is finished (not that it will be shown all over the world)

and if anyone still wants to make the multiple button thing, feel free ;)

with multiple buttons

jos · 2012-01-11

i made the script with multiple buttons. it does pretty much the same as br0t's script, but with for each LED a button. It makes the spheres as well, to keep the information wich button's for corresponding LED. if you want something changed, yoy can always mail me. (if you want your own mesh for a led i can make you a pickbutton or wathever) script in attachment.

Attachments

another idea

Anubis · 2012-01-12

i see you start with max script, good, so maybe you'll appreciate an idea (with less scripting and other benefits). this dialog with buttons for each led-object seems to me alot of clicking, a bit more visual but not very natural for animating.
what about this - make 2 circular objects (sphere or cylinder) a bit bigger than "dots"-shperes (as your "eye"-area is more than 1 shpere) to serve as "helper objects" and animate easy by hand as you like their XY movement. and at the end you'll need just 2-3 lines of code to animate the materials according to intersection btw 2 "eyes" and "dots".
if i was some free time w'd made a demo video to see how easy is and that helps to focus on animation, not on clicking frame-by-frame and dot-per-dot. but with 5 years in Max am sure you get what i mean, cheers!

[EDIT]
Ok, i spen a little time to record a video tut. Cheers!

br0t · 2012-01-11

haha feel free, just post the movie here when its done :D