How to force Backculling with a Cube?

Jul 25, 2009 at 9:58 PM
Edited Jul 25, 2009 at 9:59 PM

Hi StatusUnknown,

Could you please give me a small hand with the Cube and MaterialShader classes?

I'm trying to use both to render a skycube but I cannot get a way to force backculling so that textures are rendered either face of the cube (internal or external).

Here is my current code for testing purposes:


/// <summary>
/// </summary>
public class Nebulae : IDraw, IContentOwner
#region Fields
private Cube p_Cube;
private MaterialShader p_NebulaeMaterial;
private Matrix p_WorldMatrix;

#region Initialization
public Nebulae(ContentRegister contentRegister)
if (contentRegister == null)
throw new ArgumentNullException();

p_NebulaeMaterial = new MaterialShader();
p_NebulaeMaterial.Lights = new MaterialLightCollection();
p_NebulaeMaterial.Lights.AmbientLightColour = Color.White.ToVector3();
p_NebulaeMaterial.TextureMapSampler = TextureSamplerState.AnisotropicHighFiltering;

p_WorldMatrix = Matrix.CreateTranslation(new Vector3(0, 0, -5));

p_Cube = new Cube(new Vector3(5f));


#region IDraw Members

public void Draw(DrawState state)
state.PushWorldMatrix(ref p_WorldMatrix);





#region ICullable Members

public bool CullTest(ICuller culler)
return true;


#region IContentOwner Members

public void LoadContent(ContentRegister content, DrawState state, Microsoft.Xna.Framework.Content.ContentManager manager)
p_NebulaeMaterial.TextureMap = manager.Load<Texture2D>("nebulae");

public void UnloadContent(ContentRegister content, DrawState state)



Jul 26, 2009 at 1:01 AM

state.RenderState.DepthColourCull.CullMode is what you are after.
Good luck

Jul 26, 2009 at 10:34 PM

Thank you StatusUnknown, that made the trick I was looking for... I think I'm getting now used to the overall Xen mechanics :)

At first, I was looking for a basis for a game engine which Xen is not even if you provide the core functions for it. However, I find it very easy to use as soon as you get to understand how it is built inside (and the source code gets very handy in such occasions ;)).

Thanks again for bringing that knowledge to us.