Maerius

Hello everyone!

I'm rather new to the XNA as well to this Forum, so please don't neglect my tricky thinking and poor language usage abilities :D.

I want to take adventages of Content Pipeline, but I'd like to simulate it's work in runtime. I tried to understand the internal mechanism using Reflector, but the code unsuprisingly overhelms me.

I need to build a mesh in runtime. MeshBuilder is nice, but it produces MeshContent as a result. How to simulate this design-time process in runtime This would make the debugging of custom importers much easier as well.

I'd be grateful for any help and tips.

p.s. Sorry if such a question has already appeared in this forum and I missed it.


Re: XNA Game Studio Express How to build a mesh in runtime?

Joel Martinez

You could look and see how the XNA Content Builder works.

Also, debugging custom importers and processors can be accomplished by simply putting this line of code wherever you want to break:

System.Diagnostings.Debugger.Launch();

When that line executes, it will pop up and prompt you to either use an existing debugger instance, or launch a new one.





Re: XNA Game Studio Express How to build a mesh in runtime?

Maerius

System.Diagnostics.Debugger.Launch() made the debugging easier. I used to use a bit more complicated method... Thanks.

XNA Content Builder uses the Microsoft.Build to simulate the whole Visual Studio build process. Something tells me it's not the proper way to build a mesh in runtime.

Some time ago I wrote a very handy class, similiar to the XNA version of MeshBuilder, which (in opposite to XNA) created Mesh object (XNA's MeshModel substitute) directly (which wasn't such a sophisticated solution as Content Pipeline is). I was unpleasantly suprised when I've discovered that XNA's MeshBuilder produces MeshContent - not Model. In addition, Model and MeshModel cannot be manually instantiated, which forces me to the direct use of Vertex~ and IndexBuffers, which, seems to be not a wonderful idea having available Mesh/Model classes already implemented and tested.

I really don't know what to do now.




Re: XNA Game Studio Express How to build a mesh in runtime?

Joel Martinez

Maerius wrote:
System.Diagnostics.Debugger.Launch() made the debugging easier. I used to use a bit more complicated method... Thanks.
Would you mind sharing your debugging technique





Re: XNA Game Studio Express How to build a mesh in runtime?

Shawn Hargreaves - MSFT

The XNA content pipeline, and associated types like the Model class, fundamentally requires that data be prepared ahead of time in a build step. There is no way to create a new Model instance at runtime.

If your game is only for Windows, you could use the content build task as Joel pointed out, doing the "build" step on the fly as part of your game. That won't work on Xbox, though.

If you absolutely need to create new meshes on the fly in an Xbox game, you'll have to write your own model class to do this.





Re: XNA Game Studio Express How to build a mesh in runtime?

Maerius

I meant Debug->Attach to Process... from VS "not Express". "Complicated" is the wrong word - "annoying" would be better ;)



Re: XNA Game Studio Express How to build a mesh in runtime?

Maerius

Thanks. That solves the case :)

Writing an own Model class is not a bad idea - XNA eases the usage of the most common scenarios (load and use), but it enables the implementation of the advanced solutions. Nothing is impossible having VertexBuffer, IndexBuffer and Effect classes :D (as for now I'll better avoid runtime mesh generation and sorting mesh parts by the technique).

Thanks once again.