Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / How to play an object3D animation?

Author
Message
Kot
1
Years of Service
User Offline
Joined: 2nd Mar 2017
Location:
Posted: 9th Dec 2017 10:02
In AppGameKit there is a command PlayObjectAnimation( objID, animName, starttime, endtime, loop, tweentime ) . I found some animated objects in the Internet, but the animation is described by frame numbers, e.g. frames 21-31 attack, frames 32-39 got hit etc. I opened the object file, but it was not human-readable and I didn't find any animation names. How can I animate those 3D objects?
puzzler2018
User Offline
Joined: 8th Oct 2017
Location:
Posted: 9th Dec 2017 10:25
Hi

I dont like working blind...

I suppose the golden question would be from everyone would be - unless of course someone knows exactly.

Do you have

- an axample of a .obj file that you could upload for us to test with (as long as it doesnt upset copyrights on that object) - dont upload if it does

- What source code do you have so far that your trying to work with that could show ones here that its not working, so can get it working

D


Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 9th Dec 2017 16:30 Edited at: 9th Dec 2017 16:46
Have you tried using the command...

GetObjectAnimationName()

Just write a little snippet to load the model and use that on it with a print to display it.

That will show you the name of the animation, then you will be ready to use it fully in your program.

I suggest writing a separate snippet, so you can use it again on other models that you download in the future.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
hoyoyo80
2
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 9th Dec 2017 23:36
For AnimName, u can use blank( " "),the use the frames range.

My animation is exported from blender and i dont know how i can name the animation.
Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Dec 2017 01:28 Edited at: 11th Dec 2017 18:34
Here is a modified version of my model viewer for AGK.

I just added in the animation features today, so I hope it doesn't have any bugs in it. (test it for me, see attached ZIP)

W, S, A, D - tilt and pan the camera

Q, E - rotate the object

Arrow Keys move the camera on X and Z

Right Shift and Enter move the object up and down.



The folder opens your model. ( I added more file extensions other than just X like before, but your textures need to be PNG)

If it has more than 1 animation, then the 3 little buttons next to the folder appear to navigate though the animations.

The program displays..
The Model's File Name
The # of animations for that object
The Name of the animation selected (I have number 2 selected in the screenshot)
The number of frames for the animation selected.

The buttons to the right of the animation navigation buttons are for playing the animation selected.

The first button is for the Frames Per Second you want to play it (speed) just click it to increment and 20 is max, then it cycles back to 1 fps

The next Button that says STOP in the image above also PLAYs the animation, so you can PLay then Stop on a frame , then Play again to resume.

The next button is the reset for starting the animation at the first frame again, but you have to STOP before you can RESET, not while playing.

The next button over (says 5 in screenshot) just displays the current frame you are on.

I hope this helps, and I know it is very basic right now, but I will be adding to it now and then.

Quote: " I found some animated objects in the Internet, but the animation is described by frame numbers, e.g. frames 21-31 attack, frames 32-39 got hit etc."

It sounds like that object has all of the animations together in one animation name, just like the FPSC classic models.

So, all you will need is the animation name and you will be good to go if you follow the instructions in the help manual.

Just load the object in this program and it should tell you the name.

Edit
I have deleted the old ZIP because I added mouse controls as requested.

Hold down the left mouse button to move the model left - right - up - down

Hold down the right mouse button to rotate the model left or right

Use the scroll wheel (if your mouse has one) to move the camera forwards or backwards for zooming

I will be adding a start and end range for the animation playback soon, for those models that have all animations named as one.

