Rendering meshes?

Topics: General
Mar 21, 2007 at 5:09 AM
Hey. How would I go about rendering meshes? I know that they are "stored", I need to be able to render them to the screen.

I know that I would have to add this myself (Partly becuase I am sure you have other things to do and partly becuase I have done heavy modifications to the code) but any general pointers in the right direction would be great :).

Right now my current idea is to :

A) Add a new item in the LevelContent class to store my meshes.
B) Write code to translate the meshes from the LeadWrks class to the LevelContent class in the level processor.
C) Write code in LevelWriter to transfer the LevelContent meshes to the "output" and write code in LevelReader to transfer the "output" to the level.
D) Write code in the level class to render the meshes to the screen.

Am I on the right track?

Thanks :).
Coordinator
Mar 21, 2007 at 7:10 PM
It's a more concrete plan than I've got now :)

I want to do a couple things:
- Store information needed for rendering and culling
- Use the existing content pipeline to import build meshes
- Use the existing ModelConent classes to render meshes

I'm stuck on a couple of other small things first, and I don't know how to handle surface descriptions (materials) but that's my idea.
Mar 21, 2007 at 9:32 PM
My idea is that if I can get the name of the model and the transformation matrices then I can just write code to load the .X model like a texture.

So we don't get the mesh data from the level (as there is no point) we just get the position, scale, rotation, name of the mesh and then load a model that way.

I will let you know if I make progress in this area :).
Mar 23, 2007 at 6:03 AM
Hey. How do you debug the custom importer? Breakpoints don't seem to work :\.
Mar 24, 2007 at 7:29 AM
Well what a productive day ^^. I have the mesh data somewhat loaded into my level class.

What I did was first I reimplemented the mesh and the meshreference case into the Level importer. I couldn't figure out how to get the correct number of bytes from the meshes so what I did was I just read all the data I wanted and then seeked the rest (Basically I just threw the rest away as I didn't know what to do wih it).

Your mesh and meshreference classes had some errors with the name array (you need to subtract 1) so I fixed them.

I then wrote a new method to process the meshes in the Leadwrks processor class. This basically takes the mesh array and creates a new "LevelMesh" array all the while transfering the data that I want to save.

Then I wrote a writer and a reader for my "LevelMesh" class. I added code in the LevelWriter to write my LevelMesh array.

Finally I added a LevelMesh list to my Level class and added code in the LevelReader to get the LevelMesh array.

The data I saved is simply the position, the transformation matrix, and the file name of the .X file. I will write code to then render this .X file to the screen...

I might have to do more work on it, but it is a start :).
Coordinator
Mar 27, 2007 at 3:45 AM
Thanks - I did read these notes and make some changes to both the checked in and not-so checked in code :) I dislike how the .3dw stores some things in 0-based arrays and others in 1-based, I haven't had meshes working since I decided to do -1 everywhere instead of adding a blank item to my string array.

Thanks a bunch for the helpful notes, and about debugging the importer, uncomment the appropriately marked comments in the Importer or Processor classes and you'll be asked for a debugger session during content builds. Make sure you have real VS.NET or the free VS.NET Debugger installed first! Your break points will be set and caught in that instance of VS (or the debugger of your choice), not the instance of GSE/C# Express hosting the content build.
Mar 27, 2007 at 12:01 PM
Hi :). I just used my logger class for debugging and it worked fine.

I am implementing collision detection right now and then I am going to try to get lightmaps working ;).