CSQC skeletal animations played by anim name

Discuss CSQC related programming.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: CSQC skeletal animations played by anim name

Post by toneddu2000 »

Thanks for the hints Spike but, unfortunately, it doesn't work
I used for DP same code I posted yesterday in addition with yours. For FTE, I used csqc_test I found on the FTEQW src folder.
I couldn't understand the different behaviour DP/FTE you told me about the renderflags var. I searched it and I found a preprocessor "#ifndef WORKINDP" but, honestly I don't know how to set it up.
I tried:

Code: Select all

self.frame1time = time-self.frame1time;
on both DP and FTE the player plays the animation at an abnormous fast pace and then stops 

Code: Select all

self.frame1time += frametime;
on DP model stands still, on FTE model disappears! :shock: 
All the above code has been put in the predraw function

I put

Code: Select all

 self.frame1time = time; or self.frame1time = 0;
before spawn(); in the model spawn function but I've seen no change.

I'm completely frustrated and with 0 free time available so I've to shelve this test for a bit. I'm a little disappointed because I wanted to join these tests with the ragdoll one, to create a map where toying a bit with skeletal animation and physics, but I tought that, if playing in loop a simple animation is so difficult, creating skeletal movements that react with physics is nearly impossible for my skills!
In the next weeks I'll try to search some other code on the net who someone finally succeded on this task. Nahuel made a test once but youtube video and source link are broken now.
Thanks again for your precious help
Meadow Fun!! - my first commercial game, made with FTEQW game engine
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: CSQC skeletal animations played by anim name

Post by toneddu2000 »

Now is becoming ridiculous.. I've been trying (in the past 2 weeks) to create a documentation about using IQM model file to animate csqc animations and animation code driven.
For the animation part, I'm quite ok for a basic trivial example, but the skeleton and the code driven part makes literally driving me crazy!
I create first a BRAND NEW SKELETON from erebus model (recreate from scratch, no bones from original one) with this simple structure.
Then I wrote this simple function

Code: Select all

