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.

DarkBASIC Discussion / Character animations in DBC (bone / limb based)

Author
Message
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 17th Feb 2009 00:23 Edited at: 17th Feb 2009 00:29
Hi All,

Having desperately been searching for 1 or 2 animated characters (other than the fairly crude ones in Dark Matter 1) to use in first person shooter aspect of my space sim, I stumbled across the following fanstastic suite of sci-fi animated models

http://www.3drt.com/3dm/characters/hitomi/hitomi-shots.htm

However, it appears to use bone based animation (because when I downloaded a free monster sample the animations dont work). What I was wondering is, is there any way to get bone based animations to work in DBC or convert them to the required limb based animations (probably showing my ignorance here of what is involved in doing such a thing)?

I suspect the answer is no and ordinarily I wouldnt waste people's time posting here but I REALLY want to use these models!

Another route occurred to me which is can DBC and DBP work together. I dont have DBP but understand that bone based animations would work with it - is there anyway I could combine the majority of my space sim (written in DBC) with a FPS aspect that is written in DBP? More than happy to buy DBP if it means I can do this.

E.g. maybe its possible to have 2 executibles, 1 for the DBC space sim aspect and 1 for the DBP planet FPS aspect. When the player lands on a planet, the DBC code calls the DBP exe and allows the player to enter the FPS. When the player re-enters his spaceship and returns to space, the DBP calls the DBC executible. In between both transitions, a .txt file is output so that when the exe file is called, I can code within each a reference to the .txt file so that the exe knows not to start at the main menu (begining) but to jump to a particular point. Would this work (hope this waffle makes sense).

Cheers
Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 17th Feb 2009 02:47
Well do you have DBP?

~QJ
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 17th Feb 2009 03:01
No I dont but as I say, more than happy to buy it if it will permit what I'm trying to achieve
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 17th Feb 2009 03:04
The 2 darkbasic version split while maybe possible isn't a good idea. DBC and DBPro require 2 different set of requirements to run. Possibly anyone with specs that allow DBC to run will be happily chugging along until they switch to the DBPro section and then error out on a DirectX version requirement or some DLL specific to whatever version of Windows you are compiling the DBPro part on. Use one or the other for the whole game for consistancy.

Getting the models to work in DBC is possible but can take a lot of work. Beside the method I mentioned before about splitting the model into limbs at the joint points, creating a hierarchy and using bone key frames to create keys applicable to the limb hierarchy, probably with the free trial of DBPro you could play the animation of your model 1 frame at a time and after each frame, save the mesh of the current state of the model. Then load the meshes into DBC and use CHANGE MESH obj,0,mesh number to animate the model.

Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 17th Feb 2009 03:50
@Latch, thats a great idea (importing into the trial DBP and saving the meshes) but do you know if using the change mesh obj,0,mesh command run slower than the loop object obj no, start frame, end frame type approach.

ps I'm reluctant to use the "cut limb" approach you mentioned earlier as it sounds like a lot of work and I dont know if I would end up with as smooth an animation sequence as the original bone-animation.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 17th Feb 2009 11:28
Hi, I tried the DBP import method but no joy as each time I save a mesh in DBP it seems to be saving the very first frame (0) and not the one that is being set (the bone animations work fine in DBP so it cant be that (e.g. Loop object 1,0,30 works fine))

DBP
load object "monster-animated-character-X.x",1
for i = 1 to 31
set object frame 1,i-1
make mesh from object 1,1
save mesh "Chas"+str$(i-1)+".x",1
delete mesh 1
next i

i.e. I end up with Chas1-30.x files but they are all identical and not reflective of the actual frame that was being displayed on the DBP screen.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th Feb 2009 00:46
Strange. Perhaps it's a timing thing. What if you were to insert a sync or a wait after frame advancement and/or make mesh?

What if you advance the count of the mesh number with i ?

And I think DB starts counting frames at 1 with the set object frame command - I remember some kind of error in DBC when I tried to use set object frame x,0 I don't know though. I could be wrong on that.

And does DBPro's save mesh save the mesh as an X file? What might be happening is instead of refrencing the newly created mesh, it is referencing the original x file and just creating a mesh based on that xfile. In DBC the saving of the mesh would have to be through a memblock. Try two things: this first example is your code with a sync in it and i carrying the mesh number:



