StepByStep: Spoike Notes: CSQC iqm animation

DEFINITIONS:

pose: a single static position of a model or iqm

frame: a set of poses

 

NOTE: mdl’s are set up differently.

Each pose has its own .frame. To run a mdl animation, you change frames. eg

rockrun1 is a frame consisting of one pose

rockrun2 is a frame consisting of one pose

rockrun3 is a frame consisting of one pose

etc

you run the animation by ‘changing frames’

 

 

IQMS are set up like this:

pose  – each static image

frame: a set of images which are one animation

you run the animation by ‘playing the frame’, the poses all auto-play

 

 

 

 

 

 

 

======

from here

 

md2+md3 do not natively support framegroups, while mdl+iqm do.
csqc is quite explicit when it comes to animation, so there’s about 5 fields that need to be updated each frame.
.frame+.frame2 define the two framegroups/animations to lerp between, eg when the animation changes.
.lerpfrac says how much of .frame2 to use (and thus how little of .frame to use). 0 uses excusively .frame, 1 uses exlusively .frame2, other values linearly interpolate.
.frame1time+.frame2time define the time into the two animations.

So, to switch from one animation to a new one, you copy .frame to .frame2 (and .frame1time to .frame2time), set .frame to the new animation (and .frame1time to 0), set .lerpfrac to 1, and then slowly decrement it over time (depending on how smooth you want the animation switch to be, probably lerpfrac=max(0,lerpfrac-frametime*10);
additionally, you need to increment both .frame1time and .frame2time by frametime. You can scale it or whatever if desired.

note that if you want to restart an animation, you will likely want to do it with lerpfrac (and .frame1==.frame2) instead of trivially resetting .frameNtime to 0, as this avoids sudden snaps.

when it comes to viewmodels, they’re not really any different from any other entity. Just make sure MASK_VIEWMODELS isn’t used, spawn a private entity with renderflags|=RF_VIEWMODEL|RF_DEPTHHACK, setmodelindex it to getstatf(STAT_WEAPONMODEL), and update its frame to getstat(STAT_WEAPONFRAME) as appropriate.
use some bit in the frame stat to signify animation restarts, and have the csqc restart the animation when its toggled by the ssqc or so.

So yeah, quite a bit of code that really needs some proper example code to fully understand. I don’t really have easy-to-read code to link though, so I’m sorry about that.

======

setatt<OneManClan> YES it animates it
<Spoike> automatically?
<OneManClan> yes
<Spoike> then you fucked up.
<OneManClan> i exported it with Loop = 1
<Spoike> exactly. you put everything into a single animation
<Spoike> .frame selects the animation
<Spoike> .frame1time selects the time offset within that animation
<Spoike> .frame2 selects the alternative animation
<Spoike> .frame2time selects the time offset within that alternative animation
<Spoike> .lerpfrac says how much of that alternative animation to use.
<Spoike> those are csqc’s 5 animation controls.
<OneManClan> i see
<OneManClan> my current (minimalist) code is: http://pastebin.com/QXW5NTQB

<Spoike> the modelviewer feature resets frame1time when you change the .frame
<Spoike> but otherwise increases it by frametime
<Spoike> if your csqc isn’t updating the .frame1time field then you don’t get framegroup animation
<OneManClan> so why is the ‘halo’ animating?
<Spoike> hrmpk
<Spoike> because players.
<OneManClan> theres some other ‘way of dealing w iqms’ if its a player?
<Spoike> entities in general
=====
ntities in general
<OneManClan> this is one of those situations where it feels like theres some manual i havent read that everyone else has
<Spoike> though I’d be somewhat surprised
<OneManClan> so should i have exported (blender-> iqm) with loop ‘off’?
<Spoike> nah

<Spoike> I should give you a framegroups file to build new frame’groups’ from your single animation
<Spoike> but too lazy to figure out the format
<OneManClan> i already made one

<Spoike> to explain: there’s two ways to do animation.
<Spoike> 1: manually select the exact new frame 10 times every second
<Spoike> 2: select the current action instead, and set the time, and allow the animation to loop etc normally without you caring how many frames there are etc
<Spoike> and blend between different actions based upon your own weights

<Spoike> note that with the second one, you can easily change the speed of the animation based upon distance travelled etc
<OneManClan> ok i need to rtfm re: ‘weights’
<Spoike> I recently added 8-way animation blending with skeletal formats
<Spoike> so .frame3 and .frame4 and their .frame3time and .lerpfrac3 values should all be usable
<Spoike> regarding weights, think of a set of scales.
<Spoike> as one gets heavy, the other moves in the other direction
<Spoike> the actual weights of either doesn’t really matter (so long as they don’t break the scales)
<Spoike> but rather the balance between them
<Spoike> that’s what ‘weights’ are in animation
<OneManClan> is this what were talking about: https://www.youtube.com/watch?v=DWVzqorScTM
<Spoike> sort of
<Spoike> those are vertex weights
<Spoike> how much of each bone each vertex uses
<OneManClan> http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Meshes/Vertex_Groups/Weight_Paint
<OneManClan> ^^>?
<Spoike> what was I talking about again? :s
<OneManClan> ‘weights’
<OneManClan> im tryign to figure out what I should be rtfming
<OneManClan> ok IIUC weights “specify what vertices will move when a bone moves”
<OneManClan> as described here: http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Advanced_Animation/Guided_tour/Mesh/vg#Weight_Paint
<Spoike> vertex weights are controlled purely in the model. you don’t have any control over them as a programmer.
<OneManClan> ah so these are not the ‘weights’ we’re looking for?
<Spoike> yeah
<Spoike> you always go off googling something and end up with something else.
<OneManClan> ‘blender weights’
<Spoike> well what do you expect.
<Spoike> I’m not talking about blender.
<OneManClan> i expect: “weights are <definition of weights> ”

<Spoike> weights are things you put on scales.
<Spoike> as one gets more significant, the other one is less significant.
<OneManClan> i get the metaphor, just not sure ‘what to do next’
<Spoike> which is what lerpfrac is all about
<Spoike> lerpfrac says how much of frame2 to use
<OneManClan> ok i tried to do this: self.lerpfrac -= frametime*10;
<OneManClan> while (self.lerpfrac < 0)
<OneManClan> {
<OneManClan> self.frame2 = self.frame;
<OneManClan> self.lerpfrac += 1;
<OneManClan> self.frame += 1;
<OneManClan> }
<Spoike> which of course won’t work
<OneManClan> didnt make a difference/ looks the same
<Spoike> because your model only has a single frame.
<OneManClan> how do you mean ‘frame’?
<OneManClan> there are 25 animation ‘frames’
<OneManClan> or is this a wrong use of the term ‘frame’?
<Spoike> to avoid ambiguity, I’m going to introduce you to two terms: poses and animations.
<Spoike> .frame selects the animation.
<Spoike> a framegroup is an animation with multiple animations.
<OneManClan> ah, ok
<Spoike> err
<Spoike> a framegroup is an animation with multiple poses.
<OneManClan> mulriple sequence of poses
<Spoike> a frame is an animation with a single pose.
<OneManClan> yea
<Spoike> your model has a single animation.
<OneManClan> yes
<Spoike> while you want multiple all with a single pose in order to match your player.mdl file
<Spoike> so that you don’t have to pull all the animations apart and redo them just yet
<OneManClan> “<Spoike> while you want multiple all” ?
<Spoike> while you want multiple, all with …
<OneManClan> ah, so i should do the ‘access the individual poses’, and explicitly get the SCQC to ‘play them’?
<Spoike> no
<OneManClan> ie method 1 (as you described above)
<Spoike> your SSQC is already doing method 1.
<OneManClan> yes
<Spoike> and changing that would break ezquake.
<Spoike> so its not really an option
<Spoike> so you’d need to either ‘decompose’ those frames into animations in your csqc
<OneManClan> is the csqc still reading the .frame (a ‘renderable field’), even though we changed to iqm?
<Spoike> or just use the exact same frame numbers in your iqm
<Spoike> yeah
<OneManClan> I made a file called ‘iqm_base4.iqm.framegroups’
<OneManClan> which just has the line: 1 25 30.000000 1
<Spoike> see, there’s one problem.
<Spoike> put all frames in a single animation
<Spoike> all poses, sorry.
<Spoike> bah
<OneManClan> 🙂
<OneManClan> at least the jargon is becoming clearer, thanks
<OneManClan> framegroups: animation sequence with multiple poses
<OneManClan> frame: a single pose
<OneManClan> (which might be part of a framegroup)
<Spoike> the .frame field selects which framegroup/frame to use. which is why the terminology gets messy.
<OneManClan> yea
<Spoike> it doesn’t help that I use framegroup and frame almost interchangably…
<OneManClan> i tried: self.frame = 1; // thinkin this would override ssqc animation info passed to the iqm
<OneManClan> but it ditnt work
<Spoike> it should do
<OneManClan> maybe there’s other ‘renderable fields’ which are interfering
<OneManClan> holdon, gonna re-read everythign you’ve said today
<OneManClan> a few times ! 🙂
<Spoike> the foo.ext.framegroups format:
<Spoike> firstpose posecount framerate loop
<Spoike> and optionally name
<Spoike> so to mimic your player.mdl you want the first column to increase by 1 for each line, the second to be 1. the third to be pretty much anything you want, and the last to be set to ‘whogivesafuck’
<Spoike> starting at 0, I believe
<OneManClan> by ‘mimic’ the player mdl, do you mean ‘mimic by having the same number of poses for each framegroup’?
<Spoike> by mimic, I mean getting your single-animation file to be animatable by ssqc selecting specific poses instead of entire animations.
<OneManClan> eg 6 running poses
<Spoike> because when there is only one animation, there’s no way to change it.
<OneManClan> So, IIUC, the 2 animation methods are:
<OneManClan> 1. get access to the complete individual poses, and control their running via qc
<OneManClan> ^^ like the traditional player.mdl
<OneManClan> 2. use framegroups, and play the animations automatically
<Spoike> the problem you have is basically that you will likely want more frames than 10 fps
<OneManClan> and the problem with ‘2’ (iiuc) is that each iqm has to play ALL the poses within it
<OneManClan> (ie unless you incorporate elements of method 1)
<Spoike> just make your iqms properly…
<Spoike> blender will give you the option to make entire animations
<Spoike> making an entire animation for a 120 single poses is a bit stupid
<Spoike> err
<Spoike> making 120 different animations each containing a single pose is a bit stupid
<Spoike> and certainly sounds excessive
<Spoike> but that’s how your qc currently animates the player
<Spoike> so its the easiest way
<Spoike> but you don’t get any perks like higher framerates or whatever
<OneManClan> ah
<OneManClan> hence the significance of the lerp stuff
<Spoike> ideally you’d identify run+stand+etc animations and generate your own frames
<Spoike> but its easier to just use a framegroups file to make blender usable as well as letting your qc animate via poses
<Spoike> but yeah, you’re stuck at 10fps

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>