tumira Posted February 9, 2017 Share Posted February 9, 2017 Since we have SetAnimationFrame for entity, can we have GetAnimationFrame also ? This is for saving and loading. http://www.leadwerks.com/werkspace/topic/15738-saving-tables-and-variables/ Another questions is, is it possible to retrieve uniqueID for an entity ? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted February 9, 2017 Share Posted February 9, 2017 You can use SetKeyValue and GetKeyValue to create and get unique IDs. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9, 2017 Share Posted February 9, 2017 That's not really how it works. The entity doesn't have a strict animation frame it is set at. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted February 9, 2017 Share Posted February 9, 2017 EDIT - Weird, but Entity:GetAnimationFrame(#) is exposed to lua. I assume the reason its not documented is due to Josh's reason as the frame can be just an interpolated point between frames? EDIT2 - Sorry Genebris - yes it will cause a crash. I had that in my original post but erased it all after I saw Josh's post. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Genebris Posted February 9, 2017 Share Posted February 9, 2017 Does it work? For me it crashes, what values does it receive? Quote Link to comment Share on other sites More sharing options...
tumira Posted February 9, 2017 Author Share Posted February 9, 2017 @Josh How do we make the entity continue playing the animation when it is loaded back or even save the animation frame? Example the crawler is playing attack animation at frameno 15 when it is saved. How do we get the frameNo for saving? Quote Link to comment Share on other sites More sharing options...
Genebris Posted February 9, 2017 Share Posted February 9, 2017 You could count how much time passed since the start of animation and use GetAnimationLength to calculate current frame, I guess. But then you also need to take speed into account. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9, 2017 Share Posted February 9, 2017 This actually returns a mat4 containing the orientation at that frame number and sequence. However, this should not be used. I think this was an experimental thing for something else... 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted February 9, 2017 Share Posted February 9, 2017 How do we make the entity continue playing the animation when it is loaded back or even save the animation frame? Example the crawler is playing attack animation at frameno 15 when it is saved. How do we get the frameNo for saving? Other than the new PlayAnimation() command, are you not setting the frame value for the command SetAnimationFrame()? why could you not save that variable value? Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
tumira Posted February 9, 2017 Author Share Posted February 9, 2017 Other than the new PlayAnimation() command, are you not setting the frame value for the command SetAnimationFrame()? why could you not save that variable value? That frameNo15 is just example. In realtime how would you know which animation frameNo is playing ? We can save the state "attacking" by saving the state value but we could not know at which frameno it is playing to save. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9, 2017 Share Posted February 9, 2017 Other than the new PlayAnimation() command, are you not setting the frame value for the command SetAnimationFrame()? why could you not save that variable value? The frames can be blended together, so there isn't one single animation or frame playing. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted February 9, 2017 Share Posted February 9, 2017 You are setting that frame value for SetAnimationFrame() - so save it as member for that entity to be gathered at a later time. Yes, Josh I understand that the actual frame being set could be an interpolation but for the most part a person could get away with grabbing the integer value of the current frame value and no one would be the wiser. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted February 9, 2017 Share Posted February 9, 2017 I added a GetFrame() function to the old AnimationManager.lua (one was there but I tweaked it). However, that has a way to expose the current "frame". Not sure about the new way. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9, 2017 Share Posted February 9, 2017 You are setting that frame value for SetAnimationFrame() - so save it as member for that entity to be gathered at a later time. Yes, Josh I understand that the actual frame being set could be an interpolation but for the most part a person could get away with grabbing the integer value of the current fame value and no one would be the wiser. You can also have multiple instances of the same sequence that are being used at the same time. There isn't one definite value for the frame sequence. Why are you asking for this? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted February 9, 2017 Share Posted February 9, 2017 I added a GetFrame() function to the old AnimationManager.lua (one was there but I tweaked it). However, that has a way to expose the current "frame". Not sure about the new way. yeah doesn't appear to be a way to grab it from the new PlayAnimation(), but the older method or using the old Animation Manager script, you should be able to grab that value since the user is the one setting the frame value. You can also have multiple instances of the same sequence that are being used at the same time. There isn't one definite value for the frame sequence. Why are you asking for this? I am not - just giving ideas on how to get this value. Are you talking about multiple instances of models playing the same sequence that may be at different points in their animation? If so, you would grab that value just like you would for anything else for that specific instance. The question arose because they are wanting to save the animation value along with other states when saving a game. I assume this person is also tracking entities so he can save their position, rotation, health, animation sequence name, etc... so i am having trouble understanding why the current frame (or at least a very close approximation) could not be saved as well. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Rick Posted February 9, 2017 Share Posted February 9, 2017 For our purposes, we are syncing the "frame" one a zombie struggle animation with fps arms struggle animation so they are playing the same "frame" so it looks right as the animations between the 2 were created to match. Tum is talking about saving that data, which I'm not sure why you'd ever want to do that. Quote Link to comment Share on other sites More sharing options...
tumira Posted February 9, 2017 Author Share Posted February 9, 2017 Now im confused. Is there a way to grab the current entity animation frameNo or not with the new playanimation command? Quote Link to comment Share on other sites More sharing options...
Rick Posted February 9, 2017 Share Posted February 9, 2017 It doesn't look like it. For the sake of ease PlayAnimation() has it's limitations. If you want you can use the old AnimationManager.lua script and that has ways to get the frame that's being played. However, the question is why would you need this to save to disk? No game I've ever seen saves while something is in the middle of an animation and then when you load the game it starts right in the middle of that animation. That seems like an odd request. Quote Link to comment Share on other sites More sharing options...
tumira Posted February 9, 2017 Author Share Posted February 9, 2017 @rick. I think there is quite a lot of fps games is saving this syle. Example halflife1 and 2, farcry series, quake series. Not sure about farcry3 and 4. Doom1,2 i think even doom3. Doom 4 is actually using checkpoint style. I guess leadwerk engine is suitable for checkpoint syle? Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9, 2017 Share Posted February 9, 2017 There is no such thing as "the current animation frame", but there is such a thing as the current 4x4 matrix of each bone. I don't understand why you would want to save any of that data though. Just set the blending value to 1.0 the first time the entity is animated, and the viewer will never see anything wrong. I wouldn't even think about this until the game is near release. Even if blending is enabled, we're talking maybe a half-second delay the user will never notice. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted February 9, 2017 Share Posted February 9, 2017 I get the theory, I think: if you save right as a sword swing is about to take your head off, when you load the game, it should load back at that exact same point, not at the beginning where the player has time to avoid the swing. That said, I've never come across this issue in a game. Curiosity question though: if there is an endhook, how is there not a current animation frame? How would the animation know when to end if it doesn't know where it currently is? Quote Link to comment Share on other sites More sharing options...
Josh Posted February 9, 2017 Share Posted February 9, 2017 The animation manager has a stack of currently playing animations, which do track a current frame, but the stack can be any size and consist of any animations, including multiple copies of the same animation sequence. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted February 9, 2017 Share Posted February 9, 2017 Gotcha. I guess a compromise would be something like GetLastAnimationCurrentFrame but even that could get tricky if the last animation ends before a previous one. Quote Link to comment Share on other sites More sharing options...
TheConceptBoy Posted November 18, 2018 Share Posted November 18, 2018 I know this is an old subject but I wanted to pitch in my 2 cents. I think we do need something like that but @Josh is correct. There's no such thing as Frames with 3D. There are just static bone positions that get blended between. If you have a hand animation move from left to right, It can take 60 proverbial "frames" (like in-game FPS Frames) to blend between one position and another or you could slow play the animation at 50% the speed and now it takes 120 in-game frames. BUT Something like this would still indeed be useful for stuff like, when you need to sync some events with the key positions of an animation. For example without using the term "Frame", Say you have a character running animation, the point when the foot touches the ground, you put a trigger which does 3 things. 1) It plays the Foot Step Sound effect[ 2) It spawns a small dust particle as if the foot is kicking up dust. 3) It spawns a small decal sprite on the floor to make a shoe footprints or Bloody foot print if you stepped in a pool of blood. I would personally find it extremely useful for triggering sound effects. So what if instead of Frames we treat it as a float value? Have 0.0 being the start of an animation and 1.0 being the end. In this sense we are not dealing with any predetermined time formats like frames and if you decide to stretch the animation (By playing it at half the speed in Leadwerks) then techincally all your stuff would still be synced. Quote Link to comment Share on other sites More sharing options...
Josh Posted November 18, 2018 Share Posted November 18, 2018 I'm thinking about making a frame event system where every time a frame is passed your function gets called, or something like that. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.