I also went back to starting at zero, so the program frame numbers coincide with the time AppGameKit uses for playing animations.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Kot
1
Years of Service
User Offline
Joined: 2nd Mar 2017
Location:
Posted: 10th Dec 2017 19:42 Edited at: 10th Dec 2017 19:50
Thanks for the replies, but the model I've got has only one animation that covers all the actions. It's a free model, so it's here as an attachment. Lots of models available in the Internet are done this way and it's a pity AppGameKit can't play animations by frame ranges. The model viewer is great, but it would be even greater if it could give names to the animations and play them by one frame back nad forth, so the user could precisely set the starting point for the animation
BTW, nice zombie - is it free?

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Dec 2017 20:11 Edited at: 10th Dec 2017 23:00
Quote: " The model viewer is great, but it would be even greater if it could give names to the animations and play them by one frame back nad forth, so the user could precisely set the starting point for the animation"

It does give the name(s) of the animation(s).

You then just have to use that with the command you put in your original post.

You said you already have the text with the model for which frames are which animations, so you know what range to play.

I do plan to have a START / END Frame slider to select the frames you want to play, but that is on the to-do list.

I think I will go back to starting at zero instead of one so that it will be an exact match when playing in AppGameKit .

Quote: "BTW, nice zombie - is it free?"

That is the Brute that Bond1 made for FPSC classic years ago. (he made one with a chainsaw and another with an axe)

I think the Brute characters were part of the Freaks and Abominations Model Pack. (mp22?)

I doubt if he was a zombie, just some guy who had bad burn scars, because he had a pile of corpses he had cut up with his chainsaw.

I'm not sure if it is free now or for purchase or even available, but you could search the FPSC Classic forum to possibly find out.

Quote: "the model I've got has only one animation that covers all the actions. It's a free model, so it's here as an attachment. "

I'll take a look at it.

Edit
It looks like your animation name is ... "<MS3DMasterAnim>" (when loading the zombie02.ms3d)

So, according to the models documentation, the first walk cycle is between frames 2 and 20

PlayObjectAnimation( objID, animName, starttime, endtime, loop, tweentime )

PlayObjectAnimation( objID, "<MS3DMasterAnim>", 2, 20, 0, 0)

Where objID is the ID that you gave the model when loading it.

...

106-115 Kick Attack

PlayObjectAnimation( objID, "<MS3DMasterAnim>", 106, 115, 0, 0)

...

Of course you will need to set the animation speed for that model (after loading it and/or right before playing each animation if you want different speeds)

SetObjectAnimationSpeed( objID, speed )

That is why I have the speed button in the model viewer, so you can find the speed you want for your animations.

A heads up on this model... he mentions starting at 1 but animations start at 2 and his doc says 200 frames, but I got 201 in the viewer, so you made need to make a 1 frames adjustment to get them right.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Dec 2017 22:05
Quote: "For AnimName, u can use blank( " "),the use the frames range.

My animation is exported from blender and i dont know how i can name the animation."


His first model in the zip is a B3D format (blitz basic) and it has a null value for the animation name.

I am setting a variable to that value read in then calling the variable when playing, but I guess you could also use a "" null string as the name and it should work.

I added a check for the length of the string on that one and it came up zero, so I know it is null "" and not with any spaces " ".

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
blink0k
AGK Developer
5
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Dec 2017 03:22
Any chance of getting some mouse controls for moving around the model?
Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 11th Dec 2017 12:54 Edited at: 11th Dec 2017 19:03
Quote: "Any chance of getting some mouse controls for moving around the model?"

Sure, and I was thinking the same thing just yesterday.

I have added a new zip with the mouse controls in the post above.

This is just a side project that I haven't really put a lot of time into.

That is why I am using buttons for displaying info rather than text objects, which is what I need to do to make it look better. (even PRINTing the file names)

I will also add the start and end frames for playback for those models that have all the animations in one animation name. (to be continued...)

I had problems uploading, but I finally got it to go through, and I think I will start a new thread for the next installment.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 11th Dec 2017 22:40
Bump so you know I came back...

Here is the latest version with the ability to select the frames of animation for playing.

