Jump to content
Sign in to follow this  
bek

model.cfg reloadMagazine (Pistol)

Recommended Posts

Yesterday I finally sat down and tried to import a weapon into A3 (I'm still fairly new at VBS). Today I've got the majority of it working fine, however I'm stuck on one part — getting the magazine removal/inserting working correctly. On A3's pistols the animation is smooth and precise; which I am unable to replicate (and the variables in use confuse me).

 

More generally: I'm importing this model (image, webGL view) into arma. This (gfycat) is where I am at currently. Note that the magazine extracts partially, but no new magazine appears to be inserted. This is the relevant code from the model.cfg:

			class magazine_reload_move_1
			{
				type = "translation";
				source = "reloadMagazine";
				selection = "magazine";
				axis = "magazine_axis";
				minValue = 0.01;
				maxValue = 0.1;//0.1 works
				offset0 = 0.0;
				offset1 = 0.55;//0.5 works
			};
			class magazine_reload_move_2: magazine_reload_move_1
			{
				minValue = 0.57;
				maxValue = 0.62;
				offset0 = 0.0;
				offset1 = -0.5;
			};

(which was appropriated from the arma 3 weapon sample).

 

So the first section (move_1) is causing difficulties. The minValue, maxValue and offset1 lines are hard to understand. Currently I've been playing with their values one by one to try and get to where I am now. Ideally the animation would extract the magazine further before it despawns, but if I increase the offset1 value, (which does that), when the magazine is inserted at the end of the anim, it "jumps" downwards out of the gun / through your hand. I've yet to get the magazine to appear when inserting either; which I assume has to do with the move_2 section.

 

So.. how do you get the correct values for this? How do minValue, maxValue and offset work together to change the location of the magazine during the anim? Am I meant to keep "guessing" until it looks right? Or is there some tool to do this? (Or would it relate to the magazine's height or something?) Any insight would be appreciated. If I can config this properly I might release it as a sample asset for the community (one of the frustrations I've had with vbs so far is the lack of documentation, samples and quality tutorials). It's also a shame that there's no "safe" mode in arma by default as I would've liked to have had the safety work, but oh well.

Share this post


Link to post
Share on other sites

You missed the third component of the reload animation in the sample model.cfg:

			class magazine_hide
			{
				type="hide";
				source="reloadMagazine";
				selection="magazine";
				minValue=0.000000;
				maxValue=1.00000;
				hideValue=0.188;
				unhideValue = 0.550;
			};

unhideValue is the point in the reloadMagazine cycle where the magazine reappears
 
The offset values are dependant on how long the memory point axis is in your .p3d. If you have offset1 = 1, the bone will move the full length of the axis, if it's offset1 = 0.5, it'll move half the length of the axis.
offset0 is an initial offset when the animation phase is 0, but for the most part you're likely to have modelled the bone in the position you want it in, so offset0 = 0 is usually fine.
 
minValue/maxValue basically tells the animation when to start and end during the animation source length. The time period of the reloadMagazine source is defined in the config.cpp by the magazineReloadTime = parameter (yes, it probably should be called reloadMagazineTime instead; for the sake of consistency. But this is Arma!).

 

If magazineReloadTime = 2; the source controler will take 2 seconds to go from value 0  to value 1. That means setting your model.cfg animation with a minValue = 0.25 and maxValue = 0.75 will make the animation start 0.5 seconds after the reloadMagazine action is started and end a the 1.5 seconds mark (0.25 * 2 = 0.5, 0.75 * 2 = 1.5). Therefore your model.cfg animation will have a period of 1 second within the whole 2 second magazineReload cycle (1.5 - 0.5 = 1, or (0.75 - 0.25) * 2 = 1).
 
The speed at which your magazine is translating along the axis is as on might expect; a matter of distance/time. As you discovered, to make the magazine move further you want to increase the offset value, and to slow the movement down you need to increase the maxValue so that it covers that longer distance over a longer time interval. But you will also want to increase the hideValue in your animation to hide/unhide the magazine, so that the magazine doesn't disappear too early now that the magazine is moving for a longer period.
 
Oh and it's possible to create a fake safety mode. You just have to add an extra muzzle to your weapon (like you would add an underslung grenade launcher) and make that safety muzzle use no magazines. The safety catch can then be animated with the weaponMuzzle animation source.

  • Like 1

Share this post


Link to post
Share on other sites

Aha — I did have that section but not the unhidevalue line for some reason. Thanks da12thMoneky once again! Now to play with the numbers until it looks right.

Share this post


Link to post
Share on other sites

So I've tried adding the safety (which works), but for some reason I cannot get its axis correct. I've imported two vertices that lie flat on the Z axis; the space between them is what I want to be the center point of the safety swtich's rotation. However it just isn't behaving like that. I've also tried a single vertex with RotationZ which also does not work — the direction is correct, but the rotation isn't based off the axis's center point, so the safety switch move entirely rather than rotating around a point. It's almost like it's taking the whole model as an axis/center point. I've triple checked the spelling of the axis in o2 and the model.cfg, I've tried assigning it to different axis (which "worked" as in the change occured), I've tried exporting the axis with different lengths just in case that mattered... what am I missing?

	class safety_rotation
	{
		type="rotationZ";
		source="weaponMuzzle";
		sourceAddress = "clamp";
		selection="safety";
		axis="safety_axis";
		memory=1;
		minValue=0.000000;
		maxValue=1.000000;
		angle0=0.0;//"rad 0"
		angle1=-0.03;//"rad -10"
	};

Here's the full model.cfg which is probably super dodge; I'm not clear on why some stuff should be in class weapon: default and other stuff in class weapon:pistol section;  but I couldn't get things working the exact way the sample_f weapon is set up. Actually, when messing with the values for comparable axis (hammer, trigger) I've observed similar behaviour — the selection rotating way away from the model, which shouldn't even happen with the given axis as a center point. Am I mistaken in thinking an axis and center point are one and the same?

Share this post


Link to post
Share on other sites

Do you have autocenter = 0 in your model's named properties?

 

It's required in the geometry LOD on models that have animations. Otherwise the game offsets the memory LOD points

 

Open your geometry LOD and press [Ctrl+1] to toggle the named properties window (this just helps identify it in Object Builder if you don't know which one it is). Right click the window and click 'New' then type in autocenter in the name field and 0 in the value field.

  • Like 1

Share this post


Link to post
Share on other sites

Once again you've nailed it; autocenter = 0 was not on my geometry LOD (but it was on view pilot somehow). Anyway that fixed it, I've since simplified the model.cfg tonnes and got the safety working, and it's all pretty sweet. Thanks for the help.

 

At this point I'm not sure if I want to push this further — I've some small things I could do but there's probably not much point. I'd be curious what others think though; if they'd consider it cool / or if its commonly done.

 

My first thought is I should be able to fairly easily display/hide the loaded and unloaded magazine during the reload_magazine_move(s) — you start with the loaded mag hidden and the empty mag visible/unhidden -> do reload_magazine_begin (hide empty), start reload_magazine_move_2, and then switch the visible hidden mags so you're back at the start. But that's a fair bit of effort for a quick animation that's fairly dodgy anyway.

 

Another thought I have is that I could work around arma's limitation of no per-pixel colour specular (since spec is crammed into the G channel of your _SMDI map) which is necessary for the bullets, which are an orange metal, by making them a separate element with a (simplified) RVMAT with an orange tint in its specular[]={1.2,1.2,1.2,1}; line, obviously using the same textures. But then again I'd be adding a material (probably not ideal for performance) and slightly complicating the model.cfg as I'd have to use two classes when translocating the loaded magazine, as it seems you can't create a selection (bone?) within o2 that contains other selections. I already do this for the slide, as when the slide retracts the safety must also move. It's not a huge deal to do so again but I'm not sure it's worth the effort. Anyway, enough nonsense.

Share this post


Link to post
Share on other sites

 

as it seems you can't create a selection (bone?) within o2 that contains other selections. I already do this for the slide, as when the slide retracts the safety must also move. It's not a huge deal to do so again but I'm not sure it's worth the effort. Anyway, enough nonsense.

 

You can. The correct way to get a bone that moves multiple selections is to set the one bone as a child of the other bone in cfgSkeletons at the top of the model.cfg

class cfgSkeletons
{
	class Default
	{
		isDiscrete = 1;
		skeletonInherit = "";
		skeletonBones[] = {};
	};

	class MyWeapon_skeleton : default
	{
		SkeletonBones[]=
		{
			"magazine","",
			"trigger","",
			"slide","",
			"safety","slide"
		};
	};
};

Bones in the skeleton are defined in "child","parent" pairs. If a bone is defined without a parent e.g. "magazine","" above then that bone only moves as part of the entire geometry, but if there is a bone in between the second set of quotation marks in the pair it acts as a parent to the bone in the first set of quotes. Therefore the child bone will follow the parent bone in whatever animations move the parent bone.

 

More in-depth tut I wrote about complex, multi-bone animations:

http://www.rkslstudios.info/public-forum/33/180

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×