void Player_SkeletonDisplayNumBones()
{
	local float numbones,i;
	numbones = skel_get_numbones(self.skeletonindex);
	for (i = 1;i< numbones;i++){
		print(ftos(i) ," - ", skel_get_bonename(self.skeletonindex,i)," \n");
	}
}
to list all the bones with relative number just to understand how DP (or IQM, I don't know) structures model. Well, prepare to be shocked!

Code: Select all

1 - root 
2 - pelvis 
3 - spine 
4 - legthigh_l 
5 - legthigh_r 
6 - torso 
7 - legankle_l 
8 - legankle_r 
9 - armupper_l 
10 - head 
11 - armupper_r 
12 - legfoot_l 
13 - legfoot_r 
14 - armlower_l 
15 - armlower_r 
16 - armhand_l 
WTF?! How, HOOW is that possible? How torso could be listed AFTER thigh left and right? And feets after arms upper?!
That's how I assembled this VERY simple skeleton (go figure if it was more detailed!)

Code: Select all

Root
--pelvis
----spine and all their descendants (torso, arms, and head)
----legthigh_l & legthigh_r and all their descendants
In Blender I connected first spine to pelvis and then legs to pelvis but DP listed first legs than torso (which is connected to spine)
The only "documentation" is this wonderful example made by ChristianIce and modified by Nahuel (not for the animation part anyway) which uses DPM model format and its code works with bending the spine bone with input angles (the neck and torso bend when looking up and down)
Here's the code

Code: Select all

//bend skeleton spine by mouse input
  body_ang = skel_get_bonerel (self.skeletonindex, 	skel_find_bone(self.skeletonindex,"pelvis"));
	ang = '0 0 0';
	ang_y = self.bodyangle_y * 0.25;
	ang_z = -input_angles_x * 0.5; // let's divide it.
	self.angles_y = input_angles_y;
	makevectors(ang);
	//bend skeleton
	local string s;
	s = skel_get_bonename(self.skeletonindex,23);
	skel_set_bone(self.skeletonindex,skel_find_bone(self.skeletonindex,"belly"), '0.0 0.0 0.0');//moves the torso	
	skel_set_bone(self.skeletonindex, skel_find_bone(self.skeletonindex,"throat"), '0.0 0.0 0.0');//moves the neck	
Bones in ChristianIce's DPM model are listed correctly

Code: Select all

1 - pelvis 
2 - belly 
3 - torso 
4 - neck 
5 - throat 
6 - head 
7 - shoulders 
8 - jfur 
9 - jflr 
10 - jful 
11 - jfll 
12 - jback 
13 - jbll 
14 - jbrl 
15 - uparm-r 
16 - rotarm-r 
17 - loarm-r 
18 - hand-r 
19 - gun 
20 - uparm-l 
21 - rotarm-l 
22 - loarm-l 
23 - hand-l 
24 - upleg-r 
25 - loleg-r 
26 - foot-r 
27 - toe-r 
28 - upleg-l 
29 - loleg-l 
30 - foot-l
 
On my iqm model the code doesn't work (I tried both skel_set_bone and skel_mul_bone) so I really can't understand if it's a model issue or what else.
Meadow Fun!! - my first commercial game, made with FTEQW game engine
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: CSQC skeletal animations played by anim name

Post by frag.machine »

I know almost nothing about CSQC, IQM or anything directly related to skeletal animation, so bear with my ignorance please. But why does this matter ? Aren't you referering to the bones names in your code anyway ? Or are you assuming in a non obvious way that pelvis has index 1, torso has index 2 and so on ?

EDIT: speel check :P
EDIT2: GAHHH! again, I'm terrible today :oops:
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: CSQC skeletal animations played by anim name

Post by Spike »

the problem is basically that skel_build takes a bone range. first+stop. if the bones in the lower half of the body are not contiguous, you end up needing to call it multiple times. which is annoying and a bit inefficent.
sadly there's no way to say 'torso and all decendants', nor 'all decendants of root unless its a decendant of torso', which are the two groups that are most desirable. The API is based purely upon bone numbers and has no concept of groups. Which is a problem when your editor/exporter randomly generates bone ordering. :s
It would be good to be able to set up some bone groups feature, but I expect someone would still complain about the design of it anyway (it sucks when they're legitimate complaints). I might do it and roll a few tweaks into some new extension some time, either way I doubt DP would adopt it any time soon anyway, and as you seem to be using that engine, no rush!
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: CSQC skeletal animations played by anim name

Post by toneddu2000 »

frag.machine wrote:Aren't you referering to the bones names in your code anyway ? Or are you assuming in a non obvious way that pelvis has index 1, torso has index 2 and so on ?
That's the problem... I don't know! :D I mean, of course there's some model format issue, because same code with DPM works, so I presumed (there's nothing assured by me about programming matter, I'm still very ignorant about it) it's something related to IQM randomly bone numbers generation
Spike wrote:It would be good to be able to set up some bone groups feature, but I expect someone would still complain about the design of it anyway (it sucks when they're legitimate complaints). I might do it and roll a few tweaks into some new extension some time, either way I doubt DP would adopt it any time soon anyway, and as you seem to be using that engine, no rush!
Well, Spike, I've to admit that for structuring all my "work enviroment" with DP I spent like 3 years with trying, re-trying, no documentation found, finding some clues on the net and so on. Last week I fired up FTE and I encountered all the problems I found 3 years ago with DP
- can't understand how to setup a standalone game and standalone data folder (and don't use Quake original files most of all!)
- can't understand how to setup NetRadiant with .fte folder (to be honest, that's a no problem, I could manage it)
- can't understand why my NetRadiant maps won't open on FTE instead sock's maps do (even after re-exported with my NetRadiant)
- don't have a list of all command line commands (I made mine for DP)
- don't know how to setup "high end" features like fonts, glsl shaders, skeletal model files (THAT'S THE MOST IMPORTANT ONES - qc code for skeletal animation that worked in DP made the model disappear in FTE!)
- don't know how to edit real time lights in editor and how to load them from maps (I don't use lightmaps, only real time lights)
- don't know how to check if ode is running and which ode libraries it needs on Win/Linux
and a lot of other stuff I don't remember right now...
If there's a great documentation about all these things to know about FTE I'll switch right now... seriously! :D Even because you're the one who's really helping me in these threads. I found a SERIOUS bug (I posted here some week ago) in DP where real time shadows of animated skeletal model (DPM and IQM) are projected as the model were in T-pose but I never saw here a LordHavoc reply (I even asked him a while ago about something else csqc DP related but no replies...), so...