This second example goes on the supposition that SAVE MESH references an object and not a mesh created from an object. Therefore, we have to make new objects as we go along:



Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 18th Feb 2009 09:49
Thanks Latch - the first method worked!! My only concern now is that a higher poly model mean not run as fast using the change object animation method, than if I cut the limbs as you suggested before. Oh well, only one way to find out I guess.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th Feb 2009 12:06
Actually, in theory, switching a pointer to different meshes should be faster than the interpolation calculation and the repositioning of each vertex each frame in a model. I guess that depends on how DBC handles the changing meshes! But yeah, there could be a huge performance hit with tons of meshes loaded into memory. If you had 5 characters, each with 100 frames of animation - that's 500 meshes taking up a lot of memory.

The cut thing works as long as your 3d modeling program can copy or use the same keyframe information for a limb hierarchy as the original model.

Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 18th Feb 2009 22:23
Ok thanks Latch, thats interesting. I've had a play around with Robert's Lighning limb dll but not sure how it will go in terms of remembering the same keyframe heirarchy. Do you know of a 3D modelling package that might be sophisticated enough to enable the cut thing to work. Money is just about no object at this stage, so if you know of a good modelling program that costs a bit, thats ok. Basically, I need to finish the project quickly (within a month).
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 19th Feb 2009 03:28
A month? Why the deadline? Are you being commissioned to create this game? Or is the wife saying "I've had it! You've got one more month to play with your toys!"

What's the format of your models? Is it direct X or 3ds? So many animation modeling programs will import 3ds, I don't know how many will import direct x with animation.

Quote: "Do you know of a 3D modelling package that might be sophisticated enough to enable the cut thing to work"

Caligari truespace would probably more than suffice. But on looking at the specs, I don't see any import of Direct X. But there are many other import formats including 3ds. Is Dark Matter in 3ds? And I remember that it will do hierarchical animation. Check the specs in detail and even contact customer support. I'm pretty sure Caligari truespace would probably meet all of your animation needs.

This can also be done with Blender. The thing is Blender is not intuitive. I've done it in Blender, the model was direct X but the animation came from somewhere else - but I also created a custom script for the export... so maybe I spoke too soon on cutting the model as an option. It is still possible, but like I said, it'll take some work.

Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 19th Feb 2009 05:01 Edited at: 19th Feb 2009 05:02
Its the latter. From now on, for every night I spend writing the game, the rolling pin looms closer

Should have listened to my grandfather's advice about marriage: "why buy a book when you can join a library".

I've played around with TS & Blender but not for doing this sort of thing so ok I'll check them out.

