Notifications
Clear all

[Closed] animation about time data flow

I meet a problem when I use maxscript to animate an object, the problem as follow:
maxscript read or accept data from out equepment , and all the data are some position of the object ,what I want to do is use the data to animate the object moving as the real world happened

9 Replies

Best approach might be to actually interface with the Motion Capture utility – that will capture data input from devices like joysticks, in realtimer.

However, if you must let maxscript interface with it, you could…

  1. set up a timer to make the call that polls your device periodically

  2. use one of the following to derive the time at which the data was polled
    2a. the timer’s tick amount (be that maxscript timer or .net timer) – easiest to derive a delta time with
    2b. something like timestamp() or getLocalTime() to get a timestamp (with millisecond data) – you’ll have to record the current timestamp at the beginning of recording to get a delta

  3. from here, either…
    3a. adjust the objects in real time with animation keying set; set the sliderTime to the value corresponding to the time date you captured in step 2. Make sure you adjust the animationRange value if the recording will be outside the current animation range. Then set the recorded input value on the object(s). Note that this causes viewport redraws and may lag well behind your polling frequency.
    3b. record the data to a buffer, such as an array, so that you can apply the motion to the object(s) after recording.
    3c. use a combination of the above – the buffer for fast storage, and update the viewports once every N samples so that the user has some feedback.

Below is an extremely simplified example using the mouse


myObj = sphere radius:10 pos:[0,0,0]
rollout roll_test "test" (
	local startCoords
	timer tick_tock interval:100 active:true
	on tick_tock tick do (
		local numTicks = tick_tock.ticks
		if (numTicks > animationrange.end) do ( animationRange = (interval 0 numTicks) )
		-- make sure your time configuration is set to allow 'ticks'
		-- 4800 animation ticks per second, 100ms interval, so 480 ticks per timer tick
		sliderTime = 480t * numTicks
		mousePos = mouse.screenPos
		mouseDelta = startCoords - mouse.screenPos
		with animate on ( myObj.pos = [-mouseDelta.x,mouseDelta.y,0] )
		-- press Esc to stop recording
		if (keyboard.escPressed) do ( tick_tock.active = false )
	)
	on roll_test open do ( startCoords = mouse.screenPos )
)
createDialog roll_test
-- when done, hit Play (make sure realtime playback is on) and you should see your recorded animation

thanks for your help ,ZeBoxx2

maybe I didn’t descripe the question correctly
I just want hnow how to use the data to fitting the movement and make the animation look like just as the real world do;now I have the displacement data , but the data only some certain position of the object

uh, what I want to do is to use the data simulate the deformation such as a beam vibration in three-dimensional space

not 100% sure, but are you talking about soft body dynamics there? 😮

1 Reply
(@flyingaway)
Joined: 11 months ago

Posts: 0

soft body? uh , it should be a rigid body , I want to do a bridge vibration animation use the data collected by sensors

okay, so you don’t need any realtime input or dynamics simulation at all…

You basically have data, and timestamps for that data, and you want to apply that data as animation in the scene?

If so, all you’d need to do is…


 <loop over your data here>
 -- 4800 'ticks' in a second
 t = 4800t * (data_timestamp_in_milliseconds / 1000.0)
 with animate on at time t (
   <someobject>.<someparameter> = data_value
 )
 <data loop end>
 

thank you , but I am a beginner , I dont know how to use the data to make the object such as a long box to do some movement , yeah , I know how to do it , but I dont know how to write the code , that’s all what I faced . thanks again for your help

well, let’s say you’ve got the data in two arrays… one for the time and another for the value:


timeData = #(0,100,150,230,300,340,390,480,560,650) -- sample timestamp in milliseconds
valueData = #(10,11,8,12,10,7,18,15,12,16) -- same values

So that each value has an associated timestamp… i.e. valueData[2]’s timestamp is timeData[2].

Then going with the ‘box height’ example:


myBox = box()
for i = 1 to timeData.count do (
	t = 4800t * (timeData[i] / 1000.0)
	with animate on at time t (
		myBox.height = valueData[i]
	)
)

thank you ,ZeBoxx2
but what if I got a series of data in the same time ,for example , at a time I got tens of data of the difference position of the bridge ,how can I use the data simuteously to animation the movement

http://www.youtube.com/watch?v=j-zczJXSxnw&feature=related
ok , I think what I want to do is just like the viedo show, of course , not so intensity
the difficulty is how to use the data to animation the movement naturally