本文整理汇总了C++中KeyValues::GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::GetFloat方法的具体用法?C++ KeyValues::GetFloat怎么用?C++ KeyValues::GetFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::GetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseSurfaceData
int CPhysicsSurfaceProps::ParseSurfaceData(const char* pFilename, const char* pTextfile) {
if (!AddFileToDatabase(pFilename)) return 0;
KeyValues* surfprops = new KeyValues("");
surfprops->LoadFromBuffer(pFilename, pTextfile);
for (KeyValues* surface = surfprops; surface; surface = surface->GetNextKey()) {
CSurface prop;
int baseMaterial = GetSurfaceIndex("default");
memset(&prop.data, 0, sizeof(prop.data));
prop.m_name = m_strings->AddString(surface->GetName());
prop.data.game.material = 0;
prop.data.game.maxSpeedFactor = 1.0f;
prop.data.game.jumpFactor = 1.0f;
prop.data.game.climbable = 0.0f;
CopyPhysicsProperties(&prop, baseMaterial);
for (KeyValues* data = surface->GetFirstSubKey(); data; data = data->GetNextKey()) {
const char* key = data->GetName();
if (!strcmpi(key, "base")) {
baseMaterial = GetSurfaceIndex(data->GetString());
CopyPhysicsProperties(&prop, baseMaterial);
} else if (!strcmpi(key, "thickness")) {
prop.data.physics.thickness = data->GetFloat();
} else if (!strcmpi(key, "density")) {
prop.data.physics.density = data->GetFloat();
} else if (!strcmpi(key, "elasticity")) {
prop.data.physics.elasticity = data->GetFloat();
} else if (!strcmpi(key, "friction")) {
prop.data.physics.friction = data->GetFloat();
} else if (!strcmpi(key, "dampening")) {
prop.data.physics.dampening = data->GetFloat();
} else if (!strcmpi(key, "audioreflectivity")) {
prop.data.audio.reflectivity = data->GetFloat();
} else if (!strcmpi(key, "audiohardnessfactor")) {
prop.data.audio.hardnessFactor = data->GetFloat();
} else if (!strcmpi(key, "audioroughnessfactor")) {
prop.data.audio.roughnessFactor = data->GetFloat();
} else if (!strcmpi(key, "scrapeRoughThreshold")) {
prop.data.audio.roughThreshold = data->GetFloat();
} else if (!strcmpi(key, "impactHardThreshold")) {
prop.data.audio.hardThreshold = data->GetFloat();
} else if (!strcmpi(key, "audioHardMinVelocity")) {
prop.data.audio.hardVelocityThreshold = data->GetFloat();
} else if (!strcmpi(key, "maxspeedfactor")) {
prop.data.game.maxSpeedFactor = data->GetFloat();
} else if (!strcmpi(key, "jumpfactor")) {
prop.data.game.jumpFactor = data->GetFloat();
} else if (!strcmpi(key, "climbable")) {
prop.data.game.climbable = data->GetInt();
} else if (!strcmpi(key, "gamematerial")) {
if (data->GetDataType() == KeyValues::TYPE_STRING && strlen(data->GetString()) == 1) {
prop.data.game.material = toupper(data->GetString()[0]);
} else {
prop.data.game.material = data->GetInt();
}
} else if (!strcmpi(key, "stepleft")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.stepleft = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "stepright")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.stepright = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "impactsoft")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.impactSoft = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "impacthard")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.impactHard = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "scrapesmooth")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.scrapeSmooth = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "scraperough")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.scrapeRough = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "bulletimpact")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.bulletImpact = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "break")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.breakSound = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "strain")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.strainSound = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "rolling")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.rolling = m_soundList.AddToTail(sym);
} else {
AssertMsg2(0, "Bad surfaceprop key %s (%s)\n", key, data->GetString());
}
}
if (GetSurfaceIndex(m_strings->String(prop.m_name)) >= 0) break;
m_props.AddToTail(prop);
}
surfprops->deleteThis();
return 0;
}
示例2: ParseDetailGroup
//-----------------------------------------------------------------------------
// Parses the key-value pairs in the detail.rad file
//-----------------------------------------------------------------------------
static void ParseDetailGroup( int detailId, KeyValues* pGroupKeyValues )
{
// Sort the group by alpha
float alpha = pGroupKeyValues->GetFloat( "alpha", 1.0f );
int i = s_DetailObjectDict[detailId].m_Groups.Count();
while ( --i >= 0 )
{
if (alpha > s_DetailObjectDict[detailId].m_Groups[i].m_Alpha)
break;
}
// Insert after the first guy who's more transparent that we are!
i = s_DetailObjectDict[detailId].m_Groups.InsertAfter(i);
DetailObjectGroup_t& group = s_DetailObjectDict[detailId].m_Groups[i];
group.m_Alpha = alpha;
// Add in all the model groups
KeyValues* pIter = pGroupKeyValues->GetFirstSubKey();
float totalAmount = 0.0f;
while( pIter )
{
if (pIter->GetFirstSubKey())
{
int i = group.m_Models.AddToTail();
DetailModel_t &model = group.m_Models[i];
model.m_ModelName = pIter->GetString( "model", 0 );
if (model.m_ModelName != UTL_INVAL_SYMBOL)
{
model.m_Type = DETAIL_PROP_TYPE_MODEL;
}
else
{
const char *pSpriteData = pIter->GetString( "sprite", 0 );
if (pSpriteData)
{
model.m_Type = DETAIL_PROP_TYPE_SPRITE;
model.m_Tex[0].Init();
model.m_Tex[1].Init();
float x = 0, y = 0, flWidth = 64, flHeight = 64, flTextureSize = 512;
int nValid = sscanf( pSpriteData, "%f %f %f %f %f", &x, &y, &flWidth, &flHeight, &flTextureSize );
if ( (nValid != 5) || (flTextureSize == 0) )
{
Error( "Invalid arguments to \"sprite\" in detail.vbsp!\n" );
}
model.m_Tex[0].x = ( x + 0.5f ) / flTextureSize;
model.m_Tex[0].y = ( y + 0.5f ) / flTextureSize;
model.m_Tex[1].x = ( x + flWidth - 0.5f ) / flTextureSize;
model.m_Tex[1].y = ( y + flHeight - 0.5f ) / flTextureSize;
model.m_Pos[0].Init( -10, 20 );
model.m_Pos[1].Init( 10, 0 );
pSpriteData = pIter->GetString( "spritesize", 0 );
if (pSpriteData)
{
sscanf( pSpriteData, "%f %f %f %f", &x, &y, &flWidth, &flHeight );
float ox = flWidth * x;
float oy = flHeight * y;
model.m_Pos[0].x = -ox;
model.m_Pos[0].y = flHeight - oy;
model.m_Pos[1].x = flWidth - ox;
model.m_Pos[1].y = -oy;
}
model.m_flRandomScaleStdDev = pIter->GetFloat( "spriterandomscale", 0.0f );
}
}
model.m_Amount = pIter->GetFloat( "amount", 1.0 ) + totalAmount;
totalAmount = model.m_Amount;
model.m_Flags = 0;
if (pIter->GetInt( "upright", 0 ))
{
model.m_Flags |= MODELFLAG_UPRIGHT;
}
// These are used to prevent emission on steep surfaces
float minAngle = pIter->GetFloat( "minAngle", 180 );
float maxAngle = pIter->GetFloat( "maxAngle", 180 );
model.m_MinCosAngle = cos(minAngle * M_PI / 180.f);
model.m_MaxCosAngle = cos(maxAngle * M_PI / 180.f);
model.m_Orientation = pIter->GetInt( "detailOrientation", 0 );
// Make sure minAngle < maxAngle
if ( model.m_MinCosAngle < model.m_MaxCosAngle)
{
model.m_MinCosAngle = model.m_MaxCosAngle;
//.........这里部分代码省略.........
示例3: LoadWeapons
void CWeapons::LoadWeapons(const char *szWeaponListName, WeaponsData_t *pDefault)
{
if ((szWeaponListName != NULL) && (szWeaponListName[0] != 0))
{
KeyValues *kv = new KeyValues("Weapons");
char szFilename[1024];
CBotGlobals::BuildFileName(szFilename, "weapons", BOT_CONFIG_FOLDER, "ini", false);
if (kv)
{
if (kv->LoadFromFile(filesystem, szFilename, NULL))
{
kv = kv->FindKey(szWeaponListName);
if (kv)
{
kv = kv->GetFirstSubKey();
if (0)
kv = kv->GetFirstTrueSubKey();
while (kv != NULL)
{
WeaponsData_t newWeapon;
memset(&newWeapon, 0, sizeof(WeaponsData_t));
const char *szKeyName = kv->GetName();
char lowered[64];
strncpy(lowered, szKeyName, 63);
lowered[63] = 0;
__strlow(lowered);
newWeapon.szWeaponName = CStrings::GetString(lowered);
newWeapon.iId = kv->GetInt("id");
newWeapon.iSlot = kv->GetInt("slot");
newWeapon.minPrimDist = kv->GetFloat("minPrimDist");
newWeapon.maxPrimDist = kv->GetFloat("maxPrimDist");
newWeapon.m_fProjSpeed = kv->GetFloat("m_fProjSpeed");
newWeapon.m_iAmmoIndex = kv->GetInt("m_iAmmoIndex");
newWeapon.m_iPreference = kv->GetInt("m_iPreference");
KeyValues *flags = kv->FindKey("flags");
if (flags)
{
int i = 0;
while (szWeaponFlags[i][0] != '\0')
{
if (flags->FindKey(szWeaponFlags[i]) && (flags->GetInt(szWeaponFlags[i]) == 1))
newWeapon.m_iFlags |= (1 << i);
i++;
}
}
AddWeapon(new CWeapon(&newWeapon));
kv = kv->GetNextTrueSubKey();
}
}
}
kv->deleteThis();
}
}
if (pDefault != NULL)
{
// No weapons from INI file then add default
if (m_theWeapons.size() == 0)
{
while (pDefault->szWeaponName[0] != '\0')
{
AddWeapon(new CWeapon(pDefault));
pDefault++;
}
}
}
}
示例4: RunLabel
bool CMapAdd::RunLabel( const char *mapaddMap, const char *szLabel)
{
if(AllocPooledString(mapaddMap) == AllocPooledString("") || !mapaddMap || !szLabel || AllocPooledString(szLabel) == AllocPooledString(""))
return false; //Failed to load!
//FileHandle_t fh = filesystem->Open(szMapadd,"r","MOD");
// Open the mapadd data file, and abort if we can't
KeyValues *pMapAdd = new KeyValues( "MapAdd" );
if(pMapAdd->LoadFromFile( filesystem, mapaddMap, "MOD" ))
{
KeyValues *pMapAdd2 = pMapAdd->FindKey(szLabel);
if(pMapAdd2)
{
KeyValues *pMapAddEnt = pMapAdd2->GetFirstTrueSubKey();
while (pMapAddEnt)
{
if(!HandlePlayerEntity(pMapAddEnt, false) && !HandleRemoveEnitity( pMapAddEnt ) && !HandleSMODEntity(pMapAddEnt) && !HandleSpecialEnitity(pMapAddEnt))
{
Vector SpawnVector = Vector(0,0,0);
QAngle SpawnAngle = QAngle(0,0,0);
SpawnVector.x = pMapAddEnt->GetFloat("x", SpawnVector.x);
SpawnVector.y = pMapAddEnt->GetFloat("y", SpawnVector.y);
SpawnVector.z = pMapAddEnt->GetFloat("z", SpawnVector.z);
SpawnAngle[PITCH] = pMapAddEnt->GetFloat("pitch", SpawnAngle[PITCH]);
SpawnAngle[YAW] = pMapAddEnt->GetFloat("yaw", SpawnAngle[YAW]);
SpawnAngle[ROLL] = pMapAddEnt->GetFloat("roll", SpawnAngle[ROLL]);
CBaseEntity *createEnt = CBaseEntity::CreateNoSpawn(pMapAddEnt->GetName(),SpawnVector,SpawnAngle);
KeyValues *pEntKeyValues = pMapAddEnt->FindKey("KeyValues");
if(pEntKeyValues && createEnt)
{
Msg("keyvalue for %s Found!\n",pMapAddEnt->GetName());
KeyValues *pEntKeyValuesAdd = pEntKeyValues->GetFirstValue();
while(pEntKeyValuesAdd && createEnt)
{
if(AllocPooledString(pEntKeyValuesAdd->GetName()) == AllocPooledString("model"))
{
PrecacheModel(pEntKeyValuesAdd->GetString(""));
createEnt->SetModel(pEntKeyValuesAdd->GetString(""));
}
/* else if(AllocPooledString(pEntKeyValuesAdd->GetName()) == AllocPooledString("name"))
{
createEnt->SetName(AllocPooledString(pEntKeyValuesAdd->GetString("")));
}
else if(AllocPooledString(pEntKeyValuesAdd->GetName()) == AllocPooledString("spawnflags"))
{
createEnt->AddSpawnFlags(pEntKeyValuesAdd->GetInt());
}*/
else
{
createEnt->KeyValue(pEntKeyValuesAdd->GetName(),pEntKeyValuesAdd->GetString(""));
}
pEntKeyValuesAdd = pEntKeyValuesAdd->GetNextValue();
}
}
//createEnt->Activate();//Is this a good idea? Not sure!
//createEnt->Spawn();
DispatchSpawn( createEnt ); //I derped
}
pMapAddEnt = pMapAddEnt->GetNextTrueSubKey(); //Got to keep this!
}
}
}
pMapAdd->deleteThis();
return true;
}
示例5: KeyValues
BasicShaderCfg_t *BuildShaderData( const char *dumpFileName )
{
KeyValues *pKV = new KeyValues( dumpFileName );
char _path[MAX_PATH];
Q_snprintf( _path, MAX_PATH, "%s/%s.dump", ::GetDumpDirectory(), dumpFileName );
Q_FixSlashes( _path );
pKV->LoadFromFile( g_pFullFileSystem, _path, "MOD" );
BasicShaderCfg_t *data = new BasicShaderCfg_t();
const char *szT = pKV->GetString( "vs_name" );
int len = Q_strlen( szT ) + 1;
data->ProcVSName = new char[ len ];
Q_snprintf( data->ProcVSName, len, "%s", szT );
szT = pKV->GetString( "ps_name" );
len = Q_strlen( szT ) + 1;
data->ProcPSName = new char[ len ];
Q_snprintf( data->ProcPSName, len, "%s", szT );
szT = pKV->GetString( "shader_filename" );
len = Q_strlen( szT ) + 1;
data->Filename = new char[ len ];
Q_snprintf( data->Filename, len, "%s", szT );
Q_FixSlashes( data->Filename );
szT = pKV->GetName();
len = Q_strlen( szT ) + 1;
data->CanvasName = new char[ len ];
Q_snprintf( data->CanvasName, len, "%s", szT );
Q_snprintf( data->dumpversion, sizeof(data->dumpversion), "%s", pKV->GetString( GetDumpVersion_KeyName() ) );
data->iShaderModel = pKV->GetInt( "i_sm" );
data->iCullmode = pKV->GetInt( "i_cull" );
data->iAlphablendmode = pKV->GetInt( "i_ablend" );
data->flAlphaTestRef = pKV->GetFloat( "fl_atestref" );
data->iDepthtestmode = pKV->GetInt( "i_dtest" );
data->iDepthwritemode = pKV->GetInt( "i_dwrite" );
data->bsRGBWrite = !!pKV->GetInt( "i_srgbw" );
data->iVFMT_flags = pKV->GetInt( "i_vfmt_flags" );
data->iVFMT_numTexcoords = pKV->GetInt( "i_vfmt_texcoords" );
data->iVFMT_numUserData = pKV->GetInt( "i_vfmt_udata" );
for ( int i = 0; i < 3; i++ )
{
char tmp[48];
Q_snprintf( tmp, sizeof(tmp), "i_vfmt_texcoordDim_%i", i );
data->iVFMT_texDim[i] = pKV->GetInt( tmp, GetVarFlagsVarValue( HLSLVAR_FLOAT2 ) + 1 );
}
data->bVertexLighting = !!pKV->GetInt( "i_vlit" );
data->bRefractionSupport = !!pKV->GetInt( "i_vrefract" );
KeyValues *pSubIdent_VS = pKV->FindKey( "identifiers_VS" );
if ( pSubIdent_VS )
ReadIdents( *data->pVS_Identifiers, pSubIdent_VS );
KeyValues *pSubIdent_PS = pKV->FindKey( "identifiers_PS" );
if ( pSubIdent_PS )
ReadIdents( *data->pPS_Identifiers, pSubIdent_PS );
pKV->deleteThis();
return data;
}
示例6: LoadObjectInfos
void LoadObjectInfos( IBaseFileSystem *pFileSystem )
{
const char *pFilename = "scripts/objects.txt";
// Make sure this stuff hasn't already been loaded.
Assert( !AreObjectInfosLoaded() );
KeyValues *pValues = new KeyValues( "Object descriptions" );
if ( !pValues->LoadFromFile( pFileSystem, pFilename, "GAME" ) )
{
Error( "Can't open %s for object info.", pFilename );
pValues->deleteThis();
return;
}
// Now read each class's information in.
for ( int iObj=0; iObj < ARRAYSIZE( g_ObjectInfos ); iObj++ )
{
CObjectInfo *pInfo = &g_ObjectInfos[iObj];
KeyValues *pSub = pValues->FindKey( pInfo->m_pObjectName );
if ( !pSub )
{
Error( "Missing section '%s' from %s.", pInfo->m_pObjectName, pFilename );
pValues->deleteThis();
return;
}
// Read all the info in.
if ( (pInfo->m_flBuildTime = pSub->GetFloat( "BuildTime", -999 )) == -999 ||
(pInfo->m_nMaxObjects = pSub->GetInt( "MaxObjects", -999 )) == -999 ||
(pInfo->m_Cost = pSub->GetInt( "Cost", -999 )) == -999 ||
(pInfo->m_CostMultiplierPerInstance = pSub->GetFloat( "CostMultiplier", -999 )) == -999 ||
(pInfo->m_UpgradeCost = pSub->GetInt( "UpgradeCost", -999 )) == -999 ||
(pInfo->m_MaxUpgradeLevel = pSub->GetInt( "MaxUpgradeLevel", -999 )) == -999 ||
(pInfo->m_SelectionSlot = pSub->GetInt( "SelectionSlot", -999 )) == -999 ||
(pInfo->m_SelectionPosition = pSub->GetInt( "SelectionPosition", -999 )) == -999 )
{
Error( "Missing data for object '%s' in %s.", pInfo->m_pObjectName, pFilename );
pValues->deleteThis();
return;
}
pInfo->m_pClassName = ReadAndAllocStringValue( pSub, "ClassName", pFilename );
pInfo->m_pStatusName = ReadAndAllocStringValue( pSub, "StatusName", pFilename );
pInfo->m_pBuilderWeaponName = ReadAndAllocStringValue( pSub, "BuilderWeaponName", pFilename );
pInfo->m_pBuilderPlacementString = ReadAndAllocStringValue( pSub, "BuilderPlacementString", pFilename );
pInfo->m_bSolidToPlayerMovement = pSub->GetInt( "SolidToPlayerMovement", 0 ) ? true : false;
pInfo->m_pIconActive = ReadAndAllocStringValue( pSub, "IconActive", pFilename );
pInfo->m_pIconInactive = ReadAndAllocStringValue( pSub, "IconInactive", pFilename );
pInfo->m_pViewModel = ReadAndAllocStringValue( pSub, "Viewmodel", pFilename );
pInfo->m_pPlayerModel = ReadAndAllocStringValue( pSub, "Playermodel", pFilename );
pInfo->m_iDisplayPriority = pSub->GetInt( "DisplayPriority", 0 );
pInfo->m_pHudStatusIcon = ReadAndAllocStringValue( pSub, "HudStatusIcon", pFilename );
pInfo->m_bVisibleInWeaponSelection = ( pSub->GetInt( "VisibleInWeaponSelection", 1 ) > 0 );
pInfo->m_pExplodeSound = ReadAndAllocStringValue( pSub, "ExplodeSound", pFilename );
pInfo->m_pExplosionParticleEffect = ReadAndAllocStringValue( pSub, "ExplodeEffect", pFilename );
pInfo->m_bAutoSwitchTo = ( pSub->GetInt( "autoswitchto", 0 ) > 0 );
pInfo->m_iMetalToDropInGibs = pSub->GetInt( "MetalToDropInGibs", 0 );
}
pValues->deleteThis();
}
示例7: Parse
void FileWeaponInfo_t::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )
{
// Okay, we tried at least once to look this up...
bParsedScript = true;
// Classname
Q_strncpy( szClassName, szWeaponName, MAX_WEAPON_STRING );
// Printable name
Q_strncpy( szPrintName, pKeyValuesData->GetString( "printname", WEAPON_PRINTNAME_MISSING ), MAX_WEAPON_STRING );
// View model & world model
Q_strncpy( szViewModel, pKeyValuesData->GetString( "viewmodel" ), MAX_WEAPON_STRING );
Q_strncpy( szWorldModel, pKeyValuesData->GetString( "playermodel" ), MAX_WEAPON_STRING );
Q_strncpy( szClipModel, pKeyValuesData->GetString( "clipmodel" ), MAX_WEAPON_STRING );
Q_strncpy( szAnimationPrefix, pKeyValuesData->GetString( "anim_prefix" ), MAX_WEAPON_PREFIX );
iSlot = pKeyValuesData->GetInt( "bucket", 0 );
iPosition = pKeyValuesData->GetInt( "bucket_position", 0 );
iMaxClip1 = pKeyValuesData->GetInt( "clip_size", WEAPON_NOCLIP ); // Max primary clips gun can hold (assume they don't use clips by default)
iMaxClip2 = pKeyValuesData->GetInt( "clip2_size", WEAPON_NOCLIP ); // Max secondary clips gun can hold (assume they don't use clips by default)
iDefaultClip1 = pKeyValuesData->GetInt( "default_clip", iMaxClip1 ); // amount of primary ammo placed in the primary clip when it's picked up
iDefaultClip2 = pKeyValuesData->GetInt( "default_clip2", iMaxClip2 ); // amount of secondary ammo placed in the secondary clip when it's picked up
iWeight = pKeyValuesData->GetInt( "weight", 0 );
iRumbleEffect = pKeyValuesData->GetInt( "rumble", -1 );
// Viewmodel FOV
flViewFov = pKeyValuesData->GetFloat( "view_fov", 0.0f );
// Bash DMG
m_flBashDamage = pKeyValuesData->GetFloat("damage_bash", 1.0f);
// LAME old way to specify item flags.
// Weapon scripts should use the flag names.
iFlags = pKeyValuesData->GetInt( "item_flags", ITEM_FLAG_LIMITINWORLD );
for ( int i=0; i < ARRAYSIZE( g_ItemFlags ); i++ )
{
int iVal = pKeyValuesData->GetInt( g_ItemFlags[i].m_pFlagName, -1 );
if ( iVal == 0 )
{
iFlags &= ~g_ItemFlags[i].m_iFlagValue;
}
else if ( iVal == 1 )
{
iFlags |= g_ItemFlags[i].m_iFlagValue;
}
}
bShowUsageHint = ( pKeyValuesData->GetInt( "showusagehint", 0 ) != 0 ) ? true : false;
bAutoSwitchTo = ( pKeyValuesData->GetInt( "autoswitchto", 1 ) != 0 ) ? true : false;
bAutoSwitchFrom = ( pKeyValuesData->GetInt( "autoswitchfrom", 1 ) != 0 ) ? true : false;
m_bBuiltRightHanded = ( pKeyValuesData->GetInt( "BuiltRightHanded", 1 ) != 0 ) ? true : false;
m_bAllowFlipping = ( pKeyValuesData->GetInt( "AllowFlipping", 1 ) != 0 ) ? true : false;
m_bMeleeWeapon = ( pKeyValuesData->GetInt( "MeleeWeapon", 0 ) != 0 ) ? true : false;
#if defined(_DEBUG) && defined(HL2_CLIENT_DLL)
// make sure two weapons aren't in the same slot & position
if ( iSlot >= MAX_WEAPON_SLOTS ||
iPosition >= MAX_WEAPON_POSITIONS )
{
Warning( "Invalid weapon slot or position [slot %d/%d max], pos[%d/%d max]\n",
iSlot, MAX_WEAPON_SLOTS - 1, iPosition, MAX_WEAPON_POSITIONS - 1 );
}
else
{
if (g_bUsedWeaponSlots[iSlot][iPosition])
{
Warning( "Duplicately assigned weapon slots in selection hud: %s (%d, %d)\n", szPrintName, iSlot, iPosition );
}
g_bUsedWeaponSlots[iSlot][iPosition] = true;
}
#endif
// Primary ammo used
const char *pAmmo = pKeyValuesData->GetString( "primary_ammo", "None" );
if ( strcmp("None", pAmmo) == 0 )
Q_strncpy( szAmmo1, "", sizeof( szAmmo1 ) );
else
Q_strncpy( szAmmo1, pAmmo, sizeof( szAmmo1 ) );
iAmmoType = GetAmmoDef()->Index( szAmmo1 );
// Secondary ammo used
pAmmo = pKeyValuesData->GetString( "secondary_ammo", "None" );
if ( strcmp("None", pAmmo) == 0)
Q_strncpy( szAmmo2, "", sizeof( szAmmo2 ) );
else
Q_strncpy( szAmmo2, pAmmo, sizeof( szAmmo2 ) );
iAmmo2Type = GetAmmoDef()->Index( szAmmo2 );
// Ironsight
KeyValues *pSights = pKeyValuesData->FindKey( "IronSight" );
if (pSights)
{
vecIronsightPosOffset.x = pSights->GetFloat( "forward", 0.0f );
vecIronsightPosOffset.y = pSights->GetFloat( "right", 0.0f );
vecIronsightPosOffset.z = pSights->GetFloat( "up", 0.0f );
angIronsightAngOffset[PITCH] = pSights->GetFloat( "pitch", 0.0f );
angIronsightAngOffset[YAW] = pSights->GetFloat( "yaw", 0.0f );
//.........这里部分代码省略.........
示例8: GetValue
//-----------------------------------------------------------------------------
// Purpose: Gets the specified value from a panel
//-----------------------------------------------------------------------------
AnimationController::Value_t AnimationController::GetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var)
{
Value_t val = { 0, 0, 0, 0 };
if (var == m_sPosition)
{
int x, y;
panel->GetPos(x, y);
val.a = (float)(x - GetRelativeOffset( anim.align, true ) );
val.b = (float)(y - GetRelativeOffset( anim.align, false ) );
}
else if (var == m_sSize)
{
int w, t;
panel->GetSize(w, t);
val.a = (float)w;
val.b = (float)t;
}
else if (var == m_sFgColor)
{
Color col = panel->GetFgColor();
val.a = col[0];
val.b = col[1];
val.c = col[2];
val.d = col[3];
}
else if (var == m_sBgColor)
{
Color col = panel->GetBgColor();
val.a = col[0];
val.b = col[1];
val.c = col[2];
val.d = col[3];
}
else if ( var == m_sXPos )
{
int x, y;
panel->GetPos(x, y);
val.a = (float)( x - GetRelativeOffset( anim.align, true ) );
}
else if ( var == m_sYPos )
{
int x, y;
panel->GetPos(x, y);
val.a = (float)( y - GetRelativeOffset( anim.align, false ) );
}
else if ( var == m_sWide )
{
int w, h;
panel->GetSize(w, h);
val.a = (float)w;
}
else if ( var == m_sTall )
{
int w, h;
panel->GetSize(w, h);
val.a = (float)h;
}
else
{
KeyValues *outputData = new KeyValues(g_ScriptSymbols.String(var));
if (panel->RequestInfo(outputData))
{
// find the var and lookup it's type
KeyValues *kv = outputData->FindKey(g_ScriptSymbols.String(var));
if (kv && kv->GetDataType() == KeyValues::TYPE_FLOAT)
{
val.a = kv->GetFloat();
val.b = 0.0f;
val.c = 0.0f;
val.d = 0.0f;
}
else if (kv && kv->GetDataType() == KeyValues::TYPE_COLOR)
{
Color col = kv->GetColor();
val.a = col[0];
val.b = col[1];
val.c = col[2];
val.d = col[3];
}
}
else
{
// Assert(!("Unhandlable var in AnimationController::GetValue())"));
}
outputData->deleteThis();
}
return val;
}
示例9: LoadObjectInfos
void LoadObjectInfos( IBaseFileSystem *pFileSystem )
{
const char *pFilename = "scripts/objects.txt";
// Make sure this stuff hasn't already been loaded.
Assert( !AreObjectInfosLoaded() );
KeyValues *pValues = new KeyValues( "Object descriptions" );
if ( !pValues->LoadFromFile( pFileSystem, pFilename, "GAME" ) )
{
Error( "Can't open %s for object info.", pFilename );
pValues->deleteThis();
return;
}
// Now read each class's information in.
for ( int iObj=0; iObj < ARRAYSIZE( g_ObjectInfos ); iObj++ )
{
CObjectInfo *pInfo = &g_ObjectInfos[iObj];
KeyValues *pSub = pValues->FindKey( pInfo->m_pObjectName );
if ( !pSub )
{
Error( "Missing section '%s' from %s.", pInfo->m_pObjectName, pFilename );
pValues->deleteThis();
return;
}
// Read all the info in.
if ( (pInfo->m_flBuildTime = pSub->GetFloat( "BuildTime", -999 )) == -999 ||
(pInfo->m_nMaxObjects = pSub->GetInt( "MaxObjects", -999 )) == -999 ||
(pInfo->m_Cost = pSub->GetInt( "Cost", -999 )) == -999 ||
(pInfo->m_CostMultiplierPerInstance = pSub->GetFloat( "CostMultiplier", -999 )) == -999 ||
(pInfo->m_UpgradeCost = pSub->GetInt( "UpgradeCost", -999 )) == -999 ||
(pInfo->m_flUpgradeDuration = pSub->GetFloat( "UpgradeDuration", -999)) == -999 ||
(pInfo->m_MaxUpgradeLevel = pSub->GetInt( "MaxUpgradeLevel", -999 )) == -999 ||
(pInfo->m_SelectionSlot = pSub->GetInt( "SelectionSlot", -999 )) == -999 ||
(pInfo->m_BuildCount = pSub->GetInt( "BuildCount", -999 )) == -999 ||
(pInfo->m_SelectionPosition = pSub->GetInt( "SelectionPosition", -999 )) == -999 )
{
Error( "Missing data for object '%s' in %s.", pInfo->m_pObjectName, pFilename );
pValues->deleteThis();
return;
}
pInfo->m_pClassName = ReadAndAllocStringValue( pSub, "ClassName", pFilename );
pInfo->m_pStatusName = ReadAndAllocStringValue( pSub, "StatusName", pFilename );
pInfo->m_pBuilderWeaponName = ReadAndAllocStringValue( pSub, "BuilderWeaponName", pFilename );
pInfo->m_pBuilderPlacementString = ReadAndAllocStringValue( pSub, "BuilderPlacementString", pFilename );
pInfo->m_bSolidToPlayerMovement = pSub->GetInt( "SolidToPlayerMovement", 0 ) ? true : false;
pInfo->m_pIconActive = ReadAndAllocStringValue( pSub, "IconActive", pFilename );
pInfo->m_pIconInactive = ReadAndAllocStringValue( pSub, "IconInactive", pFilename );
pInfo->m_pIconMenu = ReadAndAllocStringValue( pSub, "IconMenu", pFilename );
pInfo->m_bUseItemInfo = pSub->GetInt( "UseItemInfo", 0 ) ? true : false;
pInfo->m_pViewModel = ReadAndAllocStringValue( pSub, "Viewmodel", pFilename );
pInfo->m_pPlayerModel = ReadAndAllocStringValue( pSub, "Playermodel", pFilename );
pInfo->m_iDisplayPriority = pSub->GetInt( "DisplayPriority", 0 );
pInfo->m_pHudStatusIcon = ReadAndAllocStringValue( pSub, "HudStatusIcon", pFilename );
pInfo->m_bVisibleInWeaponSelection = ( pSub->GetInt( "VisibleInWeaponSelection", 1 ) > 0 );
pInfo->m_pExplodeSound = ReadAndAllocStringValue( pSub, "ExplodeSound", pFilename );
pInfo->m_pUpgradeSound = ReadAndAllocStringValue( pSub, "UpgradeSound", pFilename );
pInfo->m_pExplosionParticleEffect = ReadAndAllocStringValue( pSub, "ExplodeEffect", pFilename );
pInfo->m_bAutoSwitchTo = ( pSub->GetInt( "autoswitchto", 0 ) > 0 );
pInfo->m_iMetalToDropInGibs = pSub->GetInt( "MetalToDropInGibs", 0 );
pInfo->m_bRequiresOwnBuilder = pSub->GetBool( "RequiresOwnBuilder", 0 );
// PistonMiner: Added Object Mode key
KeyValues *pAltModes = pSub->FindKey("AltModes");
if (pAltModes)
{
for (int i = 0; i < 4; ++i) // load at most 4 object modes
{
char altModeBuffer[256]; // Max size of 0x100
V_snprintf(altModeBuffer, ARRAYSIZE(altModeBuffer), "AltMode%d", i);
KeyValues *pCurAltMode = pAltModes->FindKey(altModeBuffer);
if (!pCurAltMode)
break;
// Save logic here
pInfo->m_AltModes.AddToTail(ReadAndAllocStringValue( pCurAltMode, "StatusName", pFilename ));
pInfo->m_AltModes.AddToTail(ReadAndAllocStringValue( pCurAltMode, "ModeName", pFilename ));
pInfo->m_AltModes.AddToTail(ReadAndAllocStringValue( pCurAltMode, "IconMenu", pFilename ));
}
}
}
pValues->deleteThis();
}
示例10: ParseDetailGroup
//-----------------------------------------------------------------------------
// Parses the key-value pairs in the detail.rad file
//-----------------------------------------------------------------------------
static void ParseDetailGroup( int detailId, KeyValues* pGroupKeyValues )
{
// Sort the group by alpha
float alpha = pGroupKeyValues->GetFloat( "alpha", 1.0f );
int i = s_DetailObjectDict[detailId].m_Groups.Count();
while ( --i >= 0 )
{
if (alpha > s_DetailObjectDict[detailId].m_Groups[i].m_Alpha)
break;
}
// Insert after the first guy who's more transparent that we are!
i = s_DetailObjectDict[detailId].m_Groups.InsertAfter(i);
DetailObjectGroup_t& group = s_DetailObjectDict[detailId].m_Groups[i];
group.m_Alpha = alpha;
// Add in all the model groups
KeyValues* pIter = pGroupKeyValues->GetFirstSubKey();
float totalAmount = 0.0f;
while( pIter )
{
if (pIter->GetFirstSubKey())
{
int i = group.m_Models.AddToTail();
DetailModel_t &model = group.m_Models[i];
model.m_ModelName = pIter->GetString( "model", 0 );
if (model.m_ModelName != UTL_INVAL_SYMBOL)
{
model.m_Type = DETAIL_PROP_TYPE_MODEL;
}
else
{
const char *pSpriteData = pIter->GetString( "sprite", 0 );
if (pSpriteData)
{
const char *pProcModelType = pIter->GetString( "sprite_shape", 0 );
if ( pProcModelType )
{
if ( !Q_stricmp( pProcModelType, "cross" ) )
{
model.m_Type = DETAIL_PROP_TYPE_SHAPE_CROSS;
}
else if ( !Q_stricmp( pProcModelType, "tri" ) )
{
model.m_Type = DETAIL_PROP_TYPE_SHAPE_TRI;
}
else
model.m_Type = DETAIL_PROP_TYPE_SPRITE;
}
else
{
// card sprite
model.m_Type = DETAIL_PROP_TYPE_SPRITE;
}
model.m_Tex[0].Init();
model.m_Tex[1].Init();
float x = 0, y = 0, flWidth = 64, flHeight = 64, flTextureSize = 512;
int nValid = sscanf( pSpriteData, "%f %f %f %f %f", &x, &y, &flWidth, &flHeight, &flTextureSize );
if ( (nValid != 5) || (flTextureSize == 0) )
{
Error( "Invalid arguments to \"sprite\" in detail.vbsp (model %s)!\n", model.m_ModelName );
}
model.m_Tex[0].x = ( x + 0.5f ) / flTextureSize;
model.m_Tex[0].y = ( y + 0.5f ) / flTextureSize;
model.m_Tex[1].x = ( x + flWidth - 0.5f ) / flTextureSize;
model.m_Tex[1].y = ( y + flHeight - 0.5f ) / flTextureSize;
model.m_Pos[0].Init( -10, 20 );
model.m_Pos[1].Init( 10, 0 );
pSpriteData = pIter->GetString( "spritesize", 0 );
if (pSpriteData)
{
sscanf( pSpriteData, "%f %f %f %f", &x, &y, &flWidth, &flHeight );
float ox = flWidth * x;
float oy = flHeight * y;
model.m_Pos[0].x = -ox;
model.m_Pos[0].y = flHeight - oy;
model.m_Pos[1].x = flWidth - ox;
model.m_Pos[1].y = -oy;
}
model.m_flRandomScaleStdDev = pIter->GetFloat( "spriterandomscale", 0.0f );
// sway is a percent of max sway, cl_detail_max_sway
float flSway = clamp( pIter->GetFloat( "sway", 0.0f ), 0.0, 1.0 );
model.m_SwayAmount = (unsigned char)( 255.0 * flSway );
//.........这里部分代码省略.........
示例11: CenterOnFace
void ControlPanel::CenterOnFace( void )
{
if ( !models->GetActiveStudioModel() )
return;
StudioModel *mdl = models->GetActiveStudioModel();
if ( !mdl )
return;
CStudioHdr *hdr = mdl->GetStudioHdr();
if ( !hdr )
return;
setSpeed( 1.0f );
int oldSeq = models->GetActiveStudioModel()->GetSequence();
int seq = models->GetActiveStudioModel()->LookupSequence( "idle_suble" );
if ( seq == -1 )
seq = 0;
if ( seq != oldSeq )
{
Con_Printf( "Centering changed model sequence # to %d\n", seq );
}
setSequence( seq );
initPoseParameters( );
mdl->m_angles.Init();
mdl->m_origin.Init();
Vector size;
VectorSubtract( hdr->hull_max(), hdr->hull_min(), size );
float eyeheight = hdr->hull_min().z + 0.9 * size.z;
if ( hdr->GetNumAttachments() > 0 )
{
for (int i = 0; i < hdr->GetNumAttachments(); i++)
{
const mstudioattachment_t &attachment = hdr->pAttachment( i );
int iBone = hdr->GetAttachmentBone( i );
if ( Q_stricmp( attachment.pszName(), "eyes" ) )
continue;
mstudiobone_t *bone = hdr->pBone( iBone );
if ( !bone )
continue;
matrix3x4_t boneToPose;
MatrixInvert( bone->poseToBone, boneToPose );
matrix3x4_t attachmentPoseToLocal;
ConcatTransforms( boneToPose, attachment.local, attachmentPoseToLocal );
Vector localSpaceEyePosition;
VectorITransform( vec3_origin, attachmentPoseToLocal, localSpaceEyePosition );
// Not sure why this must be negative?
eyeheight = -localSpaceEyePosition.z + hdr->hull_min().z;
break;
}
}
KeyValues *seqKeyValues = new KeyValues("");
if ( seqKeyValues->LoadFromBuffer( mdl->GetFileName( ), mdl->GetKeyValueText( seq ) ) )
{
// Do we have a build point section?
KeyValues *pkvAllFaceposer = seqKeyValues->FindKey("faceposer");
if ( pkvAllFaceposer )
{
float flEyeheight = pkvAllFaceposer->GetFloat( "eye_height", -9999.0f );
if ( flEyeheight != -9999.0f )
{
eyeheight = flEyeheight;
}
}
}
seqKeyValues->deleteThis();
mdl->m_origin.x = size.z * .65f;
mdl->m_origin.z += eyeheight;
CUtlVector< StudioModel * > modellist;
modellist.AddToTail( models->GetActiveStudioModel() );
int i;
if ( models->CountVisibleModels() > 0 )
{
modellist.RemoveAll();
for ( i = 0; i < models->Count(); i++ )
{
if ( models->IsModelShownIn3DView( i ) )
{
modellist.AddToTail( models->GetStudioModel( i ) );
}
//.........这里部分代码省略.........
示例12: Parse
//.........这里部分代码省略.........
iRumbleEffect = pKeyValuesData->GetInt("rumble", -1);
// LAME old way to specify item flags.
// Weapon scripts should use the flag names.
iFlags = pKeyValuesData->GetInt("item_flags", ITEM_FLAG_LIMITINWORLD);
for (int i = 0; i < ARRAYSIZE(g_ItemFlags); i++)
{
int iVal = pKeyValuesData->GetInt(g_ItemFlags[i].m_pFlagName, -1);
if (iVal == 0)
iFlags &= ~g_ItemFlags[i].m_iFlagValue;
else if (iVal == 1)
iFlags |= g_ItemFlags[i].m_iFlagValue;
}
bShowUsageHint = (pKeyValuesData->GetInt("showusagehint", 0) != 0) ? true : false;
bAutoSwitchTo = (pKeyValuesData->GetInt("autoswitchto", 1) != 0) ? true : false;
bAutoSwitchFrom = (pKeyValuesData->GetInt("autoswitchfrom", 1) != 0) ? true : false;
m_bBuiltRightHanded = (pKeyValuesData->GetInt("BuiltRightHanded", 1) != 0) ? true : false;
m_bAllowFlipping = (pKeyValuesData->GetInt("AllowFlipping", 1) != 0) ? true : false;
m_bMeleeWeapon = (pKeyValuesData->GetInt("MeleeWeapon", 0) != 0) ? true : false;
#if defined(_DEBUG) && defined(HL2_CLIENT_DLL)
// make sure two weapons aren't in the same slot & position
if ( iSlot >= MAX_WEAPON_SLOTS ||
iPosition >= MAX_WEAPON_POSITIONS )
{
Warning( "Invalid weapon slot or position [slot %d/%d max], pos[%d/%d max]\n",
iSlot, MAX_WEAPON_SLOTS - 1, iPosition, MAX_WEAPON_POSITIONS - 1 );
}
else
{
if (g_bUsedWeaponSlots[iSlot][iPosition])
{
Warning( "Duplicately assigned weapon slots in selection hud: %s (%d, %d)\n", szPrintName, iSlot, iPosition );
}
g_bUsedWeaponSlots[iSlot][iPosition] = true;
}
#endif
// Primary ammo used
const char *pAmmo = pKeyValuesData->GetString("primary_ammo", "None");
if (strcmp("None", pAmmo) == 0)
Q_strncpy(szAmmo1, "", sizeof(szAmmo1));
else
Q_strncpy(szAmmo1, pAmmo, sizeof(szAmmo1));
iAmmoType = GetAmmoDef()->Index(szAmmo1);
// Secondary ammo used
pAmmo = pKeyValuesData->GetString("secondary_ammo", "None");
if (strcmp("None", pAmmo) == 0)
Q_strncpy(szAmmo2, "", sizeof(szAmmo2));
else
Q_strncpy(szAmmo2, pAmmo, sizeof(szAmmo2));
iAmmo2Type = GetAmmoDef()->Index(szAmmo2);
// Now read the weapon sounds
memset(aShootSounds, 0, sizeof(aShootSounds));
KeyValues *pSoundData = pKeyValuesData->FindKey("SoundData");
if (pSoundData)
{
for (int i = EMPTY; i < NUM_SHOOT_SOUND_TYPES; i++)
{
const char *soundname = pSoundData->GetString(pWeaponSoundCategories[i]);
if (soundname && soundname[0])
Q_strncpy(aShootSounds[i], soundname, MAX_WEAPON_STRING);
}
}
// this just saves off the data in the script file for later use
KeyValues *pEt = pKeyValuesData->FindKey("Ironsight");
if (pEt)
{
m_expOffset.x = pEt->GetFloat("x", 0.0f);
m_expOffset.y = pEt->GetFloat("y", 0.0f);
m_expOffset.z = pEt->GetFloat("z", 0.0f);
m_expOriOffset.x = pEt->GetFloat("xori", 0.0f);
m_expOriOffset.y = pEt->GetFloat("yori", 0.0f);
m_expOriOffset.z = pEt->GetFloat("zori", 0.0f);
}
else
{
m_expOffset = vec3_origin;
m_expOriOffset.Init();
}
m_WeaponWeight = pKeyValuesData->GetFloat("weapon_weight", 0.0f);
}
示例13: SetupModel
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CModelPanel::SetupModel( void )
{
if ( !m_pModelInfo )
return;
MDLCACHE_CRITICAL_SECTION();
// remove any current models we're using
DeleteModelData();
const char *pszModelName = GetModelName();
if ( !pszModelName || !pszModelName[0] )
return;
// create the new model
CModelPanelModel *pEnt = new CModelPanelModel;
if ( !pEnt )
return;
if ( pEnt->InitializeAsClientEntity( pszModelName, false ) == false )
{
// we failed to initialize this entity so just return gracefully
pEnt->Remove();
return;
}
// setup the handle
m_hModel = pEnt;
pEnt->DontRecordInTools();
pEnt->AddEffects( EF_NODRAW ); // don't let the renderer draw the model normally
if ( m_pModelInfo->m_nSkin >= 0 )
{
pEnt->SetSkin( m_pModelInfo->m_nSkin );
}
// do we have any animation information?
if ( m_pModelInfo->m_Animations.Count() > 0 && m_pModelInfo->m_Animations.IsValidIndex( m_iDefaultAnimation ) )
{
CModelPanelModelAnimation *pAnim = m_pModelInfo->m_Animations[ m_iDefaultAnimation ];
int sequence = ACT_INVALID;
if ( pAnim->m_pszActivity && pAnim->m_pszActivity[0] )
{
Activity activity = (Activity)ActivityList_IndexForName( pAnim->m_pszActivity );
sequence = pEnt->SelectWeightedSequence( activity );
}
else if ( pAnim->m_pszSequence && pAnim->m_pszSequence[0] )
{
sequence = pEnt->LookupSequence( pAnim->m_pszSequence );
}
if ( sequence != ACT_INVALID )
{
pEnt->ResetSequence( sequence );
pEnt->SetCycle( 0 );
if ( pAnim->m_pPoseParameters )
{
for ( KeyValues *pData = pAnim->m_pPoseParameters->GetFirstSubKey(); pData != NULL; pData = pData->GetNextKey() )
{
const char *pName = pData->GetName();
float flValue = pData->GetFloat();
pEnt->SetPoseParameter( pName, flValue );
}
}
pEnt->m_flAnimTime = gpGlobals->curtime;
}
}
// setup any attached models
for ( int i = 0 ; i < m_pModelInfo->m_AttachedModelsInfo.Count() ; i++ )
{
CModelPanelAttachedModelInfo *pInfo = m_pModelInfo->m_AttachedModelsInfo[i];
C_BaseAnimating *pTemp = new C_BaseAnimating;
if ( pTemp )
{
if ( pTemp->InitializeAsClientEntity( pInfo->m_pszModelName, false ) == false )
{
// we failed to initialize this model so just skip it
pTemp->Remove();
continue;
}
pTemp->DontRecordInTools();
pTemp->AddEffects( EF_NODRAW ); // don't let the renderer draw the model normally
pTemp->FollowEntity( m_hModel.Get() ); // attach to parent model
if ( pInfo->m_nSkin >= 0 )
{
pTemp->SetSkin( pInfo->m_nSkin );
}
pTemp->m_flAnimTime = gpGlobals->curtime;
//.........这里部分代码省略.........
示例14: FindPoseCycle
//.........这里部分代码省略.........
{
const mstudioattachment_t &attachment = hdr->pAttachment( i );
int iBone = hdr->GetAttachmentBone( i );
if ( Q_stricmp( attachment.pszName(), "eyes" ) )
continue;
mstudiobone_t *bone = hdr->pBone( iBone );
if ( !bone )
continue;
matrix3x4_t boneToPose;
MatrixInvert( bone->poseToBone, boneToPose );
matrix3x4_t attachmentPoseToLocal;
ConcatTransforms( boneToPose, attachment.local, attachmentPoseToLocal );
Vector localSpaceEyePosition;
VectorITransform( vec3_origin, attachmentPoseToLocal, localSpaceEyePosition );
// Not sure why this must be negative?
eyeheight = -localSpaceEyePosition.z + hdr->hull_min().z;
break;
}
}
KeyValues *seqKeyValues = new KeyValues("");
if ( seqKeyValues->LoadFromBuffer( model->GetFileName( ), model->GetKeyValueText( sequence ) ) )
{
// Do we have a build point section?
KeyValues *pkvAllFaceposer = seqKeyValues->FindKey("faceposer");
if ( pkvAllFaceposer )
{
float flEyeheight = pkvAllFaceposer->GetFloat( "eye_height", -9999.0f );
if ( flEyeheight != -9999.0f )
{
eyeheight = flEyeheight;
}
}
}
model->m_origin.z += eyeheight;
}
else
{
Vector mins, maxs;
model->ExtractBbox(mins, maxs);
Vector size;
VectorSubtract( maxs, mins, size );
float maxdim = size.x;
if ( size.y > maxdim )
maxdim = size.y;
if ( size.z > maxdim )
maxdim = size.z;
float midpoint = mins.z + 0.5 * size.z;
model->m_origin.x = 3 * maxdim;
model->m_origin.z += midpoint;
}
pWnd->SuppressResize( true );
RECT rcClient;
HWND wnd = (HWND)pWnd->getHandle();
示例15: ReloadFontGlyphs
//.........这里部分代码省略.........
continue;
}
int flags = 0;
if (fontdata->GetInt( "italic" ))
{
flags |= ISurface::FONTFLAG_ITALIC;
}
if (fontdata->GetInt( "underline" ))
{
flags |= ISurface::FONTFLAG_UNDERLINE;
}
if (fontdata->GetInt( "strikeout" ))
{
flags |= ISurface::FONTFLAG_STRIKEOUT;
}
if (fontdata->GetInt( "symbol" ))
{
flags |= ISurface::FONTFLAG_SYMBOL;
}
if (fontdata->GetInt( "antialias" ) && g_pSurface->SupportsFeature(ISurface::ANTIALIASED_FONTS))
{
flags |= ISurface::FONTFLAG_ANTIALIAS;
}
if (fontdata->GetInt( "dropshadow" ) && g_pSurface->SupportsFeature(ISurface::DROPSHADOW_FONTS))
{
flags |= ISurface::FONTFLAG_DROPSHADOW;
}
if (fontdata->GetInt( "outline" ) && g_pSurface->SupportsFeature(ISurface::OUTLINE_FONTS))
{
flags |= ISurface::FONTFLAG_OUTLINE;
}
if (fontdata->GetInt( "custom" ))
{
flags |= ISurface::FONTFLAG_CUSTOM;
}
if (fontdata->GetInt( "bitmap" ))
{
flags |= ISurface::FONTFLAG_BITMAP;
}
if (fontdata->GetInt( "rotary" ))
{
flags |= ISurface::FONTFLAG_ROTARY;
}
if (fontdata->GetInt( "additive" ))
{
flags |= ISurface::FONTFLAG_ADDITIVE;
}
int tall = fontdata->GetInt("tall");
int blur = fontdata->GetInt("blur");
int scanlines = fontdata->GetInt("scanlines");
if ( (!fontYResMin && !fontYResMax) && m_FontAliases[i].m_bProportional ) // only grow this font if it doesn't have a resolution filter specified
{
tall = g_Scheme.GetProportionalScaledValueEx( this, tall );
blur = g_Scheme.GetProportionalScaledValueEx( this, blur );
scanlines = g_Scheme.GetProportionalScaledValueEx( this, scanlines );
}
// clip the font size so that fonts can't be too big
if (tall > 127)
{
tall = 127;
}
// check our minimum font height
if (tall < minimumFontHeight)
{
tall = minimumFontHeight;
}
if ( flags & ISurface::FONTFLAG_BITMAP )
{
// add the new set
g_pSurface->SetBitmapFontGlyphSet(
m_FontAliases[i]._font,
g_pSurface->GetBitmapFontName( fontdata->GetString( "name" ) ),
fontdata->GetFloat( "scalex", 1.0f ),
fontdata->GetFloat( "scaley", 1.0f ),
flags);
}
else
{
// add the new set
g_pSurface->SetFontGlyphSet(
m_FontAliases[i]._font,
fontdata->GetString( "name" ),
tall,
fontdata->GetInt( "weight" ),
blur,
scanlines,
flags);
}
// don't add any more
break;
}
}
}