Cheers!
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 19th Feb 2009 12:00
Blast, the mesh keyframe idea doesnt work after all. The problem is the gun the soldier is carrying for some reason isnt held in his hands anymore but instead some distance ahead of him (e.g. if the soldier is 6 ft tall, then he runs as though he's carrying the gun but the gun is not only bigger than it should be, it floats 30 ft in front of the soldier.

I had a tinker with TS7.6 and tried loading the .x animated file but although there was no "load error", nothing appeared on screen. So I tried the .tga version of the animated file (it actually came in several different formats) but same thing upon loading. It did occur to me that maybe the object was tiny but using the mousewheel to zoom in didnt reveal anything. Any ideas what to try next?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Feb 2009 01:15
Quote: "Blast, the mesh keyframe idea doesnt work after all. The problem is the gun the soldier is carrying for some reason isnt held in his hands anymore but instead some distance ahead of him "

Hmmm... but the animation works? The keyframes are there? It's animating with limbs as opposed to bones? Sounds like your at the door of success... I'm not sure which animation package you used but if it deals with animation at all like blender, there are a set of keyframes for each bone. The keyframes store the location, scale, and rotation of a bone. These same transformations can be applied to a limb (a mesh that is linked in a hierachical structure). If possible, you have to build the limb structure the same as the bone structure. Another thing comes into play here... a transformation matrix that defines the initial position, scale and rotation of the bone. The giant size of your gun and the offset of it suggests a couple of possibilities. It's current transformation matrix doesn't match it's original, and or, it is already a limb and it is attached to the body mesh in an hierarchical order. That could mean the original model file contains two (or more) meshes - a body and the gun - and therefore uses two types of animation - skeletal and hierarchical.

That means you have to be sure of the original scale, position and rotation of the gun, and each bone. When you cut up the mesh into individual limbs, you have to make sure that you apply the original transformations to each limb BEFORE you link the hierachy together in parent child relationships. The bones CANNOT be linked to the newly created limbs. The limbs, in essence, are now the bones. Test one set of keyframes say, on the upper leg. See if it moves through the animation the same way as the original mesh does. If it does, apply another set of keyframes and etc.

Quote: "I had a tinker with TS7.6 and tried loading the .x animated file but although there was no "load error", nothing appeared on screen. So I tried the .tga version of the animated file (it actually came in several different formats) but same thing upon loading. It did occur to me that maybe the object was tiny but using the mousewheel to zoom in didnt reveal anything. Any ideas what to try next? "


Of course I have other ideas! Each one more ugly than the last!!

The "will most likely work" idea is to just recode your game with DBPro compatibility and use DBPro. There's probably not that many changes you'd have to make. But I have to admit even suggesting that makes me a bit sad because I love the idea of pushing DBC where ever it needs to go!

Can you actually load the animated model into Blender or Truespace at all (sounds like you can't quite do it in truespace)? What about a 3ds version or a wavefront obj version?

If you can't get the animation into either of the modeling programs but at least can get the model in there, you can still cut the model up into limbs and link it in a hieracrchy. What did you import the model into that made the gun giant?

Enjoy your day.
arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 20th Feb 2009 01:30
I would like to see what that game is like when compllete
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 20th Feb 2009 12:08
@Latch: Sorry I may have misled you before - I meant the saving mesh method from DBPro worked and the good news is the gun problem has now been solved - the problem was the gun wasnt rigged to the body so I contacted 3DRT and they sent me an animated body+gun model (a .x file) + now I can animate the model in DBC!

The bad news, and this is likely a show stopper, is that each saved mesh from the animation sequence is 0.5Meg in size! And having done a rough calc of how many I'd need as a minimum to animated the model, I've calculated 300! That means storing over 300 meshes or 150Meg.

Recoding the game in DBPro is an interesting idea, although there are over 25,000 lines of code. I know its difficult to say but which route would say is quicker: trying to recut the limbs and animate via blender/TS or recoding in DBpro?
Also I've heard that DBPro takes ages to run with increasing size of code. E.g. each time I want to test/debug the game (F5) I've been told it might take as much as 15 mins to run! Has this also been your experience?

@chewbacca: No prob will do, not too far to go (I hope).
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Feb 2009 13:29 Edited at: 20th Feb 2009 13:47
25000 lines is a lot... and I heard that it does take a while to compile DBPro. In my opinion, the best solution will be one that can be used in DBC again and again. A great solution would be to come up with a DLL that will deform the mesh based on the animation in the file. While it's possible to do the workarounds like the DBPro save mesh method or cutting the mesh up and making a hierarchy and reattaching the animation, the time and overhead used don't make them desirable to repeat.

I've been able to get away with using blender and cutting up a mesh into limbs that are linked in a hierarchy and just assigning the IPOs (the animation time line of key frames) from the bone to the matching limb. I have to admit though, that the animation came from motion capture (BVH) files or was made in Blender itself. I haven't been able to load animation into blender from an X file. I also wrote my own python script to export the limb animation to the directx format DBC likes (though finally after some people on these forums tested it I found all kinds of errors in the original script and it is currently being rewritten - but works... more or less). That's why I suggested truespace because it has at least the same level of sophistication as blender and it has directx 7 animation export built in (hierarchical).

Try this: call up 3DRT and see if they have your model in truspace's format. If so, you may be on your way...

And since there are so many frames, that makes me think the animation in your models is based on motion capture. If there isn't a truespace format, see if they have a BVH format - that's a motion capture format of animation that is fairly universal. If you download the free version of Deled 3d lite, you'll be able load your x model into it, and export it as a wavefront object (.obj format). I'm willing to bet that truespace will load that. The only problem is your animation will be lost. That is where the BVH file comes in from 3DRT.

If all goes according to plan, you will load the mesh (.obj) into truespace, load the BVH file into there. The BVH file should create a series of keyframes matched likely to a rigging without a mesh. Your job would be to divide the mesh into limbs that match the bone hierarchy and copy the keyframes to those limbs. This is not something people commonly do, in fact, I only know of myself who has done it (I'm sure there are others) so it might be hard to get help on the exact technique.
The questions to ask may be
"How do I copy a series of keyframes to the clipboard?"
"How do I copy animation from one model to another - for a single limb/bone etc?"
"How do I change the pivot point of a limb?"
"How do I link a limb in a parent child relationship?"
"How do I divide a mesh into smaller meshes or individual limbs?"
"Is it possible to track the animation of one object to another?" - by this I mean, let's say you are able to load the BVH file - if it even exists from 3DRT - it's likely that it will load as a rigging without a mesh. If you had divided your mesh into limbs, it may be possible to track the movement of the bones as the animation plays and record these as new keyframes for the limbs.

Anyway, I'd be curious to know if you were able to pull off any of this!

I may start some coding on a DLL that'll allow the animation to be loaded and the mesh deformed in DBC, but I'll probably have to read up on some direct x stuff... It could be a useful tool but I'm totally unmotivated to do it. I'll let you know if I actually do start something.

Just thought of one other thing. Check out:
3dcanvas

Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 22nd Feb 2009 22:22
Thanks Latch, always very generous with your assistance, and very much appreciated by moi.

3DRT hand-create their models and unfortunately do not have a BVH file. Truespace can read in .x files (can also export as .x) but strangely not the one mesh I'm after. I've had a look at 3DCanvas and there are 1 or 2 interesting features that might allow a conversion to limb animation but havent heard back from them yet. However it does appear that animation is lost upon import from all files (except BVH). Still it might be possible to import all 300 meshes and somehow animate via this(?) Maybe there's even other software around that can do this - will check it out and report back here if successful.

I think there may even be another solution. The meshes are fairly high poly so it might be possible for me to reduce the poly count of each of them. I see 3DCanvas allows this but I suspect there are some free 3D modellers out there that can do this also.

ps: I contacted Vice @ 3DSW for advice on the DBC-Pro conversion and although it does sound like a bit of work might be involved, it might just be viable, but for now its probably a last resort.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Feb 2009 01:37
If you open your model in notepad or some other editor, there should be a section that begins with the title AnimationSet and the entry might look something like:



Could you paste a section of the animation from your model? I'd like to take a look at it. Particularly if there is an AnimationKey that reads something like:



Ideally if I could have an entirely animated x model that works (one with a skeleton) then I may be able to modify the blender directx import to read in the animation. But I need a good, working, direct x animation file with skeletal animation. Does that test monster that 3drt have posted run as an animation in direct x?

Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 23rd Feb 2009 02:25 Edited at: 23rd Feb 2009 02:26
Sure, thanks Latch. I've attached the monster model (which may be too big to attach here and hence have posted the link below also) but it is in .x format. And yes it does seem to have an AnimationKey chunk of code.

Animation Anim-Bip01_Pelvis {{ Bip01_Pelvis }
AnimationKey {4; 604 ....etc.

Link to monster model (its the 2nd model in the list)
http://www.3drt.com/downloads.htm

ps. it seems to have attached ok so no need to worry about the link

Attachments

Login to view attachments
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 24th Feb 2009 01:02
This is interesting - I've come across this fantastic looking animation modeller called Fragmotion. It looks so simple to use that even a dufus like me might be able to get some use out of it. For one, it can import .x animated files and play them plus there seems to be plenty options to modify it. Have you ever used it?

http://www.fragmosoft.com/fragMOTION/download/index.php
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Feb 2009 23:57
I tried out fragmotion. It looks pretty good. Though I don't see any method of limb animation. I could be wrong though. 1 thing, using fragmotion I was able to export the animation of the monster model as a BVH file and load it into blender. I was also able to import a 3d mesh as 3ds into blender. Now the trick would be to cut the mesh up into the correct limbs...

So, since it is possible to export the animation out of fragmotion as BVH, you could load that into truespace. The next step would be finding a model type that can be imported into truespace. There looks like there is an OBJ export option in fragmotion and I think truespace imports OBJ.

So in theory, the process might go like this:

1) import the model into fragmotion
2) export the animation to BVH (bio vision)
3) export the model as .OBJ (wave front)
4) open truespace
5) import the BVH file
6) import the OBJ model
7) cut up the import model into individual meshes corresponding to the bone lengths (the length between empty objects or the points where bones connect)
8) link the meshes in a hierarchy with the same structure as the bones
9) copy the animation keys from the corresponding bone (or empty object from the BVH import) to the limb
10) delete the bone structure
11) test the animation of the limbs
12) export as hierarchy animation. Some animators only use hierachies for Scene export. If a scene is animated with obejcts moving here and there (say like in a tornado) the animation is usually hierarchical - I don't know if that is the case with truespace but I think it has an actual hierarchical export

