void CMaterialModifyProxy::OnBind( void *pEntity ) { // Get the modified material vars from the entity input IClientRenderable *pRend = (IClientRenderable *)pEntity; if ( pRend ) { C_BaseEntity *pBaseEntity = pRend->GetIClientUnknown()->GetBaseEntity(); if ( pBaseEntity ) { if( debug_materialmodifycontrol_client.GetBool() ) { // DevMsg( 1, "%s\n", pBaseEntity->GetDebugName() ); } int numChildren = 0; bool gotOne = false; for ( C_BaseEntity *pChild = pBaseEntity->FirstMoveChild(); pChild; pChild = pChild->NextMovePeer() ) { numChildren++; C_MaterialModifyControl *pControl = dynamic_cast<C_MaterialModifyControl*>( pChild ); if ( !pControl ) continue; if( debug_materialmodifycontrol_client.GetBool() ) { // DevMsg( 1, "pControl: 0x%p\n", pControl ); } switch( pControl->GetModifyMode() ) { case MATERIAL_MODIFY_MODE_NONE: break; case MATERIAL_MODIFY_MODE_SETVAR: gotOne = true; OnBindSetVar( pControl ); break; case MATERIAL_MODIFY_MODE_ANIM_SEQUENCE: OnBindAnimatedTexture( pControl ); break; case MATERIAL_MODIFY_MODE_FLOAT_LERP: OnBindFloatLerp( pControl ); break; default: Assert( 0 ); break; } } if( gotOne ) { // DevMsg( 1, "numChildren: %d\n", numChildren ); } } } if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
void CShieldPowerLevelProxy::OnBind( void *pRenderable ) { IClientRenderable *pRend = (IClientRenderable *)pRenderable; C_BaseEntity *pEntity = pRend->GetIClientUnknown()->GetBaseEntity(); C_Shield *pShield = dynamic_cast<C_Shield*>(pEntity); if (!pShield) return; SetFloatResult( pShield->GetPowerLevel() ); }
//----------------------------------------------------------------------------- // Helper class to deal with floating point inputs //----------------------------------------------------------------------------- void CEntityMaterialProxy::OnBind( void *pRenderable ) { if( !pRenderable ) return; IClientRenderable *pRend = (IClientRenderable *)pRenderable; C_BaseEntity *pEnt = pRend->GetIClientUnknown()->GetBaseEntity(); if (pEnt) { OnBind(pEnt); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CMaterialModifyAnimatedProxy::AnimationWrapped( void* pArg ) { IClientRenderable *pRend = (IClientRenderable *)pArg; if (!pRend) return; C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity(); if (pEntity) { pEntity->TextureAnimationWrapped(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- float CMaterialModifyAnimatedProxy::GetAnimationStartTime( void* pArg ) { IClientRenderable *pRend = (IClientRenderable *)pArg; if (!pRend) return 0.0f; C_BaseEntity* pEntity = pRend->GetIClientUnknown()->GetBaseEntity(); if (pEntity) { return pEntity->GetTextureAnimationStartTime(); } return 0.0f; }
void CTeamColorProxy::OnBind( void *pRenderable ) { if( !pRenderable || !m_pColorTextureVar ) return; IClientRenderable *pRend = ( IClientRenderable* )pRenderable; C_BaseEntity *pEnt = pRend->GetIClientUnknown()->GetBaseEntity(); if ( !pEnt ) return; Vector &teamcolor = pEnt->GetTeamColor(); m_pColorTextureVar->SetVecValue(teamcolor[0], teamcolor[1], teamcolor[2], 1); }
//----------------------------------------------------------------------------- // Helper class to deal with floating point inputs //----------------------------------------------------------------------------- void CEntityMaterialProxy::OnBind( void *pRenderable ) { if( !pRenderable ) return; IClientRenderable *pRend = ( IClientRenderable* )pRenderable; C_BaseEntity *pEnt = pRend->GetIClientUnknown()->GetBaseEntity(); if ( pEnt ) { OnBind( pEnt ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } } }
void CObjectPowerProxy::OnBind( void *pRenderable ) { // Find the view angle between the player and this entity.... IClientRenderable *pRend = (IClientRenderable *)pRenderable; C_BaseEntity *pEntity = pRend->GetIClientUnknown()->GetBaseEntity(); C_BaseObject *pObject = dynamic_cast<C_BaseObject*>(pEntity); if (!pObject) return; SetFloatResult( m_Factor.GetFloat() ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
//----------------------------------------------------------------------------- // Purpose: Create the matrix by which we'll transform the particle's local // space into world space, via the attachment's transform //----------------------------------------------------------------------------- void CLocalSpaceEmitter::SetupTransformMatrix( void ) { IClientRenderable *pRenderable = ClientEntityList().GetClientRenderableFromHandle( m_hEntity ); if ( pRenderable ) { matrix3x4_t mat; if ( pRenderable->GetAttachment( m_nAttachment, mat ) == false ) { // This attachment is bogus! Assert(0); } // Tell the particle effect so it knows Vector origin; MatrixGetColumn( mat, 3, origin ); m_ParticleEffect.SetLocalSpaceTransform( mat ); SetSortOrigin( origin ); C_BaseEntity *pEnt = pRenderable->GetIClientUnknown()->GetBaseEntity(); if ( pEnt ) { Vector vWorldMins, vWorldMaxs; float scale = pEnt->CollisionProp()->BoundingRadius(); vWorldMins[0] = origin[0] - scale; vWorldMins[1] = origin[1] - scale; vWorldMins[2] = origin[2] - scale; vWorldMaxs[0] = origin[0] + scale; vWorldMaxs[1] = origin[1] + scale; vWorldMaxs[2] = origin[2] + scale; GetBinding().SetBBox( vWorldMins, vWorldMaxs, true ); } } // We preapply the local transform because we need to squash it for viewmodel FOV. m_ParticleEffect.SetAutoApplyLocalTransform( false ); }
//----------------------------------------------------------------------------- // Does the dirty deed //----------------------------------------------------------------------------- void CMaterialModifyAnimatedProxy::OnBind( void *pEntity ) { assert ( m_AnimatedTextureVar ); if( m_AnimatedTextureVar->GetType() != MATERIAL_VAR_TYPE_TEXTURE ) return; ITexture *pTexture; pTexture = m_AnimatedTextureVar->GetTextureValue(); // Get the modified material vars from the entity input IClientRenderable *pRend = (IClientRenderable *)pEntity; if ( pRend ) { C_BaseEntity *pBaseEntity = pRend->GetIClientUnknown()->GetBaseEntity(); if ( pBaseEntity ) { for ( C_BaseEntity *pChild = pBaseEntity->FirstMoveChild(); pChild; pChild = pChild->NextMovePeer() ) { C_MaterialModifyControl *pControl = dynamic_cast<C_MaterialModifyControl*>( pChild ); if ( !pControl ) continue; if ( !pControl->HasNewAnimationCommands() ) continue; // Read the data from the modify entity materialanimcommands_t sCommands; pControl->GetAnimationCommands( &sCommands ); m_iFrameStart = sCommands.iFrameStart; m_iFrameEnd = sCommands.iFrameEnd; m_bCustomWrap = sCommands.bWrap; m_flCustomFramerate = sCommands.flFrameRate; m_bReachedEnd = false; m_flStartTime = gpGlobals->curtime; pControl->ClearAnimationCommands(); } } } // Init all the vars based on whether we're using the base material settings, // or the custom ones from the entity input. int numFrames; bool bWrapAnimation; float flFrameRate; int iLastFrame; // Do we have a custom frame section from the server? if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET ) { if ( m_iFrameEnd == MATERIAL_MODIFY_ANIMATION_UNSET ) { m_iFrameEnd = pTexture->GetNumAnimationFrames(); } numFrames = (m_iFrameEnd - m_iFrameStart) + 1; bWrapAnimation = m_bCustomWrap; flFrameRate = m_flCustomFramerate; iLastFrame = (m_iFrameEnd - 1); } else { numFrames = pTexture->GetNumAnimationFrames(); bWrapAnimation = m_WrapAnimation; flFrameRate = m_FrameRate; iLastFrame = (numFrames - 1); } // Have we already reached the end? If so, stay there. if ( m_bReachedEnd && !bWrapAnimation ) { m_AnimatedTextureFrameNumVar->SetIntValue( iLastFrame ); return; } // NOTE: Must not use relative time based methods here // because the bind proxy can be called many times per frame. // Prevent multiple Wrap callbacks to be sent for no wrap mode float startTime; if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET ) { startTime = m_flStartTime; } else { startTime = GetAnimationStartTime(pEntity); } float deltaTime = gpGlobals->curtime - startTime; float prevTime = deltaTime - gpGlobals->frametime; // Clamp.. if (deltaTime < 0.0f) deltaTime = 0.0f; if (prevTime < 0.0f) prevTime = 0.0f; float frame = flFrameRate * deltaTime; float prevFrame = flFrameRate * prevTime; int intFrame = ((int)frame) % numFrames; int intPrevFrame = ((int)prevFrame) % numFrames; if ( m_iFrameStart != MATERIAL_MODIFY_ANIMATION_UNSET ) { intFrame += m_iFrameStart; intPrevFrame += m_iFrameStart; } // Report wrap situation... if (intPrevFrame > intFrame) { m_bReachedEnd = true; if (bWrapAnimation) { AnimationWrapped( pEntity ); } else { // Only sent the wrapped message once. // when we're in non-wrapping mode if (prevFrame < numFrames) AnimationWrapped( pEntity ); intFrame = numFrames - 1; } } m_AnimatedTextureFrameNumVar->SetIntValue( intFrame ); if ( ToolsEnabled() ) { ToolFramework_RecordMaterialParams( GetMaterial() ); } }
C_BaseEntity *CConveyorMaterialProxy::BindArgToEntity( void *pArg ) { IClientRenderable *pRend = (IClientRenderable *)pArg; return pRend->GetIClientUnknown()->GetBaseEntity(); }
C_BaseEntity *CResultProxy::BindArgToEntity( void *pArg ) { IClientRenderable *pRend = (IClientRenderable *)pArg; return pRend->GetIClientUnknown()->GetBaseEntity(); }
C_BaseEntity *C_BloodyTextureProxy::BindArgToEntity(void *pArg) { IClientRenderable *pRend = (IClientRenderable *)pArg; return pRend ? pRend->GetIClientUnknown()->GetBaseEntity() : NULL; }