Makeshift HUD models

Moderator: Graf Zahl

jaquboss
Posts: 12
Joined: Thu Feb 02, 2006 15:43

Post by jaquboss »

Torr Samaho wrote:The current bobbing is just the first implementation I could come up with. I'm open for suggestions on how to improve it. Since I don't know how the Quake 3 bobbing is achieved (and don't have the time to investigate this), I need specific suggestion on how the weapon should bob (best in terms of translations and rotations).
It's done using camera movement variables, well here is code, please keep in mind Q3 SDK licenses :)

Code: Select all

static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {
	float	scale;
	int		delta;
	float	fracsin;

	VectorCopy( cg.refdef_current->vieworg, origin );
	VectorCopy( cg.refdefViewAngles, angles );

	
	// on odd legs, invert some angles
	if ( cg.bobcycle & 1 ) {
		scale = -cg.xyspeed;
	} else {
		scale = cg.xyspeed;
	}

	// gun angles from bobbing

	angles[ROLL]	+= scale		* cg.bobfracsin * 0.005;
	angles[YAW]	+= scale		* cg.bobfracsin * 0.01;
	angles[PITCH]	+= cg.xyspeed	* cg.bobfracsin * 0.005;

	// drop the weapon when landing
	delta = cg.time - cg.landTime;
	if ( delta < LAND_DEFLECT_TIME ) {
		origin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME;
	} else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) {
		origin[2] += cg.landChange*0.25 * 
			(LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME;
	}

	fracsin = sin( cg.time * 0.001 );
	angles[ROLL] += scale * fracsin * 0.01;
	angles[YAW] += scale * fracsin * 0.01;
	angles[PITCH] += scale * fracsin * 0.01;

	// RF, subtract the kickAngles
	VectorMA( angles, -1.0, cg.kickAngles, angles );
}
angles vector gets translated to axis and is used to attach weapon tag 'sketon' to viewport, that skeleton just contains all the tags which are origins and angles of weapon models, that's how the animation is done for earlier Q3 engine games, but that's diffirent story...
bobcycle is updated every client frame

Code: Select all

	if( cg.bobfracsin > 0 && !ps->bobCycle ) {
		cg.lastvalidBobcycle = cg.bobcycle;
		cg.lastvalidBobfracsin = cg.bobfracsin;
	}

	cg.bobcycle = ( ps->bobCycle & 128 ) >> 7;
	cg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) );
	cg.xyspeed = sqrt( ps->velocity[0] * ps->velocity[0] + ps->velocity[1] * ps->velocity[1] );
User avatar
Snarboo
Posts: 469
Joined: Thu Jul 07, 2005 2:35
Location: space station base of the UAC

Post by Snarboo »

I know HUD model support is preliminary, but I think it would be nice if HUD models had the option of multiple view bobbing styles. I can think of three different ways the models could bob off the top of my head:

None: The HUD model doesn't bob at all and is stationary.

Doom-style: Similar to the current implementation but more refined.

Modern-style: There is view bob when the player moves and the weapon model lags behind when the player looks around, similar to Doom 3.

There could also be a slider for how much the models should bob, too.
User avatar
Torr Samaho
Developer
Developer
Posts: 160
Joined: Fri Apr 13, 2007 8:26
Location: Germany
Contact:

Post by Torr Samaho »

I revamped the HUD model weapon bob to closely resemble the original Doom weapon bob. In particular bobbing now should be independent of the size of the model, i.e. no more bobbing of some models over the whole screen.

Should be in GZDoom revision 106.
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Post by Nash »

Yes it does look much better now. Good job!
Locked

Return to “Closed Feature Suggestions”