I noitced a thread you started on the truespace forum. Would
BonesToVertex.tsx
help solve the cutting up of the mesh ?

One thing I noticed about the monster model when I loaded it into fragmotion, it had a copy of all of the bones that did nothing. What I mean is, there were lots of extra bones that didn't connect to anything - I think they were originally place holders to help define the skeleton and were never cleaned up. Anyway, I deleted all of the extra bones and it reduced the size of the x file by 500kb and it reduced the ridiculous number of IPOs (the objects that hold animation information) when I imported the BVH to blender by more than half.

Enjoy your day.
Hangar18
18
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 12th Mar 2009 13:14 Edited at: 12th Mar 2009 13:16
Well I have an update of sorts. After much fiddling it appears the switching meshes animation method is a no-goer. Its too slow (20 FPS). It appears this is due to the operation of CHANGE MESH obj,0,mesh number rather than the poly count of the object as I tried this same operation using a very low poly count square (in fact it was just replacing 1 square with an identical one but it was just a test), and got the same result (20 FPS).

So I tried the process you detailed above but got stuck on 7. In fact I may have gotten stuck on 5 - could load the BVH file but nothing seemed to happen once I did. I know I wasnt expecting to see an object pop up but I was hoping the keyframes down the bottom of the screen might show up with some sort of structure that would indicate the BVH file had loaded successfully.

