Broadcast Time Changed


#1

Do you know how (or do you have an idea) to broadcast ‘time changed’ without actually changing the time? (sdk, mxs, any way…)


#2

What about starting and cancelling animation?

fn NotifyTimeChange =
(
	local _realTimePlayback = realTimePlayback
	realTimePlayback = true
	
	fn time_callback = (format "currentTime: %\n" currentTime;stopAnimation())
	
	registerTimeCallback time_callback
	playAnimation immediateReturn:false		
	unregisterTimeCallback time_callback
	
	realTimePlayback = _realTimePlayback
)

NotifyTimeChange()

#3

I assume the obvious doesn’t do what you need. :thinking:

slidertime=slidertime

#4

this one doesn’t call “time changed”…

NotifyTimeChange() above doesn’t work either.


#5

What is “time changed” ?


#6
delete objects

s = geosphere radius:100 wirecolor:green
for k=1 to 10 do
(
	p = point size:20 wirecolor:orange
	c = p.controller = transform_script()
	c.addnode #mesh s
	c.addconstant #id k
	c.setexpression "transmatrix (getvert mesh.mesh id * mesh.objecttransform)" 
)

tp = Taper()
addmodifier s tp
animate on at time 100 tp.amount = -1
	

you can see when you change Taper amount manually the transform scripts doesn’t update, because the only TimeChanged event is held for this type of controls


#7

I would have had a really hard time figuring out that this was what you were after.


#8

another simple way to test is to register time change callback and found a method to fire it without changing time

fn time_callback = (format "time changed\n")
registerTimeCallback time_callback
-- unregisterTimeCallback time_callback

#10

There seems to be some things that do fire the Time Callback but don’t update the controllers and other that do update the controllers but don’t fire the Time Callback, which is a bit weird.

For instance slidertime= slidertime fires the Time Callback but don’t update the controller time, $.pos=$.pos (among others) updates the controller but don’t fire the Time Callback.

One thing that do both is to set the Frame Rate from the Time Configuration dialog, so perhaps there is a notification that could be called.

Open the Time Configuration dialog and in the Frame Rate section click on the selected radio button, which won’t change the frame rate but will fire both, the Time Callback and the controller Time event.

Unfortunately, setting the frame rate from the SDK doesn’t work the same way, but perhaps it is a good place to look for.


#11

this fires it (well it triggers your callback up there ^^^^)…

def_visible_primitive(invoke_time_change, "invoke_time_change");

Value* invoke_time_change_cf(Value** arg_list, int count)
{
	enum args {  knum_args };

	check_arg_count(invoke_time_change, knum_args, count);
	
	GetCOREInterface()->SetTime(GetCOREInterface()->GetTime());
	return &ok;
}

#12

This one doesn’t trigger time change callback, but somehow updates helpers positions.

g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
g.coreinterface14.scene.FlagFGAnimated (int currenttime)
redrawViews()

#13

This is what I did at the beginning, but unfortunately (and unexpectedly) it doesn’t work for most constraint and scripts controllers that I want to update in one go.


#14

It works in my case! Thank. I will investigate this solution more closely and will report …


#15

isn’t that just enumerating the scene with

Animatable::EnumAnimTree

and sending something like…

NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);


#16

unfortunately not … most scripts and constraints are ‘protected’ from the dependency loop and use RefTargMonitors … so they quite often ignore simple notifications (REFMSG_CHANGE).


#17

I don’t know any constraint that uses RefTargMonitor


#18

If you need to update the scripted controllers instead of calling the time callback, wouldn’t this work?

mapped fn UpdateControllers ctrl = ctrl.update()
UpdateControllers (getclassinstances transform_script)

#19

this was my next option … but getclassinstances for large and complex scenes can be slow (and it it slow) and it takes a significant amount of time to find all controls and update them. Which makes a problem to update on spinner dragging for example.


#20

it might be INodeMonitor or INodeTransformMonitor… if geometry used it can be RefTargMonitor. Which is better parctice to use than direct reference or node.


#21

This update issue is inherent in any script controller class. So another problem is finding all instances of all script controller classes.