PDA

View Full Version : assign mocap data


oliverp19
04-05-2008, 10:27 PM
Hi,

I am an absolute beginner to maxscript, but not in programming at all. My task ist to assign different motion capturing data to a skinned model. I know the "normal" way how to do this in max, but I need to know how to do this through maxscript.

Is there a tutorial, I didnt found yet? What are the functions I should check?

Thanks
Oli

JHN
04-06-2008, 01:06 PM
You're not very specific... are you using Biped or a custum skeleton... what data do you put in fbx or something else... what exactly do you want that this script will do? Fully automatic loading of files and mocap data or just applying mocap data to a selection... There's a lot of unknowns here... what did you try already?

-Johan

oliverp19
04-06-2008, 01:38 PM
Hi,

sorry for being unspecific...I hope with answering your questions it will get better.

are you using Biped or a custum skeleton

It is an out-of-the-box biped.

what data do you put in fbx or something else

I am not totally sure, what you mean...the mocap-data is stored in .bip files.

what exactly do you want that this script will do?

First it would be great to load the mocap-data from file and apply it to the selecion.
I think, when this step is done I know how to get further...

I tried to find some stuff like this with google, but without any success...so I hope you can help me with some hints.

Thanks!
Oli

JHN
04-07-2008, 07:13 PM
Lookup "biped.loadBipFile" or "biped.loadMocapFile" in the maxscript helpfile.

Something like:


n = $.rootNode //select a biped part
biped.loadMocapFile n "c:\mocapdata\mocapfile"


To start with...?

Goodluck,
-Johan

oliverp19
04-07-2008, 10:38 PM
Hi,

