Beispiel #1
0
//==============================
// SineFader::GetFinalAlpha
float SineFader::GetFinalAlpha() const
{
    // NOTE: pausing will still re-calculate the 
    if ( GetFadeState() == FADE_NONE )
    {
        return GetFadeAlpha();   // already clamped        
    }
    // map to sine wave
    float radians = ( 1.0f - GetFadeAlpha() ) * Mathf::Pi;  // range 0 to pi
    return ( cos( radians ) + 1.0f ) * 0.5f; // range 0 to 1
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeRing::UpdateColorValues( Instance& instance, const RingColorParameter& param, RingColorValues& values )
{
	if (param.type == RingColorParameter::Fixed)
	{
		values.original = values.fixed._color;
	}
	else if (param.type == RingColorParameter::Random)
	{
		values.original = values.random._color;
	}
	else if( param.type == RingColorParameter::Easing )
	{
		param.easing.setValueToArg(
			values.original, 
			values.easing.start,
			values.easing.end,
			instance.m_LivingTime / instance.m_LivedTime );
	}

	float fadeAlpha = GetFadeAlpha(instance);
	if (fadeAlpha != 1.0f)
	{
		values.original.a = (uint8_t)(values.original.a * fadeAlpha);
	}
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeRibbon::Rendering(const Instance& instance, Manager* manager)
{
	const InstanceValues& instValues = instance.rendererValues.ribbon;
	RibbonRenderer* renderer = manager->GetRibbonRenderer();
	if( renderer != NULL )
	{
		instValues._color.setValueToArg( m_instanceParameter.AllColor );
		m_instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43();

		color color_l = instValues._color;
		color color_r = instValues._color;

		if( RibbonColor.type == RibbonColorParameter::Default )
		{

		}
		else if( RibbonColor.type == RibbonColorParameter::Fixed )
		{
			color_l = color::mul( color_l, RibbonColor.fixed.l );
			color_r = color::mul( color_r, RibbonColor.fixed.r );
		}

		float fadeAlpha = GetFadeAlpha( instance );
		if( fadeAlpha != 1.0f )
		{
			color_l.a = (uint8_t)(color_l.a * fadeAlpha);
			color_r.a = (uint8_t)(color_r.a * fadeAlpha);
		}

		color_l.setValueToArg( m_instanceParameter.Colors[0] );
		color_r.setValueToArg( m_instanceParameter.Colors[1] );


		
		if( RibbonPosition.type == RibbonPositionParameter::Default )
		{
			m_instanceParameter.Positions[0] = -0.5f;
			m_instanceParameter.Positions[1] = 0.5f;
		}
		else if( RibbonPosition.type == RibbonPositionParameter::Fixed )
		{
			m_instanceParameter.Positions[0] = RibbonPosition.fixed.l;
			m_instanceParameter.Positions[1] = RibbonPosition.fixed.r;
		}

		renderer->Rendering( m_nodeParameter, m_instanceParameter, m_userData );

		m_instanceParameter.InstanceIndex++;
	}
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeRing::Rendering(const Instance& instance, Manager* manager)
{
	const InstanceValues& instValues = instance.rendererValues.ring;
	RingRenderer* renderer = manager->GetRingRenderer();
	if( renderer != NULL )
	{
		RingRenderer::NodeParameter nodeParameter;
		nodeParameter.EffectPointer = GetEffect();
		nodeParameter.AlphaBlend = AlphaBlend;
		nodeParameter.TextureFilter = Texture.FilterType;
		nodeParameter.TextureWrap = Texture.WrapType;
		nodeParameter.ZTest = Texture.ZTest;
		nodeParameter.ZWrite = Texture.ZWrite;
		nodeParameter.Billboard = Billboard;
		nodeParameter.VertexCount = VertexCount;
		nodeParameter.ColorTextureIndex = RingTexture;

		RingRenderer::InstanceParameter instanceParameter;
		instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43();

		instanceParameter.ViewingAngle = instValues.viewingAngle.current;
		
		instValues.outerLocation.current.setValueToArg( instanceParameter.OuterLocation );
		instValues.innerLocation.current.setValueToArg( instanceParameter.InnerLocation );

		instanceParameter.CenterRatio = instValues.centerRatio.current;

		instValues.outerColor.current.setValueToArg( instanceParameter.OuterColor );
		instValues.centerColor.current.setValueToArg( instanceParameter.CenterColor );
		instValues.innerColor.current.setValueToArg( instanceParameter.InnerColor );
		
		float fadeAlpha = GetFadeAlpha( instance );
		if( fadeAlpha != 1.0f )
		{
			instanceParameter.OuterColor.A = (uint8_t)(instanceParameter.OuterColor.A * fadeAlpha);
			instanceParameter.CenterColor.A = (uint8_t)(instanceParameter.CenterColor.A * fadeAlpha);
			instanceParameter.InnerColor.A = (uint8_t)(instanceParameter.InnerColor.A * fadeAlpha);
		}

		instanceParameter.UV = instance.GetUV();
		renderer->Rendering( nodeParameter, instanceParameter, m_userData );
	}
}
void CGumpEditorDoc::OnSettings()
{
	CGumpEditorView* pView = (CGumpEditorView*)FindView(RUNTIME_CLASS(CGumpEditorView));
	if (!pView) return;

	CDEditor& editor = pView->GetDEditor();

	CDialogSettings	dlg;

	dlg.m_width = editor.GetVirtualSize().cx;
	dlg.m_height = editor.GetVirtualSize().cy;
	dlg.m_gridWidth = editor.GetGridSize().cx;
	dlg.m_gridHeight = editor.GetGridSize().cy;
	editor.GetMargins( dlg.m_marginLeft, dlg.m_marginTop, dlg.m_marginRight, dlg.m_marginBottom );
	
	dlg.m_strName = GetName();
	dlg.m_iAlpha = GetAlpha();
	dlg.m_iFlags = GetFlags();
	dlg.m_iFadeAlpha = GetFadeAlpha();
	dlg.m_iFadeTime = GetFadeTime();
	dlg.m_strShapeName = GetShapeName();
	GetEventHandler(dlg.m_strEvClick, dlg.m_strEvClose, dlg.m_strEvMouseUp, dlg.m_strEvMouseDown, dlg.m_strEvKeyPressed);

	if( dlg.DoModal() == IDOK )
	{
		editor.SetGridSize( CSize( dlg.m_gridWidth, dlg.m_gridHeight ) );
		editor.SetVirtualSize( CSize( dlg.m_width, dlg.m_height ) );
		editor.SetMargins( dlg.m_marginLeft, dlg.m_marginTop, dlg.m_marginRight, dlg.m_marginBottom );
		
		SetName(dlg.m_strName);
		SetAlpha(dlg.m_iAlpha);
		SetFlags(dlg.m_iFlags);
		SetFade(dlg.m_iFadeAlpha, dlg.m_iFadeTime);
		SetShapeName(dlg.m_strShapeName);
		SetEventHandler(dlg.m_strEvClick, dlg.m_strEvClose, dlg.m_strEvMouseUp, dlg.m_strEvMouseDown, dlg.m_strEvKeyPressed);
		
		editor.RedrawWindow();
	}
}
BOOL CGumpEditorDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
	// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
	CStdioFile file;
	if (!file.Open(lpszPathName, CFile::modeCreate | CFile::modeWrite | CFile::typeText))
		return FALSE;
	
	CString str;
	CSize size = m_objs.GetVirtualSize();
	str = "<?xml version='1.0'?>\n";
	file.WriteString(str);

	str.Format("<form width='%d' height='%d' alpha='%d' flags='%d' shape='%s'>\n", size.cx, size.cy, GetAlpha(), GetFlags(), GetShapeName());
	file.WriteString( str );

	str.Format(" <fade alpha='%d' time='%d'/>\n", GetFadeAlpha(), GetFadeTime());
	file.WriteString(str);
	str.Format(" <event onclick='%s' onclose='%s' onmouseup='%s' onmousedown='%s' onkeypressed='%s'/>\n",
			GetEventHandler(ONCLICK), GetEventHandler(ONCLOSE), GetEventHandler(ONMOUSEUP), GetEventHandler(ONMOUSEDOWN), GetEventHandler(ONKEYPRESSED));
	file.WriteString(str);

	int count = 0;
	CDiagramEntity* obj;
	while( ( obj = m_objs.GetAt( count++ ) ) ) {
		file.WriteString( obj->GetString(TRUE) + _T( "\n" ) );
		file.WriteString( obj->GetString(FALSE) + _T( "\n" ) );
	}

	file.WriteString("</form>\n");

	file.Close();

	m_objs.SetModified( FALSE );

	SetModifiedFlag(FALSE);

	return TRUE;
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeModel::Rendering(const Instance& instance, Manager* manager)
{
	const InstanceValues& instValues = instance.rendererValues.model;
	ModelRenderer* renderer = manager->GetModelRenderer();
	if( renderer != NULL )
	{
		ModelRenderer::NodeParameter nodeParameter;
		nodeParameter.AlphaBlend = AlphaBlend;
		nodeParameter.TextureFilter = Texture.FilterType;
		nodeParameter.TextureWrap = Texture.WrapType;
		nodeParameter.ZTest = Texture.ZTest;
		nodeParameter.ZWrite = Texture.ZWrite;
		nodeParameter.EffectPointer = GetEffect();
		nodeParameter.ModelIndex = ModelIndex;
		nodeParameter.ColorTextureIndex = Texture.ColorTextureIndex;
		nodeParameter.Culling = Culling;
		nodeParameter.Lighting = Lighting;
		nodeParameter.NormalTextureIndex = NormalTextureIndex;
		nodeParameter.Magnification = m_effect->GetMaginification();
		nodeParameter.IsRightHand = manager->GetCoordinateSystem() ==
			COORDINATE_SYSTEM_RH;

		ModelRenderer::InstanceParameter instanceParameter;
		instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43();

		instanceParameter.UV = instance.GetUV();
		
		instValues._color.setValueToArg( instanceParameter.AllColor );
		float fadeAlpha = GetFadeAlpha( instance );
		if( fadeAlpha != 1.0f )
		{
			instanceParameter.AllColor.A = (uint8_t)(instanceParameter.AllColor.A * fadeAlpha);
		}

		renderer->Rendering( nodeParameter, instanceParameter, m_userData );
	}
}
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void EffectNodeSprite::Rendering(const Instance& instance, Manager* manager)
{
	const InstanceValues& instValues = instance.rendererValues.sprite;
	SpriteRenderer* renderer = manager->GetSpriteRenderer();
	if( renderer != NULL )
	{
		SpriteRenderer::NodeParameter nodeParameter;
		nodeParameter.AlphaBlend = AlphaBlend;
		nodeParameter.TextureFilter = Texture.FilterType;
		nodeParameter.TextureWrap = Texture.WrapType;
		nodeParameter.ZTest = Texture.ZTest;
		nodeParameter.ZWrite = Texture.ZWrite;
		nodeParameter.Billboard = Billboard;
		nodeParameter.ColorTextureIndex = SpriteTexture;
		nodeParameter.EffectPointer = GetEffect();

		SpriteRenderer::InstanceParameter instanceParameter;
		instValues._color.setValueToArg( instanceParameter.AllColor );
		instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43();

		color color_ll = instValues._color;
		color color_lr = instValues._color;
		color color_ul = instValues._color;
		color color_ur = instValues._color;

		if( SpriteColor.type == SpriteColorParameter::Default )
		{
		}
		else if( SpriteColor.type == SpriteColorParameter::Fixed )
		{
			color_ll = color::mul( color_ll, SpriteColor.fixed.ll );
			color_lr = color::mul( color_lr, SpriteColor.fixed.lr );
			color_ul = color::mul( color_ul, SpriteColor.fixed.ul );
			color_ur = color::mul( color_ur, SpriteColor.fixed.ur );
		}

		float fadeAlpha = GetFadeAlpha( instance );
		if( fadeAlpha != 1.0f )
		{
			color_ll.a = (uint8_t)(color_ll.a * fadeAlpha);
			color_lr.a = (uint8_t)(color_lr.a * fadeAlpha);
			color_ul.a = (uint8_t)(color_ul.a * fadeAlpha);
			color_ur.a = (uint8_t)(color_ur.a * fadeAlpha);
		}

		color_ll.setValueToArg( instanceParameter.Colors[0] );
		color_lr.setValueToArg( instanceParameter.Colors[1] );
		color_ul.setValueToArg( instanceParameter.Colors[2] );
		color_ur.setValueToArg( instanceParameter.Colors[3] );
		

		if( SpritePosition.type == SpritePosition.Default )
		{
			instanceParameter.Positions[0].X = -0.5f;
			instanceParameter.Positions[0].Y = -0.5f;
			instanceParameter.Positions[1].X = 0.5f;
			instanceParameter.Positions[1].Y = -0.5f;
			instanceParameter.Positions[2].X = -0.5f;
			instanceParameter.Positions[2].Y = 0.5f;
			instanceParameter.Positions[3].X = 0.5f;
			instanceParameter.Positions[3].Y = 0.5f;
		}
		else if( SpritePosition.type == SpritePosition.Fixed )
		{
			SpritePosition.fixed.ll.setValueToArg( instanceParameter.Positions[0] );
			SpritePosition.fixed.lr.setValueToArg( instanceParameter.Positions[1] );
			SpritePosition.fixed.ul.setValueToArg( instanceParameter.Positions[2] );
			SpritePosition.fixed.ur.setValueToArg( instanceParameter.Positions[3] );
		}

		instanceParameter.UV = instance.GetUV();
		renderer->Rendering( nodeParameter, instanceParameter, m_userData );
	}
}
//-----------------------------------------------------------------------------
// Purpose: Render the effect
//-----------------------------------------------------------------------------
void CEP1IntroEffect::Render( int x, int y, int w, int h )
{
	if ( ( m_flFinishTime == 0 ) || ( IsEnabled() == false ) )
		return;

	IMaterial *pMaterial = materials->FindMaterial( "effects/introblur", TEXTURE_GROUP_CLIENT_EFFECTS, true );
	if ( pMaterial == NULL )
		return;

	// Set ourselves to the proper rendermode
	materials->MatrixMode( MATERIAL_VIEW );
	materials->PushMatrix();
	materials->LoadIdentity();
	materials->MatrixMode( MATERIAL_PROJECTION );
	materials->PushMatrix();
	materials->LoadIdentity();

	// Get our current view
	if ( m_pStunTexture == NULL )
	{
		m_pStunTexture = GetWaterRefractionTexture();
	}

	// Draw the texture if we're using it
	if ( m_pStunTexture != NULL )
	{
		bool foundVar;
		IMaterialVar* pBaseTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false );

		if ( m_bUpdateView )
		{
			// Save off this pass
			Rect_t srcRect;
			srcRect.x = x;
			srcRect.y = y;
			srcRect.width = w;
			srcRect.height = h;
			pBaseTextureVar->SetTextureValue( m_pStunTexture );

			materials->CopyRenderTargetToTextureEx( m_pStunTexture, 0, &srcRect, NULL );
			materials->SetFrameBufferCopyTexture( m_pStunTexture );
			m_bUpdateView = false;
		}

		byte overlaycolor[4] = { 255, 255, 255, 0 };
		
		// Get our fade value depending on our fade duration
		overlaycolor[3] = GetFadeAlpha();

		// Disable overself if we're done fading out
		if ( m_bFadeOut && overlaycolor[3] == 0 )
		{
			// Takes effect next frame (we don't want to hose our matrix stacks here)
			g_pScreenSpaceEffects->DisableScreenSpaceEffect( "episodic_intro" );
			m_bUpdateView = true;
		}

		// Calculate some wavey noise to jitter the view by
		float vX = 2.0f * -fabs( cosf( gpGlobals->curtime ) * cosf( gpGlobals->curtime * 6.0 ) );
		float vY = 2.0f * cosf( gpGlobals->curtime ) * cosf( gpGlobals->curtime * 5.0 );

		// Scale percentage
		float flScalePerc = 0.02f + ( 0.01f * cosf( gpGlobals->curtime * 2.0f ) * cosf( gpGlobals->curtime * 0.5f ) );
		
		// Scaled offsets for the UVs (as texels)
		float flUOffset = ( m_pStunTexture->GetActualWidth() - 1 ) * flScalePerc * 0.5f;
		float flVOffset = ( m_pStunTexture->GetActualHeight() - 1 ) * flScalePerc * 0.5f;
		
		// New UVs with scaling offsets
		float flU1 = flUOffset;
		float flU2 = ( m_pStunTexture->GetActualWidth() - 1 ) - flUOffset;
		float flV1 = flVOffset;
		float flV2 = ( m_pStunTexture->GetActualHeight() - 1 ) - flVOffset;

		// Draw the "zoomed" overlay
		materials->DrawScreenSpaceRectangle( pMaterial, vX, vY, w, h,
			flU1, flV1, 
			flU2, flV2, 
			m_pStunTexture->GetActualWidth(), m_pStunTexture->GetActualHeight() );

		render->ViewDrawFade( overlaycolor, pMaterial );

		// Save off this pass
		Rect_t srcRect;
		srcRect.x = x;
		srcRect.y = y;
		srcRect.width = w;
		srcRect.height = h;
		pBaseTextureVar->SetTextureValue( m_pStunTexture );

		materials->CopyRenderTargetToTextureEx( m_pStunTexture, 0, &srcRect, NULL );
	}

	// Restore our state
	materials->MatrixMode( MATERIAL_VIEW );
	materials->PopMatrix();
	materials->MatrixMode( MATERIAL_PROJECTION );
	materials->PopMatrix();
}
//-----------------------------------------------------------------------------
// Purpose: Render the effect
//-----------------------------------------------------------------------------
void CEP2StunEffect::Render( int x, int y, int w, int h )
{
	if ( ( m_flFinishTime == 0 ) || ( IsEnabled() == false ) )
		return;

	CMatRenderContextPtr pRenderContext( materials );

	// Set ourselves to the proper rendermode
	pRenderContext->MatrixMode( MATERIAL_VIEW );
	pRenderContext->PushMatrix();
	pRenderContext->LoadIdentity();
	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->PushMatrix();
	pRenderContext->LoadIdentity();

	if ( m_bUpdateView )
	{
		// Save off this pass
		Rect_t srcRect;
		srcRect.x = x;
		srcRect.y = y;
		srcRect.width = w;
		srcRect.height = h;
		pRenderContext->CopyRenderTargetToTextureEx( m_StunTexture, 0, &srcRect, NULL );
		m_bUpdateView = false;
	}

	byte overlaycolor[4] = { 255, 255, 255, 0 };

	// Get our fade value depending on our fade duration
	overlaycolor[3] = GetFadeAlpha();

	// Disable overself if we're done fading out
	if ( m_bFadeOut && overlaycolor[3] == 0 )
	{
		// Takes effect next frame (we don't want to hose our matrix stacks here)
		g_pScreenSpaceEffects->DisableScreenSpaceEffect( "ep2_groggy" );
		m_bUpdateView = true;
	}

	// Calculate some wavey noise to jitter the view by
	float vX = 4.0f * cosf( gpGlobals->curtime ) * cosf( gpGlobals->curtime * 6.0 );
	float vY = 2.0f * cosf( gpGlobals->curtime ) * cosf( gpGlobals->curtime * 5.0 );

	float flBaseScale = 0.2f + 0.005f * sinf( gpGlobals->curtime * 4.0f );

	// Scale percentage
	float flScalePerc = flBaseScale + ( 0.01f * cosf( gpGlobals->curtime * 2.0f ) * cosf( gpGlobals->curtime * 0.5f ) );

    // Scaled offsets for the UVs (as texels)
	float flUOffset = ( m_StunTexture->GetActualWidth() - 1 ) * flScalePerc * 0.5f;
	float flVOffset = ( m_StunTexture->GetActualHeight() - 1 ) * flScalePerc * 0.5f;

	// New UVs with scaling offsets
	float flU1 = flUOffset;
	float flU2 = ( m_StunTexture->GetActualWidth() - 1 ) - flUOffset;
	float flV1 = flVOffset;
	float flV2 = ( m_StunTexture->GetActualHeight() - 1 ) - flVOffset;

	// Draw the "zoomed" overlay
	pRenderContext->DrawScreenSpaceRectangle( m_EffectMaterial, vX, vY, w, h,
		flU1, flV1, 
		flU2, flV2, 
		m_StunTexture->GetActualWidth(), m_StunTexture->GetActualHeight() );

	render->ViewDrawFade( overlaycolor, m_EffectMaterial );

	// Save off this pass
	Rect_t srcRect;
	srcRect.x = x;
	srcRect.y = y;
	srcRect.width = w;
	srcRect.height = h;
	pRenderContext->CopyRenderTargetToTextureEx( m_StunTexture, 0, &srcRect, NULL );

	// Restore our state
	pRenderContext->MatrixMode( MATERIAL_VIEW );
	pRenderContext->PopMatrix();
	pRenderContext->MatrixMode( MATERIAL_PROJECTION );
	pRenderContext->PopMatrix();
}