Nov 14, 2009 at 4:10 PM

Just a note,

I've put up a documentation CHM for 1.7. It's on the releases page. It's a tad more up to date than the old 1.0 CHM ;-)

It's one of those things that is really annoying and fiddly to build. I'm uploading the html's as well but that'll take 5 hours because it's something like 4,000 files :-D

Nov 16, 2009 at 8:50 PM



First, many thanks for XEN API,keeep up the good work man and i hope you enjoy living in UK (i am living in Sweden btw).

However, concerning the CHM, it does not display the compiled HTML documents (atleast not on my computer).Seems to be some issue with the Adress/URL.

I am new to XNA (and C# aswell) but i have a question concerning mesh effects in Xen. I have seen the tutorials and the material/Shader effetcs but my model (.x loaded with the Xen content processor) does not have any material, but i would like to enable similar XNA effetcs



foreach (ModelMesh mesh in model.Meshes)
                    foreach (BasicEffect effect in mesh.Effects)
                        effect.PreferPerPixelLighting = true;
                        effect.SpecularPower = 4;
  How can i do that i XEN ?


Also, i am not sure i understand the hole vertexBuffer Vs Load content processor debate. My models contain a lot of vertices (CAD models). I guess using index and vertexbuffers enables you to draw multiple buffers but how does


handles larger models or will the device quit if the drawTarget for the model is to big ?


Thanks and have a nice day!



Nov 26, 2009 at 5:04 PM

Anyone still here ??

In any case,if you have problem with the CHM (like me) this will fix it. You need to close the file, right click and select properties. On there in the bottom right hand corner is a nice little Unblock button.

Still i would like to know how to access the meshes and set defaultlighting.



Nov 27, 2009 at 7:22 AM
Edited Nov 27, 2009 at 7:22 AM

BasicEffect does not exist in Xen.  Instead of, there is MaterialShader to similar XNA BasicEffect.

MaterialShader is explained in Tutorial 02 "Draw sphere" (near line 71)

Nov 27, 2009 at 9:27 PM
Edited Nov 27, 2009 at 9:54 PM

Hi and thanks for that KKC. Hm..guess i was blind not to see that but i am not able to make it work on a ModelInstances, do i need to use model.SetShaderOverride instead of default shader.


first i copied the material shader and its properties from sphere tutorial 2 and set shader.Bind(state) in the (model.CullTest(state)). I am trying to make the shader work for tutorial 10 with my model.

So the shader goes into the Actor class. Still it is only show the default shader on.

Then i searched the forum and saw you old topic with the replay from statusunkown

var shaderProvider = new ModelInstanceShaderProvider(material);

i guess this would fix it, however i can't compile it, seem to missing some reference so Xen.Ex.Graphics.ModelnstanceShaderProvider ?!

i am using Xen.Ex.Graphics and the only ref i find is the shadersystem in xen.Graphics;



Any ideas ?



Nov 28, 2009 at 2:31 AM

Here is Actor Class that I edited. This class draws Model data with Default Lighting. I referenced Original Actor Class from Tutorial 10 "Model Instance".

class Actor : IDraw, IContentOwner
        private ModelInstance model;
        private Matrix worldMatrix;
        private MaterialLightCollection lights;

        public Actor(ContentRegister content, Vector3 position)
            Matrix.CreateTranslation(ref position, out this.worldMatrix);

            model = new ModelInstance();

            lights = new MaterialLightCollection();

            Vector3 lightDirection = new Vector3(0.5f, 1, -0.5f); //a dramatic direction

            // Default Light Collection ( From Tutorial 2 "Draw Sphere"). Edit this Light Parameter.
            lights.AmbientLightColour = Color.White.ToVector3() * 0.9f;	//set the ambient
            lights.AddDirectionalLight(true, lightDirection, Color.White);  //add the first of two light sources
            lights.AddDirectionalLight(true, -lightDirection, Color.White);

            // Add lights to Model.
            model.LightCollection = lights;

            //add to the content register

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

            //ModelData stores accurate bounding box information
            //the ModelInstance uses this to cull the model
            if (model.CullTest(state))


        public void LoadContent(ContentRegister content, DrawState state, ContentManager manager)
            //load the model data into the model instance (This is Sample path in Tutorial. Edit path for your model.)
            model.ModelData = manager.Load<Xen.Ex.Graphics.Content.ModelData>(@"tiny_4anim");

        public void UnloadContent(ContentRegister content, DrawState state)

        public bool CullTest(ICuller culler)
            return true;
Nov 28, 2009 at 11:23 AM

Wow,Thank kkc for all your help, that is much better.In fact it is good enough but...just to understand what we are doing here. We are just adding a lightcollection to the default shader no ?

So,features like UsePerPixelSpecular etc can not be set on this.shader if not declaring a new MaterialShader? Which is what seems to be non-working with sinply the bind method and.

Thank you and have a nice day!




Nov 28, 2009 at 11:43 AM

Yes.  Xen Model Instance has LightCollection property. this property provide easy drawing with Basic shader. This is very simple.

You can get a detail information from documentation CHM for 1.7, "ModelInstance Members" Section.

Nov 30, 2009 at 12:56 PM

Internally, the model data stores a set of meshes, each of which stores a bit of geometry. Each Geometry has a MaterialShader associated with it (which basically is a definition of material, texture, normal map, specular, diffuse, etc).~
When you set the light collection on the model instance, it will use that light collection with the material shaders in the model data. Unless you specify a shader provider, in which case those shaders will be used.
You can edit the material shaders directly, by diving into the ModelData - but this is a global change which will affect all model instances using that model data.

Nov 30, 2009 at 8:57 PM


Thanks a million, that ModelData did the trick. Great,also great use of many of the mesh properties.


 if (model.CullTest(state))

            foreach (var mesh in model.ModelData.Meshes)
                foreach (var geometry in mesh.Geometry)
                    geometry.Vertices.Draw(state, geometry.Indices, PrimitiveType.TriangleList);

I am still confused about how you handle the meshes inside the ModelData with this Load content processor,for instance,is there hard limit on the number of vertices by doing it this way ?

Do you automatically split ut up into multiple buffers if the model is to big,basically making the graphic card to the bottleneck ?

I have tried alot of softwares for indie-game development and it seems to me that i always end up in crashes because the modelsize (not the polygons) but the vertecis just kills the application.I dont know why but many of them are limited to 65k.

I am trying to do a virtual training application,do you think Xen is a good choise for the graphics ? (well, might be a bit hard to answer) but i there are some pick classes and tutorials around which i assume can be used with Xen built geometry equally as ordinary XNA,right ?




Dec 1, 2009 at 9:25 AM
Edited Dec 1, 2009 at 9:26 AM

Internally, ModelData just wraps what the XNA content pipeline (FBX importer, etc) output. So I don't do anything special to deal with large vertex buffers. All XNA gives you is a raw data array, which makes this a tad difficult anyway.

Picking a model is exceptionally difficult in any API, however, xen does store bounding boxes per bone in the model, you can see this in the advanced model use tutorial. These would probably be more than accurate enough for a lot of picking tasks. Ignoring the really small ones of course (things like fingers). If you are meaning more complex per-polygon picking for static meshes, well, this sort of problem is always quite difficult to deal with - and xen doesn't have any built in capability for this sort of thing.