thanks for your answer...I think it will help a lot, but unfortunatly I didnt reach the point where I can use it. I need to clone an existing skinned model with biped. Is there an special function for cloning a biped? I didn`t fount anything like this in the documentation...but probably I dont know enought about maxscript yet to look at the right place.

I have: a simple, skinned model with biped
I need: get an exact clone of it

When I select the model with the biped and clone it with Ctrl+V I got the result, I need. But unfortunatly the MacroRecorder doesnt help me, because there seems to be special commands for the recorder.

I hope my English was not too bad and you can help me.

Thanks!
Oli

shibumenon
04-08-2008, 07:54 AM
You may want to think about merging the same biped rig again into the current scene instead of cloning. This works best after renaming the existing biped and related nodes.

JHN
04-08-2008, 10:17 AM
I'm can't garantee it works, but look at the
"CloneNodes" code.. it may work, since it will take care of depencies to some extent.

-Johan

oliverp19
04-08-2008, 10:20 AM
thanks...but I dont understand exactly what you mean with "merging into scene".
Perhaps I should explain, what my final goal is:

We have a skinned model with biped and want to replicate this model. Afterwards I want to modify the model with some modifiers to change the look and assign mocap data to it.
At the end I want to have a few clones, which have a different look and does different things (mocap) in the scene.

I hope this explanation makes the thing more clear.

As I mentioned I am an absolute beginner to maxscript, so small code snippets would be extremly helpful.

thanks!
Oli

shibumenon
04-08-2008, 01:55 PM
I wrote a sample script for you during my lunch hour ... not yet done, but
you could go thro it,
It merges a character rig multiple times and then renames, and then modifies it ..
not commented yet ... will do so after I get home..



struct mocapImporterStruct
(
mCurMergedCharacters = #(),
mCurMergedBipRoots = #(),
mTheBipFileDir = "",
mCurRigPath = "",
mCurPrefix = "",
mCrowdCount = 0,

fn mergeACharacter theIndex =
(
curRigNodeNames = getMAXFileObjectNames mCurRigPath quiet:true;
mergeMaxFile mCurRigPath #select #useMergedMtlDups quiet:true;
allMergedNodes = for obj in $* where findItem curRigNodeNames obj.name != 0 collect obj
mCurMergedCharacters[theIndex] = allMergedNodes;
theBipRoot = for obj in allMergedNodes where (try(classof obj.controller == Vertical_Horizontal_Turn)catch(false)) collect obj;
mCurMergedBipRoots[theIndex] = theBipRoot[1];
),

fn renameCharacter theIndex =
(
-- #### CAUTION : This process of renaming is only a sample. Biped nodes may need to be renamed differently.#####
for obj in mCurMergedCharacters[theIndex] do
(
obj.name = mCurPrefix + (theIndex as string) + "_" + obj.name
)
),

fn modifyCharacter theIndex =
(
-- the below code needs to be changed if skin modifier is renamed to something other than "Skin".
allSkinnedObjs = for obj in mCurMergedCharacters[theIndex] where obj.modifiers[#skin] != undefined collect obj;
for obj in allSkinnedObjs do
(
addModifier obj (Push());
obj.push.push_Value = random 0.5 3;
)

),

fn loadBipFileOnChar theIndex theBipFile =
(

),

fn importMocapMultiple theIndex =
(
mergeACharacter (theIndex);
renameCharacter (theIndex);
modifyCharacter (theIndex);
)

)

iMocapImporterStruct = mocapImporterStruct()
iMocapImporterStruct.mCurRigPath = "C:/Shared/MaxMayaPipe/TestCharacters/MaxCharacters/skin_k0402_A.max";
iMocapImporterStruct.mCurPrefix = "Char_";
iMocapImporterStruct.mCrowdCount = 3;

for i = 1 to iMocapImporterStruct.mCrowdCount do
(
iMocapImporterStruct.importMocapMultiple i
gc()
)

oliverp19
04-08-2008, 01:55 PM
ok, I got a few more things...so here is the code, which does the cloning of my model with the Biped.


for i = 1 to 10 do (

maxOps.cloneNodes $ cloneType:#copy newNodes:&nnl
select #($Bip02,$Zeb_LR01)
mod_result = mod i 2
if (mod_result == 0) then
move $ [20,20,0]
else
move $ [-20,20,0]


n = $Bip01.controller
biped.loadBipFile n "C:\Users\Oli\Videos\Documents\3dsmax\mocap\walk-normal-takiguchi.bip"
)


The root-nodes of the bipeds are called "Bip01", "Bip02", "Bip03" and so on...at the moment I dont know, how to get through all these root-nodes and assign the mocap-data to them.

What is the best way to loop through all my biped root nodes?

Thanks
Oli

EDIT: thanks for the script, but it looks much more difficult than my one...comments would be very useful. thanks!

shibumenon
04-08-2008, 01:58 PM
change the path contained in the line:

iMocapImporterStruct.mCurRigPath = "C:/Shared/MaxMayaPipe/TestCharacters/MaxCharacters/skin_k0402_A.max";


to the path of your rig, and

iMocapImporterStruct.mCrowdCount = 3;

to the number of copies you need ....

oliverp19
04-08-2008, 02:28 PM
ok, thanks a million for your work...its works quite well!

but I am still having a few questions...so I want to understand the stuff and not only copy-paste it.

so could you please have a look on my code snippet and answer my questions corresponding to it (how to loop through all biped-roots) That would be great :-)

So...I will continue going through your script and understand the lines.

Thanks!
Oli

shibumenon
04-08-2008, 02:52 PM
ok, thanks a million for your work...its works quite well!
glad to be of help, Oli...
Am at work now, may not have time to comment/explain my code now, will do so after reaching home tonite. You could collect your questioon s and post them here ...

so could you please have a look on my code snippet and answer my questions corresponding to it (how to loop through all biped-roots) That would be great :-)

allBipRoots = for obj in $* where (try(classof obj.controller == Vertical_Horizontal_Turn)catch(false)) collect obj;
for obj in allBipRoots do
(
-- do your stuff here, eg. loading .bip files
print obj.name
)


cheers
shibu

oliverp19
04-08-2008, 04:26 PM
great...its working! here is my current code:


macroscript makeClone
category: "myScripts"
(
for i = 1 to 1 do (

maxOps.cloneNodes $ cloneType:#copy newNodes:&nnl

select #($Bip02,$Zeb_LR01)
mod_result = mod i 2
if (mod_result == 0) then
move $ [20,20,0]
else
move $ [-20,20,0]
)

)

macroscript assignMocap
category: "myScripts"
(
allBipRoots = for obj in $* where (try(classof obj.controller == Vertical_Horizontal_Turn)catch(false)) collect obj;
for obj in allBipRoots do
(
biped.loadBipFile obj.controller "C:\Users\Oli\Videos\Documents\3dsmax\mocap\walk-normal-takiguchi.bip"
)
)


Everything works fine (a bit slow, but it works ;))

But there appeared a new problem with the mocap data. as you see I move my clones in the background. but after assigning the mocap data all models are moved back to 0,0,0 (which is quite logically).

So I think I have to take all the keyframes of the different models and move them to their new position...is that right? How can I achieve that?

Thanks for your great help!

Oli

shibumenon
04-09-2008, 07:28 AM
You'll find all biped key manipulation stuff in :
Biped Keys &
bipedkey:MaxObject
in the Maxscript reference..

You could also think of using biped layers, moving the biped COM, and then collapsing the layer.
Biped Layers in Maxscript reference.

oliverp19
04-09-2008, 01:50 PM
thanks again! you are a good man :-)

i checked the reference for the functions, but didn`t get further with them...when i tried this code (only for testing):

key = biped.getKey $Bip01.controller 1

i got the following error: "Key index out of range:1"

so...the key wasnt found. but there are keys on the biped. when i select it, i can see them.

so...i got my clones with the motion-capture data and now i need to move and rotate them to their positions in the scene. i also checked the layer-stuff but i didnt understand that. unfortunatly there are nearly no free tutorials or forums about maxscript...so google isnt a big help.

i hope, you have some seconds for answering my questions :)

thanks a million!
Oli

EDIT: i found out how to move an animated biped (moveAllMode)...i know how to switch in this mode, but not how to set the values and collapse it with maxscript.

EDIT2: got it :)

d = dummy()
obj.parent = d
move d [20,20,0]
delete d

CGTalk Moderation
04-09-2008, 01:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.