Notifications
Clear all

[Closed] Best way to animate visibility of multiple objects with radiobuttons?

I want to set something up where only one of several objects is visible at a time. I have a control helper with a set of radiobuttons on a custom attribute rollout, corresponding to each of those objects I want to show or hide. When I click a radiobutton, the appropriate object is made visible, and the other objects are hidden.

Now, the radiobutton state can animate over time, and I’ve even got it set up so it use bezier steps to jump from one to another without selecting the in between states. What I would like would be if the visibility of the corresponding objects were to turn on and off as I scrolled along the timeline, in accordance with the radiobutton state.

Would this best be handled using animated parameters in the custom attributes, a time change callback, or something else I’m not considering?


EDIT: thread title changed for clarity purposes

34 Replies

If you link your radiobuttons values with nodes visibility true or false, you can try the ‘boolean_float()’ controller that takes only values of 0.0 and 1.0.for the visibility animation.

1 Reply
(@malkalypse)
Joined: 11 months ago

Posts: 0

The problem is there’s nothing to link to, since visibility is not an animatable property…

It’s a bit of a cheezy workaround, but I tried setting the scale controller to a scale script like so:

owner.isHidden = (viz.type != 1)
[1, 1, 1]

The problem is that it does not update immediately upon changing the radiobutton – I need to scrub the time slider to get it to activate.


EDIT:
Actually, never mind. I did get it updating properly. But again, I’d prefer to know the “right” solution not just whatever works…


EDIT AGAIN:
Yeah, I definitely need to replace this. It’s causing crashes at render time for whatever reason.

For visibility, you should work with the node visibility property (myNode.visibility) that is animatable, instead of the ‘isHidden’ flag.

If you want an example of this controller behavior, create a Populate Flow and open the TrackView Graph Editor for the visibility of a character that reachs the end of the Flow.

ClassOf $.visibility -> BooleanClass
ClassOf $.visibility.controller -> boolean_float

Okay, I see how to make visibility animatable now. But what do I do for connecting it to a radio button state state that is an integer from 1 to 7?


EDIT:
I thought I figured it out, but the results I am getting suggest otherwise. Where am I going wrong?

(
	delete objects
	teapot()
	viz = geoSphere baseType:1 segs:1 pos:[0,0,100]
	L1 = omniLight pos:[-100,0,0]
	L2 = omniLight pos:[0,100,0]	
	L3 = omniLight pos:[100,0,0]
	
	ca = attributes "ca" (
		parameters params rollout:RO (
			L1 type:#node
			L2 type:#node
			L3 type:#node			
			type type:#integer ui:rad default:1 animatable:true
		)
		rollout RO "RO" (
			radioButtons rad labels:#("1", "2", "3")
		)
	)
	custAttributes.add viz ca
	viz.L1 = L1
	viz.L2 = L2
	viz.L3 = L3
	
	for L in #(L1, L2, L3) do L.visibility = boolean_Float()
	paramWire.connect viz.ca[#type] L1[#visibility] "if (type == 1) then 1 else 0"
	paramWire.connect viz.ca[#type] L2[#visibility] "if (type == 2) then 1 else 0"
	paramWire.connect viz.ca[#type] L3[#visibility] "if (type == 3) then 1 else 0"
	
	at time 0 viz.type = 1
	at time 5 viz.type = 2
	at time 10 viz.type = 3
)

Actually, I’m not sure how the visibility track is supposed to work. I can directly type $.visibility = false and it does not hide the object…


EDIT AGAIN:
Okay, I see now. That’s the visibility for rendering. Not what I’m looking for.

What do you need exactly? Ligths disappearing, ligths not lighting, lights outside the viewports…? Nothing to do with lights?
‘visibility’ is effectively for rendering. And, as far as I know, the ‘isHidden’ is not animatable.

isHidden is not directly animatable, no, but there are ways around that using callbacks, etc. So I’m trying to determine what the best way to is to animate a “non-animatable” property.

In this case, I am working with lights. I want to use a control object to switch between multiple light objects, and to 1) both turn off and hide the lights which are not indicated by the radio buttons, and 2) turn on and show the light which IS indicated. And in fact that’s what I already have set up, but it currently does not animate.

there two different thins – truly animatable (animatable during render) and ‘a la’ animatable (using callbacks, time or view draw events)

which one is good enough for you?

Are they mutually exclusive? I’d like to be able to do both…

Page 1 / 3