home |  downloads |  help  |  forum  |  contact us 
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2013, 08:58:39 PM

Login with username, password and session length
Search:     Advanced search
fragMOTION 1.2.2 Released!
2787 Posts in 689 Topics by 789 Members
Latest Member: seanfisher7886
* Home Help Search Login Register
+  Fragmosoft Forum
|-+  fragMOTION
| |-+  Scripting
| | |-+  Need a script, or is this possible...!
« previous next »
Pages: 1 2 [3] Go Down Print
Author Topic: Need a script, or is this possible...!  (Read 11322 times)
Rex
Sr. Member
****
Posts: 141


Out on the Range it's rough; no smiling allowed...


View Profile WWW
Re: Need a script, or is this possible...!
« Reply #30 on: August 03, 2008, 08:24:57 AM »

You read my mind, Dale!  Less precision and an error report, now this is a very useful Thread.

Thanks again, this is great!
Logged
Pelgar
Full Member
***
Posts: 89


View Profile
Re: Need a script, or is this possible...!
« Reply #31 on: August 03, 2008, 08:42:37 AM »

Rex, glad you like it, this has been a really fun little project!

Did you say that you were activating the script with a button? If so I'd like to know how you did it, I was going to work on that next but if you've already done it it would save me a little digging.

I sent you a PM in the Fragmo forum earlier, just to try it out. Let me know if you got it.

Here's a couple of icons for you http://home.alltel.net/daleharper/Dicons.zip   Grin
Logged
Rex
Sr. Member
****
Posts: 141


Out on the Range it's rough; no smiling allowed...


View Profile WWW
Re: Need a script, or is this possible...!
« Reply #32 on: August 03, 2008, 10:19:38 AM »

Got it all working great, Dale.  Here's what I'm using right now:

--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];
   WrldX =string.format("%.4f", WrldX);                           --change the 4 in %.4f to 5 if you want 5 decimal places, to 6 for 6 decimal places...
   WrldY =string.format("%.4f", WrldY);
   WrldZ =string.format("%.4f", WrldZ);
   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];
      WrldFrmX =string.format("%.4f", WrldFrmX);  --change the 4 in %.4f to 5 if you want 5 decimal places, to 6 for 6 decimal places...
      WrldFrmY =string.format("%.4f", WrldFrmY);
      WrldFrmZ =string.format("%.4f", WrldFrmZ);
      print(BoneName.." Bone:  "..AnimName.." Anim, Frame "..CurFrame..",  World   X = "..WrldFrmX.."    Y = "..WrldFrmY.."     Z = "..WrldFrmZ);
     
else print("No Animation selected");
   end                                                           --end if (anim:isSet()) then
else print("No Bone selected");
 end                                                              --end (if Start_id > 0 then)

--End Script


I limited precision to just 4 places, might bump it up to 6.

Ah...to get a button.

1. Customize User Interface.
2. Bring up Main Toolbar[or where you want the 'hardwireShortcut'] listing.
3. RMB click on Main Toolbar--New--Tool Button--I used a button here, you could use a check/toggle[?]
4. Select new Button[at bottom of list], while holding LMB; move to desired bar location, release LMB.
5. While button is still selected, see Name, Caption, Script in right pane.
6. Navigate to proper script in Tree with click on "..." in Script entry field.
7. Go to script in Customize User Interface to edit Icon entry and Invoke the script to see .ico change, or it should.
8. Done.

Doing those steps put an icon on my Main Tool bar with an icon I chose, along with a Name and Caption.  When I want to check a transform, I select a bone and click my button, and the output pane gives my result!  Perfect.

« Last Edit: August 03, 2008, 10:34:16 AM by Rex » Logged
Pelgar
Full Member
***
Posts: 89


View Profile
Re: Need a script, or is this possible...!
« Reply #33 on: August 03, 2008, 11:27:49 AM »

Thanks Rex! I'll see if I can add a tool bar button soon. While I'm fairly deep into scripting I've started a script that will, I hope, remove every other frame from an animation then adjust the frame rate. I've been doing this manually on a lot of TrueBones animations as I loop them and get them ready for use in TGE. 50 and more frames at 30 to 60 fps seems a bit excessive for simple loop animations like walk, run....
Logged
Pages: 1 2 [3] Go Up Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Fragmosoft Forum | Powered by SMF 1.0.8.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!