Maxscript importer for .t3d files generated from PhaseSpace motion capture system using the a full suit and cap with 28 LED's. The .t3d files are generated from C3DWorkbench as simple tab delimited text files with X Y Z data on each line. The number of points needs to be known before hand and set in the "num_dummies" var. I was importing 5 second blocks of motion at 30 frames a second, hence the hard wired number of frames in "num_frames" var.
This script generates an array of dummy objects to hold the motion data as a point cloud style data set. Each point's data is mapped as a keyframe on the dummy except where the point has dropped out or "popped" (if you use EEG nomenclature....) These are filtered out during the import to make it easier to fix the data in the curve editor. Be careful of frame 0, as it does not seem to filter correctly. (Will figure this out later)
macroscript TM_Importer category: "DuncansTools" ( num_dummies = 28 num_frames = 151 dummy_array = #() animationRange = interval 0 num_frames --create the array of dummies for d = 1 to num_dummies do ( dummy_array[d] = dummy () dummy_array[d].boxsize = [1,1,1] ) --local x = dummy_array[1].pos.controller --showProperties x --get the text file ( tab delimeted works. from excel ) in_name = getOpenFileName types:"Text 3d (*.t3d|*.t3d|All (*.*)|*.*|" if in_name != undefined then ( in_file = openFile in_name if in_file != undefined then ( -- turn on animation so we can automatically create keys with animate on ( for frames = 0 to num_frames - 1 do ( for dummies = 1 to num_dummies do ( -- read the pairs of values from the file x_val = readValue in_file y_val = readValue in_file z_val = readValue in_file -- put the values to the dummies as motion keys if x_val < 0.5 or x_val > 0.5 then ( at time frames dummy_array[dummies].pos.controller.x_position = x_val ) if y_val < 0.5 or y_val > 0.5 then ( at time frames dummy_array[dummies].pos.controller.y_position = y_val ) if z_val < 0.5 or z_val > 0.5 then ( at time frames dummy_array[dummies].pos.controller.z_position = z_val ) ) ) ) ) close in_file ) )
No comments:
Post a Comment