...plus FTE has ragdolls! :D I could swicth to it in no time!
Pleas let me know if there's a manual and I'll create a document about skeletal animations even for FTE
Meadow Fun!! - my first commercial game, made with FTEQW game engine
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: CSQC skeletal animations played by anim name

Post by toneddu2000 »

SERVICE NOTE: thanks a lot for the PM, I replied to you but I think it's still in the outbox

Ok, 1, well 2 news:

First is that I exported from Blender to SMD using the AWESOME Blender Source Tools for Blender 2.6x created by some guys at Valve and then to DPM using DPModel and now look at the skeleton bone order

Code: Select all

1 - blender_implicit 
2 - root 
3 - pelvis 
4 - legthigh_l 
5 - legankle_l 
6 - legfoot_l 
7 - legthigh_r 
8 - legankle_r 
9 - legfoot_r 
10 - spine 
11 - torso 
12 - armupper_l 
13 - armlower_l 
14 - armhand_l 
15 - armupper_r 
16 - armlower_r 
17 - armhand_r 
Except for number 1 (blender_implicit, huh?), now we'll start doing serious things! Infact now selecting spine, you implicit select torso, head and shoulders (not the shampoo)

Second news is that Good Lee Salzman updated IQM and imagine what he added to last version? A new field in the exporter named "Bone order option"!! It seems he heard my prayers! :lol:
I'm too tired to test it but I'll post in the next weeks some update
Meadow Fun!! - my first commercial game, made with FTEQW game engine
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: CSQC skeletal animations played by anim name

Post by toneddu2000 »

On my pc, Linux or Windows no matter, IQM bone order feature didn't work. It couldn't load my bones file. After a talk with Lee (thanks a lot Lee!) I managed a workaround. For those interested in preserve bone order in IQM models, open iqm_export.py and go to line 1038 and replace:

Code: Select all

if boneorder:
        try:
            f = open(bpy_extras.io_utils.path_reference(boneorder, os.path.dirname(bpy.data.filepath), os.path.dirname(filename)), "r", encoding = "utf-8")
            names = [line.strip() for line in f.readlines()]
            f.close()
            names = [name for name in names if name in [bone.name for bone in bones.values()]]
            if len(names) != len(bones):
                print('Bone order (%d) does not match skeleton (%d)' % (len(names), len(bones)))
                return 
            print('Reordering bones')
            for bone in bones.values():
                bone.index = names.index(bone.name)
        except:
            print('Failed opening bone order: %s' % boneorder)
            return
with

Code: Select all

if boneorder:
        try:
            names = boneorder.split(",")
            if len(names) != len(bones):
                print('Bone order (%d) does not match skeleton (%d), write them in sequence, followed by comma, except last item' % (len(names), len(bones)))
                return 
            print('Reordering bones')
            for bone in bones.values():
                bone.index = names.index(bone.name)
        except:
            print('Failed parsing bone order sequence: %s' % boneorder)
            return
Now, for a skeleton with this kind of hierarchy

Code: Select all

--root
----spine1
------spine2
--------spine3
select both mesh and skeleton (both in OBJECT MODE), go to file -> export -> Inter-Quake model, check both Meshes and Skeleton and in the Bone order field add:

Code: Select all

root,spine1,spine2,spine3
, choose model extension (iqm or iqe) and press export.
That's it, your model will be exported with original bone order instead of the scrambled one
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Post Reply