Pages: 1 [2] 3
|
 |
|
Author
|
Topic: Need a script, or is this possible...! (Read 11485 times)
|
|
fragmo
|
You need to keep in mind that the classes listed in the SDK docs are C++ classes and can't be printed like Lua objects. Passing a matrix to print will simply show you the memory location. Try this:
for i=0,15,1 do print(mtxLocal[BoneID].m[i]); end
dave
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Thank you Dave! That was exactly what I needed. If I ever figure out where that m in "[BoneID].m[i]" came from I'll probably feel pretty stupid. I've tried very similar code but always with numbers or x, y, z but never "m". It also surprised me a bit to find that the matrix returned by BuildLocalTransformList is a 4x4. There is apparently a lot more than just transform info returned by BuildLocalTransformList. Rex, now that Dave has be back to work, instead of just scratching my head and wondering why nothing seems to work, I want to make sure that we are using the same Manual Joint Editor in MS. Would you take a look at http://home.alltel.net/daleharper/ManualJointEditor.jpg and tell me if this is the one you are using? I hate to keep using this forum for this sort of thing but email doesn't seem to work and I do not use IM at all.
|
|
|
|
|
Logged
|
|
|
|
|
Rex
|
Sorry, Pelgar, about my email calamities....I don't have that account hooked up to my mail client and have to use my IM program to see that account...
Yes, that is the same dialog I have been using to find the world coordinates for a node/joint in Milkshape3D.
Thanks again, Pelgar; I'm sure this script will help out the artists out there, not just little ole me!
Your generosity is appreciated.
Oh, one last BTW...hope it won't make a difference; I'm running an older version of fragMO, v.87. When I upgraded to .91; some of my existing library of motions did not merge into my reference Scene without errors[unlike v.87..]; so I backtracked and regressed to my earlier copy. At the very least, this Thread would be a good example of how to construct a script for workflow ilmprovements.
Cheers!
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Rex, The first thing that comes to mind with Fragmotion version difference is maybe the version of Lua they are running. How about trying the following script and see what version of Lua you are running. .91 is using Lua version 5.0.2
print(" ") --print blank line print("Lua version test") print("The LUA version is ".._VERSION)
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Pelgar
|
If I ever figure out where that m in "[BoneID].m[i]" came from I'll probably feel pretty stupid. Well I was right about one thing, I do feel pretty stupid right now. I've probably looked at matrix.htm in the FRAGMOTIONLib ten times in the last few days. Thanks again Dave!
|
|
|
|
|
Logged
|
|
|
|
|
Rex
|
Whoo Hoo! You are helping me learn a ton here, Pelgar; you are now the fragMO 'scriptDuder'!! I stumbled my way thru your suggestion and it worked. I used the Customize UI and navigated to the 'Scripts' listing. I created my own little folder and used the RMB to put a new LuaUIScript in the folder. I double clicked this file[the other type I could not get an edit window to open] and pasted your lines of code inside. With the dialog still open, I clicked the Invoke button and forgot to have my output pane open; d'oh! Once I got that viewable, the result I get with running the script is "Lua version test--The LUA version is Lua 5.02"!!
Now, when I searched for any .lua file types to open with the editor, I found none in the fragMO Tree....so, I saved this script as a .lua filetype and have that in my custom folder....wow, thanks a lot. I'm sure I'll figure this out, I'm fairly used to the TorqueScript and am beginning to combine the two arts; geometryShapes and scripting.
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Rex, Sorry, I should have included instructions for running the script. At least we have the same Lua version running. BTW, I posted a bunch of little sample scripts in the Fragmotion Tutors section yesterday. While your getting a grip on scripting you may want to play with some of them. None of them are Fragmotion specific, just generic Lua.
I've really wanted to get heaver into scripting in Fragmo for a good while now. This has been a good excuse to dive in heavy.
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Rex, sorry for the delay, after Fragmo got me going again I had to break off of your script for a little while and do some experimenting with the SDK and Lua scripts. It was worthwhile, I learned a lot and took some pretty good notes. I'll try to work them up into a tutor some day, hopefully soon. I do have a script ready for a test run. Hopefully it is along the lines of what you want/need and will run properly on Frag .87 It is set to run with a Hot Key (Accelerator in FragMese) (alt-z) right now. I'll try to add a menu bar button soon. Of course you can change the hot key to about anything you want. It prints the report in the output pane, maybe we can work out a better way soon. I exported the script to an xml file and zipped it. You can download it at http://home.alltel.net/daleharper/BoneWorldPos.zip It's actually a little easier to import an xml file into Fragmotion than a script. 1. Unzip the xml to your Fragmotion\schema\UI folder (Don't place it in the globals folder, the script does not have any global variables or functions) 2. In Fragmotion go to Edit/Customize User Interface 3. Select File/Import User Interface Objects... in the menu bar 4. browse to you Fragmotion\schema\UI folder 5. Load BoneWorldPos.xml 6. Now if you select the Scripts folder in the Customize User Interface pane you should find BoneWorldPos at the bottom of the list 7. If you want to change the hot key: select BoneWorldPos in the Lua Folder and click Accelerator under Binding, then click the three dots and a dialog will pop up. 8. You can close the User Interface Window and press Alt-Z anytime you want the World Pos info. If nothing happens make sure you have a bone selected, the output pane is open, if you want frame cords an animation has to be selected. 9. Let me know what you think.
|
|
|
|
|
Logged
|
|
|
|
|
Rex
|
Thanks, Pelgar. I installed it and I got some odd Tool pane results. I have new folder headings with icons that are blank...?? I got a Vertex Animation folder I don't remember from before and there are what appear to be new 'tools' to use in existing Tool listings..??
I tried to delete the .xml and reload fragMO, but I still have these empty tools and icons in my panes?
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Rex, I don't have a clue what's going on. I'll take a look at the xml and make sure that I didn't export more than I should have. Try removing the xml file from the Fragmotion\schema\UI folder then delete BoneWorldPos from Customize User Interface Scripts. Hopefully that will get rid of the extra tools and such that were added.
Vertex animation is part of Fragmotion .91 I don't know about .87. I guess I should have just gave you the script to start with. I've posted it below, the script alone should not add anything to your tool panes.
Once you get Fragmotion cleaned up try the script code listed below. In Fragmotion Edit/Customize User Interface, select Scripts in the List Box, right click the Scripts folder, select New/UI Script/Lua Script in the pop up. Drag to to bottom of the Scripts folder, there should be an empty script named LuaUIScript. Rename it to whatever you want in the right property panel at LuaUIScript/Name. Select LuaScript/ScriptCode and click the three dots to bring up the script editor. Paste the code below into the editor.
--Start Script editChar:ClearOutput(); --Clear the output window
local skel = editChar:GetSkeleton(); local CurBone = editChar:GetSelBone(); if (CurBone:isSet()) then -- if there is a bone currently selected Start_id = CurBone.ID; -- Save the ID in global var Start_id. else Start_id = 0; -- if no bone is selected set Start_id to 0 end -- end if/then statement if Start_id > 0 then --if no bone is selected don't execute the script local mtxLocal = matrix_Array(); local boneMap = BOOL_Array();
BoneID = CurBone.ID; local BoneName = CurBone.Name; skel:BuildLocalTransformList(mtxLocal, boneMap, 256); local WrldX, WrldY, WrldZ = mtxLocal[BoneID].m[12], mtxLocal[BoneID].m[13], mtxLocal[BoneID].m[14]; print(BoneName.." Bone: Bind Pose World X = "..WrldX.." Y = "..WrldY.." Z = "..WrldZ); local anim = editChar:GetSelAnimation() --Get current selected animation if (anim:isSet()) then -- if there is an animation currently selected local CurFrame = anim.CurrentFrame; --Get current animiation frame local AnimName = anim.Name; skel:BuildTransformListFrame(CurFrame, anim, mtxLocal, boneMap, 256); local WrldFrmX, WrldFrmY, WrldFrmZ = mtxLocal[BoneID].m[12], mtxLocal[BoneID].m[13], mtxLocal[BoneID].m[14]; print(BoneName.." Bone: "..AnimName.." Anim, Frame "..CurFrame..", World X = "..WrldFrmX.." Y = "..WrldFrmY.." Z = "..WrldFrmZ); end --end if (anim:isSet()) then
end --end (if Start_id > 0 then)
--End Script
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Rex, I took a look at the xml and I'm pretty sure I know what's going on, not so sure about why! I was playing with one of FragMo's sample scripts, show hidden, this afternoon. It looks like it was exported too when I exported my script. You should have a new icon on the right of your tool bar. If you click it once the new folder, tools... should go away. Click it again and they will come back. The script just toggles the hidden items in Fragmotions varios panes on and off.
Let me know how it works out.
Dale
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
The xml file in the link above has been fixed. I apologize for the screw up Rex! You should be able to use either of the methods listed above to get the script up and running.
|
|
|
|
|
Logged
|
|
|
|
|
Rex
|
Thanks, Dale! I got my fragMO back to where it was, no problems; always some 'unexpectedness' when you start typing and combining art...lol.
Also, good job on the script and posting it publicly here; I know it will help others behind myself along.... I'm using it just as a script, at the moment, and it works perfectly, in both bind pose and in an animation sequence!!! I got it to a button on my UI and it's all good now....just need a nicer icon than the default 'file' one...lol. I thought it had a error dialog for not having selected a bone, but no matter....does exactly what I need!
Whoo hoo!
It is amazing how you can just start typing away and get fragMOTION to do what you need...
|
|
|
|
|
Logged
|
|
|
|
|
Pelgar
|
Rex, it would be very easy to add an error message if no bone is selected. Try changing the bottom to lines:
end
end
to: else print("No Animation selected"); end --end if (anim:isSet()) then else print(" No Bone selected"); end --end (if Start_id > 0 then)
I actually posted the code yesterday for you to try, I was planning to do a bit more to it but thought it would be a good idea to make sure it runs on Frag .87 first.
If you want to remove a few of the decimal places in the report try adding
WrldFrmX =string.format("%.4f", WrldFrmX); --change the 4 in %.4f to 5 if you want 5 decimal places, to 6 for 6 decimal places...
between
local WrldFrmX, WrldFrmY, WrldFrmZ = mtxLocal[BoneID].m[12], mtxLocal[BoneID].m[13], mtxLocal[BoneID].m[14];
and
print(BoneName.." Bone: "..AnimName.." Anim, Frame "..CurFrame..", World X = "..WrldFrmX.." Y = "..WrldFrmY.." Z = "..WrldFrmZ);
of course you will need to do this for any variable that you want to control the number of decimal places for, this example only changes the WrldFrmX variable.
|
|
|
|
|
Logged
|
|
|
|
|
Pages: 1 [2] 3
|
|
|
 |