Sgt. Conker We are "absolutely fine"

15Mar/100

XNA 4.0 MultiEffect

X-Tatic has created a wrapper for all 4 built in effect types in XNA 4.0

What this means is that you can store a single type of effect yet have it be any one of the four included effect types, while still having access to all of the properties that any of the underlying effects expose.

The reason for MultiEffect is that its useful to use an effect without trying to figure out which of the 4 types it is and which properties/methods to call. You can call any of them, regardless of whether the effect implements them.

How To Use:
// to create a MultiEffect
MultiEffect effect = new MultiEffect(); // this defaults to BasicEffect

// or via any one of the built in effects
MultiEffect effect = builtInEffect.ToMultiEffect();

// you can access the underlying Effect
Effect effect = multiEffect.Effect;

// or explicitly cast it
Effect effect = (Effect)multiEffect;

// Finally, you can query the type
MultiEffectType effectType = multiEffect.CurrentType;

Download the binaries: http://www.xtaticware.com/downloads/XNA4MultiEffect.zip

or the source: http://www.xtaticware.com/downloads/XNA4MultiEffectSource.zip (MS-PL)

About CorporalX

Professional XNA/.NET developer.
Filed under: 3D, Shaders, WP7, XNA Leave a comment
Comments (0) Trackbacks (1)

Leave a comment


*