Model Viewer CE


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Kot
1
Years of Service
User Offline
Joined: 2nd Mar 2017
Location:
Posted: 14th Dec 2017 22:00
I must be doing something wrong, because when I use the command PlayObjectAnimation( objID, "<MS3DMasterAnim>", 2, 20, 0, 0) it shows only the first frame of the frame range, no matter what the second parameter is. I dealt with this problem with this piece of code, but I'd like to know how to do it properly :/

Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 14th Dec 2017 22:14 Edited at: 14th Dec 2017 22:47
Why are you manually incrementing the start frame???

You do not need to do that, because the PlayObjectAnimation command increments from the start time to the end time at the speed that you set for that objects animations.

Where is the Sync() call ?

PlayObjectAnimation( Zombie.Object, "<MS3DMasterAnim>", NrFrame, 200, 0, 0)

That should be inside of a condition so that it does not get called every cycle, just once to play then it does its thing.

Like a button pressed, else give it a flag so it will not call it again while it is playing

It keeps starting over at the first frame every cycle like it is now. (it never increments your variable because it can't reach the end)

You counter = 3 condition results in the frame increment only happening once, so unless your animation numbers are less than 3 then it won't be at the end.

You also define the image variable in uppercase, then call it in lower case

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
puzzler2018
User Offline
Joined: 8th Oct 2017
Location:
Posted: 14th Dec 2017 22:19
I really need to get into graphic design modelling - the example you gave earlier in thread conjoured looks awesome

Sorry to interrupt thread

D
Conjured Entertainment
AGK Developer
12
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 14th Dec 2017 22:51 Edited at: 14th Dec 2017 22:56
Quote: "I really need to get into graphic design modelling - the example you gave earlier in thread conjoured looks awesome"

if you are talking about that Brute character, then that is not my work. (I wish, but I am not good at characters)

Mark Blosser AKA Bond1 made that model, and yes he is a professional, and that character is from early on in his modeling career. (his later stuff is incredible)

My stuff is a lot simpler...


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Kot
1
Years of Service
User Offline
Joined: 2nd Mar 2017
Location:
Posted: 16th Dec 2017 20:39
@Conjured Entertainment: Thanks. There is no Sync() just because I cut out everything that was redundant treating it more as a concept than real code.
BTW: Did I mention that built-in AppGameKit help sucks? Ah, yes, I did, in another thread... I can't understand why the hell free programming languages like FreeBasic or QB64 have got great contextual help files or even their own wikipedias with search capabilities or at least great pdf help (as RFOBasic and X-11 Basic), while those you must buy - AppGameKit or Mintoris Basic suck in this area. I'd rather go and resolve Great Pyramid and Sphinx mystery or equally easy problem like quantum mechanics... just my 2 cents :p
PHeMoX
User Offline
Joined: 9th Jan 2018
Location:
Posted: 27th Feb 2018 19:48
Quote: "BTW: Did I mention that built-in AppGameKit help sucks? "


Yeah kind of true unfortunately. I love it when the F1 help function on a command takes you to a webpage with an actual working example of the AppGameKit command, but so often there's not much there.

At the moment I am trying to get animations to finish when started once. When taking the Help text literally regarding the 'loop' and 'play once' functionality, my code should already be working. But.. as my code restarts the animation command, the whole 'play once' counts more like 'as long as the animation is called, only play once'. So... for someone holding a key to walk, you would need to use 'loop' instead of play once. But this means that holding a key and quickly releasing it, won't finish the animation and appears glitchy.

Now don't get me wrong, I do understand my code can and probably will be rewritten in ways to support what the 'play once' and 'loop' should mean in a literal sense, but it's kind of unfortunate we don't get a bit more advice surrounding the command. And in a literal sense my code that's within a select and case type doesn't seem to literally restart each frame, despite how it probably should looking at my code. So... the whole 'continuing animation' seems to work half.

I think I understand why people want to manually increment the frames.

Login to post a reply

Server time is: 2018-06-24 21:18:47
Your offset time is: 2018-06-24 21:18:47