mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-04 18:09:53 +03:00
1
This commit is contained in:
527
utils/demoinfo/demoinfo.cpp
Normal file
527
utils/demoinfo/demoinfo.cpp
Normal file
@@ -0,0 +1,527 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: A simple application demonstrating the HL2 demo file format ( subject to change!!! )
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
#include <windows.h>
|
||||
#include "tier0/dbg.h"
|
||||
#include "filesystem.h"
|
||||
#include "FileSystem_Tools.h"
|
||||
#include "cmdlib.h"
|
||||
#include "tooldemofile.h"
|
||||
|
||||
static bool uselogfile = false;
|
||||
static bool spewed = false;
|
||||
|
||||
#define LOGFILE_NAME "log.txt"
|
||||
|
||||
#define COM_COPY_CHUNK_SIZE 8192
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Prints to stdout and to the developer console and optionally to a log file
|
||||
// Input : depth -
|
||||
// *fmt -
|
||||
// ... -
|
||||
//-----------------------------------------------------------------------------
|
||||
void vprint( int depth, const char *fmt, ... )
|
||||
{
|
||||
char string[ 8192 ];
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
vsprintf( string, fmt, va );
|
||||
va_end( va );
|
||||
|
||||
FILE *fp = NULL;
|
||||
|
||||
if ( uselogfile )
|
||||
{
|
||||
fp = fopen( LOGFILE_NAME, "ab" );
|
||||
}
|
||||
|
||||
while ( depth-- > 0 )
|
||||
{
|
||||
printf( " " );
|
||||
OutputDebugString( " " );
|
||||
if ( fp )
|
||||
{
|
||||
fprintf( fp, " " );
|
||||
}
|
||||
}
|
||||
|
||||
::printf( "%s", string );
|
||||
OutputDebugString( string );
|
||||
|
||||
if ( fp )
|
||||
{
|
||||
char *p = string;
|
||||
while ( *p )
|
||||
{
|
||||
if ( *p == '\n' )
|
||||
{
|
||||
fputc( '\r', fp );
|
||||
}
|
||||
fputc( *p, fp );
|
||||
p++;
|
||||
}
|
||||
fclose( fp );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Warning/Msg call back through this API
|
||||
// Input : type -
|
||||
// *pMsg -
|
||||
// Output : SpewRetval_t
|
||||
//-----------------------------------------------------------------------------
|
||||
SpewRetval_t SpewFunc( SpewType_t type, char const *pMsg )
|
||||
{
|
||||
spewed = true;
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
|
||||
default:
|
||||
case SPEW_MESSAGE:
|
||||
case SPEW_ASSERT:
|
||||
case SPEW_LOG:
|
||||
vprint( 0, "%s", pMsg );
|
||||
break;
|
||||
case SPEW_WARNING:
|
||||
|
||||
if ( verbose )
|
||||
{
|
||||
vprint( 0, "%s", pMsg );
|
||||
}
|
||||
break;
|
||||
case SPEW_ERROR:
|
||||
vprint( 0, "%s\n", pMsg );
|
||||
break;
|
||||
}
|
||||
|
||||
return SPEW_CONTINUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Shows usage information
|
||||
//-----------------------------------------------------------------------------
|
||||
void printusage( void )
|
||||
{
|
||||
vprint( 0, "usage: demoinfo <.dem file>\n\
|
||||
\t-v = verbose output\n\
|
||||
\t-l = log to file log.txt\n\
|
||||
\ne.g.: demoinfo -v u:/hl2/hl2/foo.dem\n" );
|
||||
|
||||
// Exit app
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Removes previous log file
|
||||
//-----------------------------------------------------------------------------
|
||||
void CheckLogFile( void )
|
||||
{
|
||||
if ( uselogfile )
|
||||
{
|
||||
_unlink( LOGFILE_NAME );
|
||||
vprint( 0, " Outputting to log.txt\n" );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Prints banner
|
||||
//-----------------------------------------------------------------------------
|
||||
void PrintHeader()
|
||||
{
|
||||
vprint( 0, "Valve Software - demoinfo.exe (%s)\n", __DATE__ );
|
||||
vprint( 0, "--- Demo File Info Sample ---\n" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Parses all "smoothing" info from .dem file
|
||||
// Input : &demoFile -
|
||||
// smooth -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ParseSmoothingInfo( CToolDemoFile &demoFile, CUtlVector< demosmoothing_t >& smooth )
|
||||
{
|
||||
democmdinfo_t info;
|
||||
int dummy;
|
||||
|
||||
bool demofinished = false;
|
||||
while ( !demofinished )
|
||||
{
|
||||
int tick = 0;
|
||||
byte cmd;
|
||||
|
||||
bool swallowmessages = true;
|
||||
do
|
||||
{
|
||||
demoFile.ReadCmdHeader( cmd, tick );
|
||||
|
||||
// COMMAND HANDLERS
|
||||
switch ( cmd )
|
||||
{
|
||||
case dem_synctick:
|
||||
break;
|
||||
case dem_stop:
|
||||
{
|
||||
swallowmessages = false;
|
||||
demofinished = true;
|
||||
}
|
||||
break;
|
||||
case dem_consolecmd:
|
||||
{
|
||||
demoFile.ReadConsoleCommand();
|
||||
}
|
||||
break;
|
||||
case dem_datatables:
|
||||
{
|
||||
demoFile.ReadNetworkDataTables( NULL );
|
||||
}
|
||||
break;
|
||||
case dem_usercmd:
|
||||
{
|
||||
demoFile.ReadUserCmd( NULL, dummy );
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
swallowmessages = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
while ( swallowmessages );
|
||||
|
||||
if ( demofinished )
|
||||
{
|
||||
// StopPlayback();
|
||||
return;
|
||||
}
|
||||
|
||||
int curpos = demoFile.GetCurPos();
|
||||
|
||||
demoFile.ReadCmdInfo( info );
|
||||
demoFile.ReadSequenceInfo( dummy, dummy );
|
||||
demoFile.ReadRawData( NULL, 0 );
|
||||
|
||||
demosmoothing_t smoothing_entry;
|
||||
|
||||
smoothing_entry.file_offset = curpos;
|
||||
smoothing_entry.frametick = tick;
|
||||
smoothing_entry.info = info;
|
||||
smoothing_entry.samplepoint = false;
|
||||
smoothing_entry.vecmoved = info.GetViewOrigin();
|
||||
smoothing_entry.angmoved = info.GetViewAngles();
|
||||
smoothing_entry.targetpoint = false;
|
||||
smoothing_entry.vectarget = info.GetViewOrigin();
|
||||
|
||||
// Add to end of list
|
||||
|
||||
smooth.AddToTail( smoothing_entry );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Resets all smoothing data back to original values
|
||||
// Input : smoothing -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ClearSmoothingInfo( CSmoothingContext& smoothing )
|
||||
{
|
||||
int c = smoothing.smooth.Count();
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
demosmoothing_t *p = &smoothing.smooth[ i ];
|
||||
p->info.Reset();
|
||||
p->vecmoved = p->info.GetViewOrigin();
|
||||
p->angmoved = p->info.GetViewAngles();
|
||||
p->samplepoint = false;
|
||||
p->vectarget = p->info.GetViewOrigin();
|
||||
p->targetpoint = false;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Helper for copying sub-chunk of file
|
||||
// Input : dst -
|
||||
// src -
|
||||
// nSize -
|
||||
//-----------------------------------------------------------------------------
|
||||
void COM_CopyFileChunk( FileHandle_t dst, FileHandle_t src, int nSize )
|
||||
{
|
||||
int copysize = nSize;
|
||||
char copybuf[COM_COPY_CHUNK_SIZE];
|
||||
|
||||
while (copysize > COM_COPY_CHUNK_SIZE)
|
||||
{
|
||||
g_pFileSystem->Read ( copybuf, COM_COPY_CHUNK_SIZE, src );
|
||||
g_pFileSystem->Write( copybuf, COM_COPY_CHUNK_SIZE, dst );
|
||||
copysize -= COM_COPY_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
g_pFileSystem->Read ( copybuf, copysize, src );
|
||||
g_pFileSystem->Write( copybuf, copysize, dst );
|
||||
|
||||
g_pFileSystem->Flush ( src );
|
||||
g_pFileSystem->Flush ( dst );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Writes out a new .dem file based on the existing dem file with new camera positions saved into the dem file
|
||||
// Note: The new file is named filename_smooth.dem
|
||||
// Input : *filename -
|
||||
// smoothing -
|
||||
//-----------------------------------------------------------------------------
|
||||
void SaveSmoothingInfo( char const *filename, CSmoothingContext& smoothing )
|
||||
{
|
||||
// Nothing to do
|
||||
int c = smoothing.smooth.Count();
|
||||
if ( !c )
|
||||
return;
|
||||
|
||||
IBaseFileSystem *fs = g_pFileSystem;
|
||||
|
||||
FileHandle_t infile, outfile;
|
||||
|
||||
infile = fs->Open( filename, "rb", "GAME" );
|
||||
if ( infile == FILESYSTEM_INVALID_HANDLE )
|
||||
return;
|
||||
|
||||
int filesize = fs->Size( infile );
|
||||
|
||||
char outfilename[ 512 ];
|
||||
Q_StripExtension( filename, outfilename, sizeof( outfilename ) );
|
||||
Q_strncat( outfilename, "_smooth", sizeof(outfilename), COPY_ALL_CHARACTERS );
|
||||
Q_DefaultExtension( outfilename, ".dem", sizeof( outfilename ) );
|
||||
outfile = fs->Open( outfilename, "wb", "GAME" );
|
||||
if ( outfile == FILESYSTEM_INVALID_HANDLE )
|
||||
{
|
||||
fs->Close( infile );
|
||||
return;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
// The basic algorithm is to seek to each sample and "overwrite" it during copy with the new data...
|
||||
int lastwritepos = 0;
|
||||
for ( i = 0; i < c; i++ )
|
||||
{
|
||||
demosmoothing_t *p = &smoothing.smooth[ i ];
|
||||
|
||||
int copyamount = p->file_offset - lastwritepos;
|
||||
|
||||
COM_CopyFileChunk( outfile, infile, copyamount );
|
||||
|
||||
fs->Seek( infile, p->file_offset, FILESYSTEM_SEEK_HEAD );
|
||||
|
||||
// wacky hacky overwriting
|
||||
fs->Write( &p->info, sizeof( democmdinfo_t ), outfile );
|
||||
|
||||
lastwritepos = fs->Tell( outfile );
|
||||
fs->Seek( infile, p->file_offset + sizeof( democmdinfo_t ), FILESYSTEM_SEEK_HEAD );
|
||||
}
|
||||
|
||||
// Copy the final bit of data, if any...
|
||||
int final = filesize - lastwritepos;
|
||||
|
||||
COM_CopyFileChunk( outfile, infile, final );
|
||||
|
||||
fs->Close( outfile );
|
||||
fs->Close( infile );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Helper for spewing verbose sample information
|
||||
// Input : flags -
|
||||
// Output : char const
|
||||
//-----------------------------------------------------------------------------
|
||||
char const *DescribeFlags( int flags )
|
||||
{
|
||||
static char outbuf[ 256 ];
|
||||
|
||||
outbuf[ 0 ] = 0;
|
||||
|
||||
if ( flags & FDEMO_USE_ORIGIN2 )
|
||||
{
|
||||
Q_strncat( outbuf, "USE_ORIGIN2, ", sizeof( outbuf ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
if ( flags & FDEMO_USE_ANGLES2 )
|
||||
{
|
||||
Q_strncat( outbuf, "USE_ANGLES2, ", sizeof( outbuf ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
if ( flags & FDEMO_NOINTERP )
|
||||
{
|
||||
Q_strncat( outbuf, "NOINTERP, ", sizeof( outbuf ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
|
||||
int len = Q_strlen( outbuf );
|
||||
if ( len > 2 )
|
||||
{
|
||||
outbuf[ len - 2 ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_strncpy( outbuf, "N/A", sizeof( outbuf ) );
|
||||
}
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads up all camera samples from a .dem file into the passed in context.
|
||||
// Input : *filename -
|
||||
// smoothing -
|
||||
//-----------------------------------------------------------------------------
|
||||
void LoadSmoothingInfo( const char *filename, CSmoothingContext& smoothing )
|
||||
{
|
||||
char name[ MAX_OSPATH ];
|
||||
Q_strncpy (name, filename, sizeof(name) );
|
||||
Q_DefaultExtension( name, ".dem", sizeof( name ) );
|
||||
|
||||
CToolDemoFile demoFile;
|
||||
|
||||
if ( !demoFile.Open( filename, true ) )
|
||||
{
|
||||
Warning( "ERROR: couldn't open %s.\n", name );
|
||||
return;
|
||||
}
|
||||
|
||||
demoheader_t * header = demoFile.ReadDemoHeader();
|
||||
|
||||
if ( !header )
|
||||
{
|
||||
demoFile.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
Msg( "\n\n" );
|
||||
Msg( "--------------------------------------------------------------\n" );
|
||||
Msg( "demofilestamp: '%s'\n", header->demofilestamp );
|
||||
Msg( "demoprotocol: %i\n", header->demoprotocol );
|
||||
Msg( "networkprotocol: %i\n", header->networkprotocol );
|
||||
Msg( "servername: '%s'\n", header->servername );
|
||||
Msg( "clientname: '%s'\n", header->clientname );
|
||||
Msg( "mapname: '%s'\n", header->mapname );
|
||||
Msg( "gamedirectory: '%s'\n", header->gamedirectory );
|
||||
Msg( "playback_time: %f seconds\n", header->playback_time );
|
||||
Msg( "playback_ticks: %i ticks\n", header->playback_ticks );
|
||||
Msg( "playback_frames: %i frames\n", header->playback_frames );
|
||||
Msg( "signonlength: %s\n", Q_pretifymem( header->signonlength ) );
|
||||
|
||||
smoothing.active = true;
|
||||
Q_strncpy( smoothing.filename, name, sizeof(smoothing.filename) );
|
||||
|
||||
smoothing.smooth.RemoveAll();
|
||||
|
||||
ClearSmoothingInfo( smoothing );
|
||||
|
||||
ParseSmoothingInfo( demoFile, smoothing.smooth );
|
||||
|
||||
Msg( "--------------------------------------------------------------\n" );
|
||||
Msg( "smoothing data: %i samples\n", smoothing.smooth.Count() );
|
||||
|
||||
if ( verbose )
|
||||
{
|
||||
int c = smoothing.smooth.Count();
|
||||
for ( int i = 0; i < c; ++i )
|
||||
{
|
||||
demosmoothing_t& sample = smoothing.smooth[ i ];
|
||||
|
||||
Msg( "Sample %i:\n", i );
|
||||
Msg( " file pos: %i\n", sample.file_offset );
|
||||
Msg( " tick: %i\n", sample.frametick );
|
||||
Msg( " flags: %s\n", DescribeFlags( sample.info.flags ) );
|
||||
|
||||
Msg( " Original Data:\n" );
|
||||
Msg( " origin: %.4f %.4f %.4f\n", sample.info.viewOrigin.x, sample.info.viewOrigin.y, sample.info.viewOrigin.z );
|
||||
Msg( " viewangles: %.4f %.4f %.4f\n", sample.info.viewAngles.x, sample.info.viewAngles.y, sample.info.viewAngles.z );
|
||||
Msg( " localviewangles: %.4f %.4f %.4f\n", sample.info.localViewAngles.x, sample.info.localViewAngles.y, sample.info.localViewAngles.z );
|
||||
|
||||
Msg( " Resampled Data:\n" );
|
||||
Msg( " origin: %.4f %.4f %.4f\n", sample.info.viewOrigin2.x, sample.info.viewOrigin2.y, sample.info.viewOrigin2.z );
|
||||
Msg( " viewangles: %.4f %.4f %.4f\n", sample.info.viewAngles2.x, sample.info.viewAngles2.y, sample.info.viewAngles2.z );
|
||||
Msg( " localviewangles: %.4f %.4f %.4f\n", sample.info.localViewAngles2.x, sample.info.localViewAngles2.y, sample.info.localViewAngles2.z );
|
||||
|
||||
Msg( "\n" );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
demoFile.Close();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : argc -
|
||||
// argv[] -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
SpewOutputFunc( SpewFunc );
|
||||
SpewActivate( "demoinfo", 2 );
|
||||
|
||||
int i = 1;
|
||||
for ( i ; i<argc ; i++)
|
||||
{
|
||||
if ( argv[ i ][ 0 ] == '-' )
|
||||
{
|
||||
switch( argv[ i ][ 1 ] )
|
||||
{
|
||||
case 'l':
|
||||
uselogfile = true;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = true;
|
||||
break;
|
||||
case 'g':
|
||||
++i;
|
||||
break;
|
||||
default:
|
||||
printusage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( argc < 2 || ( i != argc ) )
|
||||
{
|
||||
PrintHeader();
|
||||
printusage();
|
||||
}
|
||||
|
||||
CheckLogFile();
|
||||
|
||||
PrintHeader();
|
||||
|
||||
vprint( 0, " Info for %s..\n", argv[ i - 1 ] );
|
||||
|
||||
char workingdir[ 256 ];
|
||||
workingdir[0] = 0;
|
||||
Q_getwd( workingdir, sizeof( workingdir ) );
|
||||
|
||||
if ( !FileSystem_Init( NULL, 0, FS_INIT_FULL ) )
|
||||
return 1;
|
||||
|
||||
// Add this so relative filenames work.
|
||||
g_pFullFileSystem->AddSearchPath( workingdir, "game", PATH_ADD_TO_HEAD );
|
||||
|
||||
// Load the demo
|
||||
CSmoothingContext context;
|
||||
|
||||
LoadSmoothingInfo( argv[ i - 1 ], context );
|
||||
|
||||
// Note to tool makers:
|
||||
// Do your work here!!!
|
||||
//Performsmoothing( context );
|
||||
|
||||
// Save out updated .dem file
|
||||
// UNCOMMENT THIS TO ENABLE OUTPUTTING NEW .DEM FILES!!!
|
||||
// SaveSmoothingInfo( argv[ i - 1 ], context );
|
||||
|
||||
FileSystem_Term();
|
||||
|
||||
return 0;
|
||||
}
|
||||
549
utils/demoinfo/demoinfo.vcproj
Normal file
549
utils/demoinfo/demoinfo.vcproj
Normal file
@@ -0,0 +1,549 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="demoinfo"
|
||||
ProjectGUID="{4FE3FDCA-9571-44B3-A521-C81448434490}">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\common,..\..\public,..\..\public\tier1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Release/demoinfo.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
CommandLine="if exist ..\..\..\game\bin\"$(TargetName)".exe attrib -r ..\..\..\game\bin\"$(TargetName)".exe
|
||||
copy "$(TargetPath)" ..\..\..\game\bin\"$(TargetName)".exe
|
||||
if exist ..\..\..\game\bin\"$(TargetName)".pdb attrib -r ..\..\..\game\bin\"$(TargetName)".pdb
|
||||
copy "$(TargetPath)" ..\..\..\game\bin\"$(TargetName)".pdb
|
||||
"
|
||||
Outputs="..\..\..\game\bin\demoinfo.exe;..\..\..\game\bin\demoinfo.pdb"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Release/demoinfo.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\..\lib\public"
|
||||
IgnoreDefaultLibraryNames="LIBCMT,LIBCMTD"
|
||||
ProgramDatabaseFile=".\Release/demoinfo.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/demoinfo.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\public,..\..\public\tier1,..\common"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Debug/demoinfo.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
CommandLine="if exist ..\..\..\game\bin\"$(TargetName)".exe attrib -r ..\..\..\game\bin\"$(TargetName)".exe
|
||||
copy "$(TargetPath)" ..\..\..\game\bin\"$(TargetName)".exe
|
||||
if exist ..\..\..\game\bin\"$(TargetName)".pdb attrib -r ..\..\..\game\bin\"$(TargetName)".pdb
|
||||
copy "$(TargetPath)" ..\..\..\game\bin\"$(TargetName)".pdb
|
||||
"
|
||||
Outputs="..\..\..\game\bin\demoinfo.exe;..\..\..\game\bin\demoinfo.pdb"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/FIXED:NO"
|
||||
OutputFile=".\Debug/demoinfo.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="..\..\lib\public"
|
||||
IgnoreAllDefaultLibraries="FALSE"
|
||||
IgnoreDefaultLibraryNames="LIBCMT,LIBCMTD"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/demoinfo.pdb"
|
||||
GenerateMapFile="TRUE"
|
||||
MapFileName=".\Debug/demoinfo.map"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/demoinfo.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="..\..\tier1\characterset.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\common\cmdlib.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\common\cmdlib.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="demoinfo.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\filesystem_helpers.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\filesystem_init.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\common\filesystem_tools.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tier1\interface.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tier1\KeyValues.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tooldemofile.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tier1\utlbuffer.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\tier1\utlsymbol.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="..\..\Public\tier0\basetypes.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\commonmacros.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier0\dbg.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\demofile\demoformat.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier0\fasttimer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\common\filesystem_tools.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\mathlib\MATHLIB.H">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier0\memdbgon.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier0\platform.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\protected_things.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\string_t.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\vstdlib\strtools.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\studio.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="tooldemofile.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier1\utldict.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier1\utlmemory.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier1\utlrbtree.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier1\utlsymbol.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\tier1\utlvector.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\mathlib\vector.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\mathlib\vector2d.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Public\mathlib\vector4d.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\public\vstdlib\vstdlib.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="DemoSmootherSampleSourceFiles"
|
||||
Filter="*.h;*.cpp">
|
||||
<File
|
||||
RelativePath="demosmoothersamplesource.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="demosmoothersamplesource.h">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="demosmoothersamplesource.txt">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="..\..\lib\public\tier0.lib">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lib\public\tier1.lib">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lib\public\tier1.lib">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lib\public\tier2.lib">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lib\public\tier2.lib">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lib\public\vstdlib.lib">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
2705
utils/demoinfo/demosmoothersamplesource.cpp
Normal file
2705
utils/demoinfo/demosmoothersamplesource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
233
utils/demoinfo/demosmoothersamplesource.h
Normal file
233
utils/demoinfo/demosmoothersamplesource.h
Normal file
@@ -0,0 +1,233 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Sample Source Code for "demo smoothing" tool in the engine. This could be ported into the client .dll
|
||||
// pretty easily -- ywb
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CL_DEMOSMOOTHERPANEL_H
|
||||
#define CL_DEMOSMOOTHERPANEL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/Frame.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Button;
|
||||
class Label;
|
||||
class ListPanel;
|
||||
class IScheme;
|
||||
};
|
||||
|
||||
#include "demofile/demoformat.h"
|
||||
#include "demofile.h"
|
||||
|
||||
struct demodirectory_t;
|
||||
class CSmoothingTypeButton;
|
||||
class CFixEdgeButton;
|
||||
|
||||
typedef float (*EASEFUNC)( float t );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDemoSmootherPanel : public vgui::Frame
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CDemoSmootherPanel, vgui::Frame );
|
||||
|
||||
public:
|
||||
CDemoSmootherPanel( vgui::Panel *parent );
|
||||
~CDemoSmootherPanel();
|
||||
|
||||
virtual void OnTick();
|
||||
|
||||
// Command issued
|
||||
virtual void OnCommand(const char *command);
|
||||
|
||||
void OnRefresh();
|
||||
|
||||
virtual bool OverrideView( democmdinfo_t& info, int tick );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
|
||||
virtual void DrawDebuggingInfo( int frame, float elapsed );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
bool CanEdit();
|
||||
|
||||
void Reset( void );
|
||||
|
||||
demosmoothing_t *GetCurrent( void );
|
||||
|
||||
void DrawSmoothingSample( bool original, bool processed, int samplenumber, demosmoothing_t *sample, demosmoothing_t *next );
|
||||
void DrawTargetSpline( void );
|
||||
void DrawKeySpline( void );
|
||||
int GetTickForFrame( int frame );
|
||||
int GetFrameForTick( int tick );
|
||||
bool GetInterpolatedViewPoint( Vector& origin, QAngle& angles );
|
||||
bool GetInterpolatedOriginAndAngles( bool readonly, Vector& origin, QAngle& angles );
|
||||
|
||||
void DrawLegend( int startframe, int endframe );
|
||||
|
||||
void OnRevert();
|
||||
void OnPreview( bool original );
|
||||
void OnSave();
|
||||
void OnReload();
|
||||
void OnSelect();
|
||||
void OnTogglePause();
|
||||
void OnStep( bool forward );
|
||||
void OnGotoFrame();
|
||||
|
||||
void OnToggleKeyFrame( void );
|
||||
void OnToggleLookTarget( void );
|
||||
|
||||
void OnNextKey();
|
||||
void OnPrevKey();
|
||||
void OnNextTarget();
|
||||
void OnPrevTarget();
|
||||
|
||||
void OnRevertPoint( void );
|
||||
|
||||
void PopulateMenuList();
|
||||
int GetStartFrame();
|
||||
int GetEndFrame();
|
||||
|
||||
void OnSaveKey();
|
||||
void OnSetView();
|
||||
|
||||
void OnSmoothEdges( bool left, bool right );
|
||||
|
||||
void PerformLinearInterpolatedAngleSmoothing( int startframe, int endframe );
|
||||
|
||||
void OnSmoothSelectionAngles( void );
|
||||
void OnSmoothSelectionOrigin( void );
|
||||
void OnLinearInterpolateAnglesBasedOnEndpoints( void );
|
||||
void OnLinearInterpolateOriginBasedOnEndpoints( void );
|
||||
void OnSplineSampleOrigin( void );
|
||||
void OnSplineSampleAngles( void );
|
||||
void OnLookAtPoints( bool spline );
|
||||
void OnSetKeys(float interval);
|
||||
|
||||
void OnOriginEaseCurve( EASEFUNC easefunc );
|
||||
|
||||
void SetLastFrame( bool jumptotarget, int frame );
|
||||
|
||||
void AddSamplePoints( bool usetarget, bool includeboundaries, CUtlVector< demosmoothing_t * >& points, int start, int end );
|
||||
demosmoothing_t *GetBoundedSample( CUtlVector< demosmoothing_t * >& points, int sample );
|
||||
void FindSpanningPoints( int tick, CUtlVector< demosmoothing_t * >& points, int& prev, int& next );
|
||||
|
||||
// Undo/Redo
|
||||
void Undo( void );
|
||||
void Redo( void );
|
||||
|
||||
// Do push before changes
|
||||
void PushUndo( char *description );
|
||||
// Do this push after changes, must match pushundo 1for1
|
||||
void PushRedo( char *description );
|
||||
|
||||
void WipeUndo( void );
|
||||
void WipeRedo( void );
|
||||
|
||||
const char *GetUndoDescription( void );
|
||||
const char *GetRedoDescription( void );
|
||||
|
||||
bool CanUndo( void );
|
||||
bool CanRedo( void );
|
||||
|
||||
void ParseSmoothingInfo( CDemoFile &demoFile, CUtlVector< demosmoothing_t >& smooth );
|
||||
void LoadSmoothingInfo( const char *filename, CSmoothingContext& smoothing );
|
||||
void ClearSmoothingInfo( CSmoothingContext& smoothing );
|
||||
void SaveSmoothingInfo( char const *filename, CSmoothingContext& smoothing );
|
||||
|
||||
CSmoothingTypeButton *m_pType;
|
||||
|
||||
vgui::Button *m_pRevert;
|
||||
vgui::Button *m_pOK;
|
||||
vgui::Button *m_pCancel;
|
||||
|
||||
vgui::Button *m_pSave;
|
||||
vgui::Button *m_pReloadFromDisk;
|
||||
|
||||
vgui::TextEntry *m_pStartFrame;
|
||||
vgui::TextEntry *m_pEndFrame;
|
||||
|
||||
vgui::Button *m_pPreviewOriginal;
|
||||
vgui::Button *m_pPreviewProcessed;
|
||||
|
||||
vgui::CheckButton *m_pBackOff;
|
||||
|
||||
vgui::Label *m_pSelectionInfo;
|
||||
vgui::CheckButton *m_pShowAllSamples;
|
||||
vgui::Button *m_pSelectSamples;
|
||||
|
||||
vgui::Button *m_pPauseResume;
|
||||
vgui::Button *m_pStepForward;
|
||||
vgui::Button *m_pStepBackward;
|
||||
|
||||
vgui::CheckButton *m_pHideLegend;
|
||||
|
||||
vgui::CheckButton *m_pHideOriginal;
|
||||
vgui::CheckButton *m_pHideProcessed;
|
||||
|
||||
vgui::Button *m_pToggleKeyFrame;
|
||||
vgui::Button *m_pToggleLookTarget;
|
||||
vgui::Button *m_pRevertPoint;
|
||||
|
||||
vgui::Button *m_pMoveCameraToPoint;
|
||||
|
||||
vgui::Button *m_pUndo;
|
||||
vgui::Button *m_pRedo;
|
||||
|
||||
vgui::Button *m_pNextKey;
|
||||
vgui::Button *m_pPrevKey;
|
||||
vgui::Button *m_pNextTarget;
|
||||
vgui::Button *m_pPrevTarget;
|
||||
|
||||
CFixEdgeButton *m_pFixEdges;
|
||||
vgui::TextEntry *m_pFixEdgeFrames;
|
||||
|
||||
vgui::Button *m_pProcessKey;
|
||||
|
||||
vgui::TextEntry *m_pGotoFrame;
|
||||
vgui::Button *m_pGoto;
|
||||
|
||||
bool m_bHasSelection;
|
||||
int m_nSelection[2];
|
||||
int m_iSelectionTicksSpan;
|
||||
|
||||
bool m_bPreviewing;
|
||||
bool m_bPreviewOriginal;
|
||||
int m_iPreviewStartTick;
|
||||
float m_fPreviewCurrentTime;
|
||||
int m_nPreviewLastFrame;
|
||||
bool m_bPreviewPaused;
|
||||
|
||||
CSmoothingContext m_Smoothing;
|
||||
|
||||
bool m_bInputActive;
|
||||
int m_nOldCursor[2];
|
||||
|
||||
|
||||
struct DemoSmoothUndo
|
||||
{
|
||||
CSmoothingContext *undo;
|
||||
CSmoothingContext *redo;
|
||||
char *udescription;
|
||||
char *rdescription;
|
||||
};
|
||||
|
||||
CUtlVector< DemoSmoothUndo * > m_UndoStack;
|
||||
int m_nUndoLevel;
|
||||
bool m_bRedoPending;
|
||||
|
||||
bool m_bDirty;
|
||||
|
||||
Vector m_vecEyeOffset;
|
||||
};
|
||||
|
||||
#endif // CL_DEMOSMOOTHERPANEL_H
|
||||
22
utils/demoinfo/demosmoothersamplesource.txt
Normal file
22
utils/demoinfo/demosmoothersamplesource.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
NOTE 2/8/05:
|
||||
|
||||
These files are copied directly out of the HL2 engine to use as a
|
||||
starting point for writing your own vgui based "smoothing" tools for dem files.
|
||||
|
||||
If you decide to use this, then my suggestion would be to copy these into a MOD in the client .dll and
|
||||
clean up the #include's so that you can get it basically compiling and showing up.
|
||||
|
||||
It should be a "tool" just like the net_graph and other vgui
|
||||
based tools in the client .dll (use a ConVar to show/hide it maybe?)
|
||||
|
||||
The sample source actually contains all of the reading/writing code for dem files which is also in deminfo.cpp.
|
||||
|
||||
Note that CDemoFile should be changed to CToolDemoFile.
|
||||
|
||||
As I recall, you might have to reimplement a "driving" interface like the one in the main demo UI panel. I would just implement
|
||||
it as part of this UI, etc.
|
||||
|
||||
If you have any questions or run into major snags, please let me know and I'll try to help out.
|
||||
|
||||
Yahn Bernier
|
||||
yahn@valvesoftware.com
|
||||
295
utils/demoinfo/tooldemofile.cpp
Normal file
295
utils/demoinfo/tooldemofile.cpp
Normal file
@@ -0,0 +1,295 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include <utlbuffer.h>
|
||||
#include "tooldemofile.h"
|
||||
#include "filesystem.h"
|
||||
#include "demofile/demoformat.h"
|
||||
|
||||
extern IBaseFileSystem *g_pFileSystem;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CToolDemoFile::CToolDemoFile()
|
||||
{
|
||||
m_hDemoFile = FILESYSTEM_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
CToolDemoFile::~CToolDemoFile()
|
||||
{
|
||||
if ( IsOpen() )
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CToolDemoFile::ReadSequenceInfo(int &nSeqNrIn, int &nSeqNrOut)
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
|
||||
g_pFileSystem->Read( &nSeqNrIn, sizeof(int), m_hDemoFile );
|
||||
g_pFileSystem->Read( &nSeqNrOut, sizeof(int), m_hDemoFile );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CToolDemoFile::ReadCmdInfo( democmdinfo_t& info )
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
g_pFileSystem->Read( &info, sizeof( democmdinfo_t ), m_hDemoFile );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : cmd -
|
||||
// dt -
|
||||
// frame -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CToolDemoFile::ReadCmdHeader( unsigned char& cmd, int& tick )
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
|
||||
// Read the command
|
||||
int r = g_pFileSystem->Read ( &cmd, sizeof(byte), m_hDemoFile );
|
||||
|
||||
if ( r <=0 )
|
||||
{
|
||||
Warning("Missing end tag in demo file.\n");
|
||||
cmd = dem_stop;
|
||||
return;
|
||||
}
|
||||
|
||||
Assert( cmd >= 1 && cmd <= dem_lastcmd );
|
||||
|
||||
// Read the timestamp
|
||||
g_pFileSystem->Read ( &tick, sizeof(int), m_hDemoFile );
|
||||
|
||||
tick = LittleDWord( tick );
|
||||
}
|
||||
|
||||
const char *CToolDemoFile::ReadConsoleCommand()
|
||||
{
|
||||
static char cmdstring[1024];
|
||||
|
||||
ReadRawData( cmdstring, sizeof(cmdstring) );
|
||||
|
||||
return cmdstring;
|
||||
}
|
||||
|
||||
unsigned int CToolDemoFile::GetCurPos()
|
||||
{
|
||||
if ( m_hDemoFile == FILESYSTEM_INVALID_HANDLE )
|
||||
return 0;
|
||||
|
||||
return g_pFileSystem->Tell( m_hDemoFile );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : expected_length -
|
||||
// &demofile -
|
||||
//-----------------------------------------------------------------------------
|
||||
int CToolDemoFile::ReadNetworkDataTables( CUtlBuffer *buf )
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
char data[ 1024 ];
|
||||
int length;
|
||||
|
||||
g_pFileSystem->Read( &length, sizeof( int ), m_hDemoFile );
|
||||
|
||||
while( length > 0 )
|
||||
{
|
||||
int chunk = min( length, 1024 );
|
||||
g_pFileSystem->Read( data, chunk, m_hDemoFile );
|
||||
length -= chunk;
|
||||
|
||||
if ( buf )
|
||||
{
|
||||
buf->Put( data, chunk );
|
||||
}
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : discard -
|
||||
//-----------------------------------------------------------------------------
|
||||
int CToolDemoFile::ReadUserCmd( char *buffer, int &size )
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
|
||||
int outgoing_sequence;
|
||||
|
||||
g_pFileSystem->Read( &outgoing_sequence, sizeof( int ), m_hDemoFile );
|
||||
|
||||
size = ReadRawData( buffer, size );
|
||||
|
||||
return outgoing_sequence;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Rewind from the current spot by the time stamp, byte code and frame counter offsets
|
||||
//-----------------------------------------------------------------------------
|
||||
void CToolDemoFile::SeekTo( int position )
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
g_pFileSystem->Seek( m_hDemoFile, position, FILESYSTEM_SEEK_HEAD );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
int CToolDemoFile::ReadRawData( char *buffer, int length )
|
||||
{
|
||||
Assert( m_hDemoFile != FILESYSTEM_INVALID_HANDLE );
|
||||
|
||||
int size;
|
||||
|
||||
// read length of data block
|
||||
g_pFileSystem->Read( &size, sizeof( int ), m_hDemoFile );
|
||||
|
||||
if ( buffer && (length < size) )
|
||||
{
|
||||
DevMsg("CToolDemoFile::ReadRawData: buffe overflow (%i).\n", size );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( buffer )
|
||||
{
|
||||
if ( length < size )
|
||||
{
|
||||
// given buffer is too small
|
||||
DevMsg("CToolDemoFile::ReadRawData: buffe overflow (%i).\n", size );
|
||||
g_pFileSystem->Seek( m_hDemoFile, size, FILESYSTEM_SEEK_CURRENT );
|
||||
size = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// read data into buffer
|
||||
int r = g_pFileSystem->Read( buffer, size, m_hDemoFile );
|
||||
if ( r != size )
|
||||
{
|
||||
Warning( "Error reading demo message data.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// just skip it
|
||||
g_pFileSystem->Seek( m_hDemoFile, size, FILESYSTEM_SEEK_CURRENT );
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
demoheader_t *CToolDemoFile::ReadDemoHeader()
|
||||
{
|
||||
if ( m_hDemoFile == FILESYSTEM_INVALID_HANDLE )
|
||||
return NULL; // file not open
|
||||
|
||||
// goto file start
|
||||
g_pFileSystem->Seek(m_hDemoFile, 0, FILESYSTEM_SEEK_HEAD);
|
||||
|
||||
Q_memset( &m_DemoHeader, 0, sizeof(m_DemoHeader) );
|
||||
|
||||
int r = g_pFileSystem->Read( &m_DemoHeader, sizeof(demoheader_t), m_hDemoFile );
|
||||
|
||||
if ( r != sizeof(demoheader_t) )
|
||||
return NULL; // reading failed
|
||||
|
||||
if ( Q_strcmp ( m_DemoHeader.demofilestamp, DEMO_HEADER_ID ) )
|
||||
{
|
||||
Warning( "%s has invalid demo header ID.\n", m_szFileName );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
// The current network protocol version. Changing this makes clients and servers incompatible
|
||||
#define PROTOCOL_VERSION 7
|
||||
|
||||
if ( m_DemoHeader.networkprotocol != PROTOCOL_VERSION )
|
||||
{
|
||||
Warning ("ERROR: demo network protocol %i outdated, engine version is %i \n",
|
||||
m_DemoHeader.networkprotocol, PROTOCOL_VERSION );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
if ( m_DemoHeader.demoprotocol != DEMO_PROTOCOL )
|
||||
{
|
||||
Warning ("ERROR: demo file protocol %i outdated, engine version is %i \n",
|
||||
m_DemoHeader.demoprotocol, DEMO_PROTOCOL );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &m_DemoHeader;
|
||||
}
|
||||
|
||||
bool CToolDemoFile::Open(const char *name, bool bReadOnly)
|
||||
{
|
||||
if ( m_hDemoFile != FILESYSTEM_INVALID_HANDLE )
|
||||
{
|
||||
Warning ("CToolDemoFile::Open: file already open.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_szFileName[0] = 0; // clear name
|
||||
Q_memset( &m_DemoHeader, 0, sizeof(m_DemoHeader) ); // and demo header
|
||||
|
||||
if ( bReadOnly )
|
||||
{
|
||||
// open existing file for reading only
|
||||
m_hDemoFile = g_pFileSystem->Open (name, "rb", "GAME" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// create new file for writing only
|
||||
m_hDemoFile = g_pFileSystem->Open (name, "wb", "GAME" );
|
||||
}
|
||||
|
||||
if ( m_hDemoFile == FILESYSTEM_INVALID_HANDLE )
|
||||
{
|
||||
Warning ("CToolDemoFile::Open: couldn't open file %s for %s.\n",
|
||||
name, bReadOnly?"reading":"writing" );
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_strncpy( m_szFileName, name, sizeof(m_szFileName) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CToolDemoFile::IsOpen()
|
||||
{
|
||||
return m_hDemoFile != FILESYSTEM_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
void CToolDemoFile::Close()
|
||||
{
|
||||
if ( m_hDemoFile != FILESYSTEM_INVALID_HANDLE )
|
||||
{
|
||||
g_pFileSystem->Close(m_hDemoFile);
|
||||
m_hDemoFile = FILESYSTEM_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
int CToolDemoFile::GetSize()
|
||||
{
|
||||
return g_pFileSystem->Size( m_hDemoFile );
|
||||
}
|
||||
|
||||
58
utils/demoinfo/tooldemofile.h
Normal file
58
utils/demoinfo/tooldemofile.h
Normal file
@@ -0,0 +1,58 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#ifndef TOOLDEMOFILE_H
|
||||
#define TOOLDEMOFILE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "mathlib/vector.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "utlvector.h"
|
||||
#include "filesystem.h"
|
||||
#include "demofile/demoformat.h"
|
||||
|
||||
class CUtlBuffer;
|
||||
|
||||
class CToolDemoFile
|
||||
{
|
||||
public:
|
||||
CToolDemoFile();
|
||||
virtual ~CToolDemoFile();
|
||||
|
||||
bool Open(const char *name, bool bReadOnly);
|
||||
bool IsOpen();
|
||||
void Close();
|
||||
|
||||
void SeekTo( int position );
|
||||
unsigned int GetCurPos();
|
||||
int GetSize();
|
||||
|
||||
int ReadRawData( char *buffer, int length );
|
||||
|
||||
void ReadSequenceInfo(int &nSeqNrIn, int &nSeqNrOutAck);
|
||||
|
||||
void ReadCmdInfo( democmdinfo_t& info );
|
||||
|
||||
void ReadCmdHeader( unsigned char& cmd, int& tick );
|
||||
|
||||
const char *ReadConsoleCommand( void );
|
||||
|
||||
int ReadNetworkDataTables( CUtlBuffer *buf ); // if buf is NULL, skip it
|
||||
|
||||
int ReadUserCmd( char *buffer, int &size );
|
||||
|
||||
demoheader_t *ReadDemoHeader();
|
||||
|
||||
|
||||
public:
|
||||
FileHandle_t m_hDemoFile; // filesystem handle
|
||||
char m_szFileName[MAX_PATH]; //name of current demo file
|
||||
demoheader_t m_DemoHeader; //general demo info
|
||||
};
|
||||
|
||||
#endif // TOOLDEMOFILE_H
|
||||
Reference in New Issue
Block a user