Can't get vertices from loaded mesh

May 1, 2010 at 7:32 PM

I'm trying to access mesh data:

            _model = ContentManager.Load<Mesh>(resourceString);

//... model is shown in Game ...

            Mesh mesh = _model;
            IGeometryContext g = mesh.GeometryContext;
            Material material = mesh.Material;
            Vertex[] vertices = g.GetVertices();

//... yet both 'material' and 'vertices' are set to null

Should this work, or maybe I'm doing something wrong? I'm using 0.8.8.6 version.

And other qustion: if I load silverlight assembly dynamicly, will I be able to initialize mesh from ASE file in its resources?

Thx

Coordinator
May 3, 2010 at 12:47 PM

By resourceString, do you mean you're trying to give it the string containing the ASE file? It must be loaded from a file embedded in the XAP as a resource.

The Material property on mesh is more for applying a material to a Mesh, as a Mesh can have multiple materials when loading from a file. The materials are present on the Faces.

 

For your last question - loading ASE files from another assemblies resources; as long as you use the "/<component>;component/<path to ase file>" format, you are ok. 

May 3, 2010 at 2:34 PM
1 Yep, I mean something like this ("/<component>;component/<path to ase file>"). And it is loaded for sure, as it is rendered in the Game. Yet when I try "Vertex[] vertices = mesh.GetVertices();" i get null (in debug after completion of this code the value of "vertices" is null), 2 And how can I get textures, applied to model? I thought it is possible through mesh.Material.
Coordinator
May 4, 2010 at 7:03 AM

Odd that it is null.    In the latest Balder source code this has been rewritten, and the API has changed as well, so you might want to check it out. 

If you want to apply a texture to the entire Mesh, you can set the Material property on your mesh and it will apply for the entire mesh. On Material you have DiffuseMap which holds the texture.  If you download the latest source and open the SampleBrowser.sln file and navigate to the Material sample under Programatic, you'll see you how you can do it all.

May 4, 2010 at 9:57 AM
I'll try that, thx.
May 10, 2010 at 2:16 PM
Edited May 10, 2010 at 2:21 PM

I got latest source code and referenced new libraries. Yet now when my Game initialises it throws an exception in InitializeComponent(); :

{System.Windows.Markup.XamlParseException: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.Module.GetTypes(IntPtr module, StackCrawlMark& stackMark) at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at System.Reflection.Module.GetTypes(StackCrawlMark& stackMark) at System.Reflection.Assembly.GetTypes() at Balder.Core.Execution.TypeDiscoverer..ctor() at Balder.Core.Execution.Runtime.GetRuntime() at Balder.Core.Execution.Runtime.get_Instance() at Balder.Core.Execution.Game..ctor() [Line: 0 Position: 0] --- Inner Exception --- Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.Module.GetTypes(IntPtr module, StackCrawlMark& stackMark) at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at System.Reflection.Module.GetTypes(StackCrawlMark& stackMark) at System.Reflection.Assembly.GetTypes() at Balder.Core.Execution.TypeDiscoverer..ctor() at Balder.Core.Execution.Runtime.GetRuntime() at Balder.Core.Execution.Runtime.get_Instance() at Balder.Core.Execution.Game..ctor() --- End of inner exception stack trace --- at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at SimpleModelRenderer.MainPage.InitializeComponent() at SimpleModelRenderer.MainPage..ctor()}

Don't you know, what am I doing wrong?

Coordinator
May 11, 2010 at 7:56 AM

That was a very strange exception, I see were it fails but don't understand why.

Is it possible for you to send your project to me?  (einar _at_ dolittle _dot_ com)

May 11, 2010 at 1:00 PM

It is, yet you won't be able to run it without some software. I'll try to make small app to demonstrate this exception, and then will send it to you.

May 11, 2010 at 7:44 PM

I've fixed this issue. It seems there was some mess with references to assemblys.

Coordinator
May 12, 2010 at 6:05 AM

Great to hear - I was starting to get worried. :)

May 12, 2010 at 11:14 AM

Recreated the sollution from scratch and exception uppeared again (

sent you email