예제 #1
0
void G_LoadCachedRoffs()
{
	int		i, count = 0, len = 0;
	char	buffer[MAX_QPATH];

	ojk::SavedGameHelper saved_game(
		::gi.saved_game);

	// Get the count of goodies we need to revive
	saved_game.read_chunk<int32_t>(
		INT_ID('R', 'O', 'F', 'F'),
		count);

	// Now bring 'em back to life
	for ( i = 0; i < count; i++ )
	{
		saved_game.read_chunk<int32_t>(
			INT_ID('S', 'L', 'E', 'N'),
			len);

		if (len < 0 || static_cast<size_t>(len) >= sizeof(buffer))
		{
			len = 0;
		}

		saved_game.read_chunk(
			INT_ID('R', 'S', 'T', 'R'),
			buffer,
			len);

		G_LoadRoff( buffer );
	}
}
예제 #2
0
void CGCam_Roff( void )
{
	if ( cg.time < client_camera.next_roff_time )
	{
		// Nothing else to do for now...
		return; 
	}

	int roff_id;

	// Make sure that the roff is cached
	roff_id = G_LoadRoff( client_camera.sRoff );

	if ( !roff_id )
	{
		return;
	}

	roff_list_t		*roff	= &roffs[ roff_id - 1 ];
	move_rotate_t	*data	= &roff->data[ client_camera.roff_frame ];

#ifdef _DEBUG
	Com_Printf( S_COLOR_GREEN"ROFF dat: o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", 
					data->origin_delta[0], data->origin_delta[1], data->origin_delta[2],
					data->rotate_delta[0], data->rotate_delta[1], data->rotate_delta[2] );
#endif

	if ( client_camera.roff_frame )
	{
		// Don't mess with angles if we are following
		if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
		{
			VectorCopy( client_camera.angles2, client_camera.angles );
		}

		VectorCopy( client_camera.origin2, client_camera.origin );
	}

	// Don't mess with angles if we are following
	if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
	{
		VectorCopy( data->rotate_delta, client_camera.angles2 );
		client_camera.pan_time = cg.time;
		client_camera.pan_duration = 100;
	}

	VectorAdd( client_camera.origin, data->origin_delta, client_camera.origin2 );

	client_camera.move_time = cg.time;
	client_camera.move_duration = 100;

	if ( ++client_camera.roff_frame >= roff->frames )
	{
		CGCam_StopRoff();	
		return;
	}

	// Check back in 100 ms to get the next roff entry
	client_camera.next_roff_time = cg.time + 100;  
}
예제 #3
0
파일: g_roff.cpp 프로젝트: DingoOz/OpenJK
void G_LoadCachedRoffs()
{
	int		i, count, len;
	char	buffer[MAX_QPATH];

	// Get the count of goodies we need to revive
	gi.ReadFromSaveGame( 'ROFF', (void *)&count, sizeof(count), NULL );

	// Now bring 'em back to life
	for ( i = 0; i < count; i++ )
	{
		gi.ReadFromSaveGame( 'SLEN', (void *)&len, sizeof(len), NULL );
		gi.ReadFromSaveGame( 'RSTR', (void *)(buffer), len, NULL );
		G_LoadRoff( buffer );
	}
}
예제 #4
0
파일: cg_camera.cpp 프로젝트: Aura15/OpenJK
void CGCam_StartRoff( char *roff )
{
	CGCam_FollowDisable();
	CGCam_TrackDisable();

	// Set up the roff state info..we'll hijack the moving and panning code until told otherwise 
	//	...CAMERA_FOLLOWING would be a case that could override this..
	client_camera.info_state |= CAMERA_MOVING;
	client_camera.info_state |= CAMERA_PANNING;

	if ( !G_LoadRoff( roff ) )
	{
		// The load failed so don't turn on the roff playback...
		Com_Printf( S_COLOR_RED"ROFF camera playback failed\n" );
		return;
	};

	client_camera.info_state |= CAMERA_ROFFING;

	Q_strncpyz(client_camera.sRoff,roff,sizeof(client_camera.sRoff));
	client_camera.roff_frame = 0;
	client_camera.next_roff_time = cg.time;	// I can work right away
}
예제 #5
0
파일: g_roff.cpp 프로젝트: DingoOz/OpenJK
void G_Roff( gentity_t *ent )
{
	if ( !ent->next_roff_time )
	{
		return;
	}
	
	if ( ent->next_roff_time > level.time )
	{// either I don't think or it's just not time to have me think yet
		return;
	}

	const int roff_id = G_LoadRoff( ent->roff );

	if ( !roff_id )
	{	// Couldn't cache this rof
		return;
	}

	// The ID is one higher than the array index
	const roff_list_t *  roff	= &roffs[ roff_id - 1 ];
	vec3_t	org, ang;

	if ( roff->type == 2 )
	{
		move_rotate2_t	*data	= &((move_rotate2_t *)roff->data)[ ent->roff_ctr ];
		VectorCopy( data->origin_delta, org );
		VectorCopy( data->rotate_delta, ang );
		if (data->mStartNote != -1 || data->mNumNotes)
		{
			G_RoffNotetrackCallback(ent, roffs[roff_id - 1].mNoteTrackIndexes[data->mStartNote]);
		}
	}
	else
	{
		move_rotate_t	*data	= &((move_rotate_t *)roff->data)[ ent->roff_ctr ];
		VectorCopy( data->origin_delta, org );
		VectorCopy( data->rotate_delta, ang );
	}

#ifdef _DEBUG
	if ( g_developer->integer )
	{
		Com_Printf( S_COLOR_GREEN"ROFF dat: num: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", 
					ent->roff_ctr,
					org[0], org[1], org[2],
					ang[0], ang[1], ang[2] );
	}
#endif

	if ( ent->client )
	{
		// Set up the angle interpolation
		//-------------------------------------
		VectorAdd( ent->s.apos.trBase, ang, ent->s.apos.trBase );
		ent->s.apos.trTime = level.time;
		ent->s.apos.trType = TR_INTERPOLATE;

		// Store what the next apos->trBase should be
		VectorCopy( ent->s.apos.trBase, ent->client->ps.viewangles );
		VectorCopy( ent->s.apos.trBase, ent->currentAngles );
		VectorCopy( ent->s.apos.trBase, ent->s.angles );
		if ( ent->NPC )
		{
			//ent->NPC->desiredPitch = ent->s.apos.trBase[PITCH];
			ent->NPC->desiredYaw = ent->s.apos.trBase[YAW];
		}

		// Set up the origin interpolation
		//-------------------------------------
		VectorAdd( ent->s.pos.trBase, org, ent->s.pos.trBase );
		ent->s.pos.trTime = level.time;
		ent->s.pos.trType = TR_INTERPOLATE;

		// Store what the next pos->trBase should be
		VectorCopy( ent->s.pos.trBase, ent->client->ps.origin );
		VectorCopy( ent->s.pos.trBase, ent->currentOrigin );
		//VectorCopy( ent->s.pos.trBase, ent->s.origin );
	}
	else
	{
		// Set up the angle interpolation
		//-------------------------------------
		VectorScale( ang, roff->mLerp, ent->s.apos.trDelta );
		VectorCopy( ent->pos2, ent->s.apos.trBase );
		ent->s.apos.trTime = level.time;
		ent->s.apos.trType = TR_LINEAR;

		// Store what the next apos->trBase should be
		VectorAdd( ent->pos2, ang, ent->pos2 );

		// Set up the origin interpolation
		//-------------------------------------
		VectorScale( org, roff->mLerp, ent->s.pos.trDelta );
		VectorCopy( ent->pos1, ent->s.pos.trBase );
		ent->s.pos.trTime = level.time;
		ent->s.pos.trType = TR_LINEAR;

		// Store what the next apos->trBase should be
		VectorAdd( ent->pos1, org, ent->pos1 );

		//make it true linear... FIXME: sticks around after ROFF is done, but do we really care?
		ent->alt_fire = qtrue;

		if ( ent->e_ThinkFunc == thinkF_TieFighterThink || ent->e_ThinkFunc == thinkF_TieBomberThink ||
			( !ent->e_ThinkFunc
			&& ent->s.eType != ET_MISSILE
			&& ent->s.eType != ET_ITEM
			&& ent->s.eType != ET_MOVER ) )
		{//will never set currentAngles & currentOrigin itself ( why do we limit which one's get set?, just set all the time? )
			EvaluateTrajectory( &ent->s.apos, level.time, ent->currentAngles );
			EvaluateTrajectory( &ent->s.pos, level.time, ent->currentOrigin );
		}
	}

	// Link just in case.
	gi.linkentity( ent );

	// See if the ROFF playback is done
	//-------------------------------------
	if ( ++ent->roff_ctr >= roff->frames )
	{
		// We are done, so let me think no more, then tell the task that we're done.
		ent->next_roff_time = 0;

		// Stop any rotation or movement.
		VectorClear( ent->s.pos.trDelta );
		VectorClear( ent->s.apos.trDelta );

		Q3_TaskIDComplete( ent, TID_MOVE_NAV );

		return;
	}

	ent->next_roff_time = level.time + roff->mFrameTime;
}
예제 #6
0
파일: cg_camera.cpp 프로젝트: Aura15/OpenJK
static void CGCam_Roff( void )
{
 while ( client_camera.next_roff_time <= cg.time )
 {
	// Make sure that the roff is cached
	const int roff_id = G_LoadRoff( client_camera.sRoff );

	if ( !roff_id )
	{
		return;
	}

	// The ID is one higher than the array index
	const roff_list_t	*roff	= &roffs[ roff_id - 1 ];
	vec3_t org, ang;

	if ( roff->type == 2 )
	{
		move_rotate2_t	*data	= &((move_rotate2_t *)roff->data)[ client_camera.roff_frame ];
		VectorCopy( data->origin_delta, org );
		VectorCopy( data->rotate_delta, ang );

		// since we just hit a new frame, clear our CUT flag
		client_camera.info_state &= ~CAMERA_CUT;

		if (data->mStartNote != -1 || data->mNumNotes)
		{
			CG_RoffNotetrackCallback(roffs[roff_id - 1].mNoteTrackIndexes[data->mStartNote]);
		}
	}
	else
	{
		move_rotate_t	*data	= &((move_rotate_t *)roff->data)[ client_camera.roff_frame ];
		VectorCopy( data->origin_delta, org );
		VectorCopy( data->rotate_delta, ang );
	}

	// Yeah, um, I guess this just has to be negated?
	//ang[PITCH]	=- ang[PITCH];
	ang[ROLL]	= -ang[ROLL];
	// might need to to yaw as well.  need a test...

	if ( cg_developer.integer )
	{
		Com_Printf( S_COLOR_GREEN"CamROFF: frame: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", 
					client_camera.roff_frame,
					org[0], org[1], org[2],
					ang[0], ang[1], ang[2] );
	}

	if ( client_camera.roff_frame )
	{
		// Don't mess with angles if we are following
		if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
		{
			VectorAdd( client_camera.angles, client_camera.angles2, client_camera.angles );
		}

		VectorCopy( client_camera.origin2, client_camera.origin );
	}

	// Don't mess with angles if we are following
	if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
	{
		VectorCopy( ang, client_camera.angles2 );
		client_camera.pan_time = cg.time;
		client_camera.pan_duration = roff->mFrameTime;
	}

	VectorAdd( client_camera.origin, org, client_camera.origin2 );

	client_camera.move_time = cg.time;
	client_camera.move_duration = roff->mFrameTime;

	if ( ++client_camera.roff_frame >= roff->frames )
	{
		CGCam_StopRoff();	
		return;
	}

	// Check back in frameTime to get the next roff entry
	client_camera.next_roff_time += roff->mFrameTime;
 }
}
예제 #7
0
static void CGCam_Roff( void )
{
 while ( client_camera.next_roff_time <= cg.time )
 {

	int roff_id;

	// Make sure that the roff is cached
	roff_id = G_LoadRoff( client_camera.sRoff );

	if ( !roff_id )
	{
		return;
	}

	roff_list_t		*roff	= &roffs[ roff_id - 1 ];

	vec3_t org, ang;

	if ( roff->type == 2 )
	{
		move_rotate2_t	*data	= &((move_rotate2_t *)roff->data)[ client_camera.roff_frame ];
		VectorCopy( data->origin_delta, org );
		VectorCopy( data->rotate_delta, ang );
	}
	else
	{
		move_rotate_t	*data	= &((move_rotate_t *)roff->data)[ client_camera.roff_frame ];
		VectorCopy( data->origin_delta, org );
		VectorCopy( data->rotate_delta, ang );
	}

	// Yeah, um, I guess this just has to be negated?
	ang[PITCH] =- ang[PITCH];
	ang[ROLL]  =- ang[ROLL];
	// might need to to yaw as well.  need a test...

#ifdef _DEBUG
	if ( cg_developer.integer )
	{
		Com_Printf( S_COLOR_GREEN"CamROFF : o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", 
					org[0], org[1], org[2],
					ang[0], ang[1], ang[2] );
	}
#endif

	if ( client_camera.roff_frame )
	{
		// Don't mess with angles if we are following
		if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
		{
			VectorAdd( client_camera.angles, client_camera.angles2, client_camera.angles );
		}

		VectorCopy( client_camera.origin2, client_camera.origin );
	}

	// Don't mess with angles if we are following
	if ( !(client_camera.info_state & CAMERA_FOLLOWING) )
	{
		VectorCopy( ang, client_camera.angles2 );
		client_camera.pan_time = cg.time;
		client_camera.pan_duration = roff->mFrameTime;
	}

	VectorAdd( client_camera.origin, org, client_camera.origin2 );

	client_camera.move_time = cg.time;
	client_camera.move_duration = roff->mFrameTime;

	if ( ++client_camera.roff_frame >= roff->frames )
	{
		CGCam_StopRoff();	
		return;
	}

	// Check back in frameTime to get the next roff entry
	client_camera.next_roff_time += roff->mFrameTime;
 }
}