So I parked that fear for the time being and proceeded to try all sorts of options to cut up the mesh, from point edit to deformation but simply couldnt cut up the model. I can see where the bonestovertex.tsx thing is saved in the TS folder structure but have no idea how to import it (it wont allow me to load it in anyway shape or form) and I cant see an option within TS to utilise it. Anyway the long and short is I've given up with TS (a bit wimpy I know), and suspect its time to try the dreaded last resort - converting DBC into DBPro, which is a little bit of a worry given there is no guarantee of success.

Thanks for all your help Latch - will post a further update if I get any joy.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Mar 2009 16:09
I made a lot of assumptions about TS based on Blender functionality. That whole process isn't easy to do - and it takes tweaking.

The change mesh thing is too slow also, huh? 20 fps, that's strange... I don't remember it being that slow...

And if it's any help, this is the basics for Blender but you've said you've moved on - anyway here's the info if you care to review it.
With Blender, I actually used an older BVH import (from blender 2.41) because I found the newer ones didn't behave the way I wanted. Anyway, it loads the BVH file as what are called empties - objects without any vertices or faces but with transformations (rotations, scale, position). It also loads the animation as what are called IPO curves. To 'cut up' a model, I used Boolean operations. Basically, I created a cube and placed it so that the arm or leg, or head or whatever was inside of it. I then select the cube and the whole model so they are both highlighted, then I chose the Intersect option from the Boolean operation menu. That left me with a cut out of the limb I wanted and the whole model - still intact. I move the cutout to another editing surface and continue to slice up the rest of the model. Because the joints rotate, and you now have a flat sliced limb, adding a sphere or rounded half to the cut limb helps hide the seam as the rounded part is inside it's parent limb.

After the slice and dice, I assign the parent child relationships based on the empties that were loaded earlier. I also rename the limbs so that they are similar to the empty names and I can identify which IPO I will assign. Then I open up the IPO screen. I highlight a particular limb then go through the different IPOs until I find the one that belonged to the relative empty. I assign that IPO to the limb. I do this for all of the limbs. If everything has gone according to plan, when you run the animation (ALT+A) your limbed mesh should be moving around. If by some chance you actually try this and get that far, you'll need to use my Blender to DBC exporter. It isn't public domain as of yet as I have been making a lot of changes to it. Let me know if you try out this process we can then communicate in email as to getting the model out of Blender. You'll be the guinea pig.

But good luck if you embark on recoding for DBPro.

Enjoy your day.

Login to post a reply

Server time is: 2025-05-16 23:57:10
Your offset time is: 2025-05-16 23:57:10