home |  downloads |  help  |  forum  |  contact us 
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2013, 10:57:28 PM

Login with username, password and session length
Search:     Advanced search
fragMOTION 1.2.2 Released!
2787 Posts in 689 Topics by 788 Members
Latest Member: cliffordbryant4145
* Home Help Search Login Register
+  Fragmosoft Forum
|-+  fragMOTION
| |-+  Scripting
| | |-+  Problems with IAnimation::ID
« previous next »
Pages: [1] Go Down Print
Author Topic: Problems with IAnimation::ID  (Read 2676 times)
Pelgar
Full Member
***
Posts: 89


View Profile
Problems with IAnimation::ID
« on: October 21, 2008, 04:12:11 PM »

I'm trying to use the IAnimation::ID (get_ID()) function to get the ID of an animation but everything I try fails.
I have tried all of the following in the example code below:
local dwAnimID = pAnim:ID;   
local dwAnimID = pAnim.get_ID();
local dwAnimID = pAnim:get_ID();

local dwAnimID;
pAnim.get_ID(dwAnimID);

local dwAnimID;
pAnim:get_ID(dwAnimID);

I have successfully used code similar to the following to get a bone ID but this does not seem to work with an animation.


local pAnim = editChar:GetSelAnimation();      --get pointer to the selected animation (IAnimation)
if (pAnim:isSet()) then                   -- if there is an anim currently selected
   local dwAnimID = pAnim.ID;
   else print("No Anim Selected");   
     end      

I have tried this in FragMotion 0.9.1a and 0.9.5 with all of the above failing with an "ID no such member or child) error or "get_ID no such member or child" error.
I know that I am probably missing something simple but I can't imagine what it is.

Thanks

Dale
Logged
Pelgar
Full Member
***
Posts: 89


View Profile
Re: Problems with IAnimation::ID
« Reply #1 on: October 22, 2008, 04:26:23 AM »

It looks like I need to know how to either initialize a VARIANT variable in LUA or convert an int to a variant. I'm simply trying to read an animation DWORD property into a LUA script, modify the value, then write it back. Unfortunately the only functions/methods I can find to update the property require a variant.

I used IUserObject::GetValueDWORD to read the property value but hours of searching and trial and error have left me no closer to updating this simple property value than I was when I started.

Hours of Google searching and searching my Visual C++ documentation have left me drawing a blank. I can't even find a list of VARIANT methods??? I did find an MSDN article titled something like "Variant Ignorance is Rampant". You would think that article would make at least a slight effort to clear up some of the ignorance, but hey as I said it was a MSDN article! 
Logged
fragmo
Administrator
Not A Newbie
*****
Posts: 10664



View Profile
Re: Problems with IAnimation::ID
« Reply #2 on: October 23, 2008, 04:29:32 PM »

The properties aren't accessible from the specialized interfaces (IAnimation, IBone, ...) via script so you'll need to cast the object to IUserObject first.  And 'ID' is a special case that isn't exposed as a property but rather as a method (Get/SetID) so try playing with a different property...

local pAnim = IUserObject(editChar:GetSelAnimation());      --get pointer to the selected animation (IAnimation)
if (pAnim:isSet()) then                   -- if there is an anim currently selected
   local num = pAnim.NumFrames;
   pAnim.NumFrames = num * 2;
   print("NumFrames=", num, ": changed to ", pAnim.NumFrames);   
end

In case you still want to know how to work with the ID value...

local pAnim = IUserObject(editChar:GetSelAnimation());      --get pointer to the selected animation (IAnimation)
if (pAnim:isSet()) then                   -- if there is an anim currently selected
   local dwAnimID = pAnim:GetID();
else print("No Anim Selected");   
end


dave

Logged
Pelgar
Full Member
***
Posts: 89


View Profile
Re: Problems with IAnimation::ID
« Reply #3 on: October 23, 2008, 04:40:34 PM »

Thanks Dave,
I saw the See Also: link to IUserObject in the IAnimation::ID details, probably should have tried that route too just didn't think of it.

Dale
Logged
Pages: [1] 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!