Animating IsHidden


#1

I want to animate object visibility during animation. As visibility subanim will not be completely hidden in viewport, I decided to animate IsHidden property:

delete objects
clearlistener()

attDef = attributes IsHiddenTrack
(
	parameters Main_Param rollout:Main_Rol
	(
		IsHidden ui:chk_IsHidden type:#boolean animatable:true default:false
	) 

	rollout Main_Rol "Parameters"
	(
		checkbox 'chk_IsHidden' "IsHidden" checked:true
	)	
)

masterCtrl = point isselected:true
emptyMd = emptyModifier name:"IsHidden"
addmodifier masterCtrl emptyMd
custAttributes.add emptyMd attDef
custAtt = custAttributes.get emptyMd attDef

for i = 1 to 10 do for j = 2 to 10 do
(
	obj = teapot pos:[i*50,j*50,0]
	fl = obj.scale.controller = scale_list()
	fl.available.controller = bezier_scale()
	fl.setactive 2
	fs = scale_script()
	fs.addnode "thisNode" obj
	fs.addtarget "isHidden" (getSubAnim custAtt 1)
	fs.setexpression "thisNode.isHidden = isHidden \n[1,1,1]"
	fl[1].controller = fs
)

Script controller is too heavy and will slow down everything. Any idea to improve performance?


#2

don’t waste your time. IsHidden cannot be animated. If you want to control the visibility of an object (including it during rendering), you should use its visibility control.

there are other suggested solutions: delete object’s geometry, scale node to ZERO, or move node out of camera. In some cases, this may work too.


#3

I did that before by scaling xform, but the only way that framerate will increase is to hide the object.


#4

What about replacing base object with empty object? Do we have an empty baseobject?


#5

Like what? Editable Mesh or Mesher?

No, nor Delete Mesh won’t help :smile:
Some kind of Cache can, though.

What kind of animation, I mean what modifiers, how heavy in vertex count?

Also, what is the purpose of this “animated” hiding, can’t you turn it off or hide it “by hand”?

Skin modifier will release FPS after last key (in active layer) - just trowing some things here…


#6

Denis, this seems work in Max 2019 and above:

attDef = attributes IsHiddenTrack
(
	parameters Main_Param rollout:Main_Rol
	(
		IsHidden ui:chk_IsHidden type:#boolean animatable:true default:false
		on IsHidden get val do
		(
			if isvalidnode (thisNode = (refs.dependentNodes (refs.dependents this)[1])[1]) do
			(
				thisNode.ishidden = IsHidden
			)
			val
		)
	) 

	rollout Main_Rol "Parameters"
	(
		checkbox 'chk_IsHidden' "IsHidden" checked:true
	)	
)

delete objects
clearlistener()
masterCtrl = Teapot isselected:true
emptyMd = emptyModifier name:"IsHidden"
addmodifier masterCtrl emptyMd
custAttributes.add emptyMd attDef
custAtt = custAttributes.get emptyMd attDef

do you think it may have problem with viewport driver or rendering?


#7

it’s easy to check… just try to render


#8

In Max 2016+ you could do something like this. Not perfect but seems to work and since it is not a “hack” I see no drawbacks using it.

plugin SimpleMeshMod ShowHideGeometry
name:"Show/Hide Geometry"
classID:#(0x7ec0b278, 0x5c4cb199)
(
	parameters main rollout:params
	(
		visible ui:chk_visible type:#boolean animatable:true default:true
	)

	rollout params "Parameters"
	(
		checkbox 'chk_visible' "Visible" checked:true
	)

	on ModifyMesh do
	(
		if visible then mesh else meshop.deleteFaces mesh #all
	)
)

#9

this is correct. It’s renderable…


#10

Slice modifier have a valid pos. controller to destroy mesh by itself.

And deleting mesh can bring back performance in some situations.

Splitting character meshes (in different nodes) is understandable way also
but don’t understand point here, how is viewport rendering and performance related to offline rendering…


#11

who said it is related? i didn’t…

I only said that if you want to really animate the visibility, you must use the visibility track, delete geometry, or scale to zero. everything else doesn’t work for rendering. that’s all.


#12

I have a process for channel rendering , I use mxs to rendering every frame , between frames I change object’s properties , maybe that’s another method ,use the script you posted to set visibility , use mxs to hide or unhide them between rendering


#13

I tried that, it will not increase the performance too much. compare to hide the object.


#14

I don’t understand why argue, if it’s enough just to take and try … I don’t need to do it, because I’ve already gone through it. Moreover, we even discussed it on this forum.

anyway … I do it again.

HideControlAttr = attributes HideControlAttr attribid:#(123456, 121212)
(
	parameters params rollout:params
	(
		hide_control type:#boolean ui:ui_hide_control
	) 
	rollout params "Hide Conrtrol"
	(
		checkbox ui_hide_control "Hide Owner"
	)	
)


delete objects
b = box name:#hide_test
ca = createinstance HideControlAttr
append b.baseobject.custattributes ca 

with animate on 
(
	for k=0 to 3 do at time (k*25) ca.hide_control = (mod k 2) != 0
)
c = b.controller.scale.controller = scale_script()
c.addnode "self" b
c.addobject "ca" ca[#hide_control]
c.setexpression "b.ishidden = (ca.value != 0); [1,1,1]"

Run this example and you will see that if you manually change the timeline it will look like working. But try rendering your scene animation from 0 to 100. You will see that it is not! NOT ANIMATABLE PROPERTIES CANNOT BE ANIMATED!

Some objects might have some not-animatable parameters (for example, “text” in the Text splineshape), that can be animated using the mechanics shown above. PARAMETERS! BUT NOT PROPERTIES!


#15

What performance are you talking about? Navigating the viewport, redrawing? This is fine and you can use anything as shown above. But you must understand that this is not real visibility and cannot be used in animation.


#16

The script only works in modify mode, because I used get handler, that will be validate only in modify panel. :slight_smile:
So I should find another handler, maybe “Scripted Animation Controller Plug-ins” which has “usePBValidity” option.


#17

I’m taking about framerate in viewport.
I don’t want to argue with either, I just want to find a hack or trick.
Why I try again while you discussed that? because maybe in new version of the max something is changed and we can use it.


#18

My focus is viewport, because animators want that. So we can even combine it with the visibility track that works in rendering.


#19

maybe it needs a different solution if you just want to manage the state of the scene at a specific time

you are not new to this business :wink: why are you so naive about MAX? :upside_down_face:


#20

compare to you I’m like a baby :slight_smile: , As you know sometimes somebody find a new trick, even undocumented stuff, so we can hunt it, and use it the code structure.
Anyway, If we leave the render problem for later, which handler you think we can find, that will be updated in time change and viewport update? As I said something like “usePBValidity” option, but for the custom attribute.