VertexBuffers and IndexBuffers

Hi All!

I am very new to the XNA framework, I have experience with DirectX and thought that XNA would be an easy challenge. I was wrong - I obviously lack something here.

I have been able to create a VertexBuffer with several (repeated) vertices and put it on the screen. Although I have not yet been able to do perspective or lighting*, this is not my main concern.

I wish to use an IndexBuffer object to store the list of vertices in the order that I want them rendered. I cannot figure out the method of doing this. I realise there are other ways of loading meshes, but this is the way I want to do it. I am reading a .off file (I don't want to convert it to a .x file -- I think there are tools out there, but no no no!!!), but currently I am just staticly testing a box.

Is there any tutorial or anything out there to help? The documentation is shockingly small (and no IndexBuffers!)

Any help would be greatly appriciated.
-Qjay

*I have a tutorial on parallax mapping (I don't know if I'm allowed to reference the site, so I won't, but just do a search for that topic and uncle ziggy will sort you out - he doesn't use IndexBuffers either)

[1178 byte] By [qjay] at [2007-12-24]
# 1

1. Start XNA Game Studio Express

2. Click on Help->Index

3. Choose XNA at the "Filtered by"-Field

4. Type in "IndexBuffer" at the "Look for"-Field.

5. Choose "IndexBuffer class"

6. READ

You simply create it the same way you did with the vertexbuffer...you use the constructor

You draw your primitive then with DrawIndexedPrimitive instead of DrawPrimitive

Shinzo-Prime at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 2
Wow please grant me even the slightest insight into your great wisdom. I'm trying to find a little help not glare straight into the face of the obvious. I know how to use the BUILT IN HELP MENUS. The description of the class does not lend itself towards it's usage OR how it needs to be added to the graphics device. Believe it or not, I actually TRIED using the help before I made this post, so your option number 6 has already been done ;)

Oh and thanks for the "use the constructor" advice. Where would I be without you telling me that in OBJECT - ORIENTATED programming systems one would actually have to call the constructor of the object to create it.

As for DrawIndexedPrimitive, yes I can respect that, but like I said, I've used DirectX, and I know it will be similar in the XNA framework as it's built on DirectX (I can state the obvious too)

I was wondering if there is anyone out there who has ACTUALLY tried using the IndexBuffers and succeeded. I have yet to find a tutorial on this (meaning it would be nice to see a working example) and as I have mentioned I have looked on the built in help, and believe it or not I have searched the internet and will continue to do so.

So thanks a million
-Qjay

qjay at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 3
The SpaceWar example uses index buffers, check out the SimpleMeshRenderer class.
Leaf. at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 4
Thanks I will I'll let you know by monday if I'm successful
qjay at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 5
Nope Unfortuantely they are reading in something else, and the SimpleMesh is very strange class... I will look at it a bit more but for now I'm going to experiment with other things. I will post my code soon. I'm currently getting the blue screen of death :)
qjay at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 6
We'll try to provide better examples of using vertex and index buffers together in the docs. The SimpleMeshRenderer in Spacewar should give you an idea of how to use these types along with VertexDeclaration, Effect and GraphicsDevice.DrawIndexedPrimitives.
MitchWalker-MSFT at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 7
That would be great. Unfortunately the code in spacewar is everywhere... gonna take me a couple of days to figure out. I think I'll stay in 2D for the time being :)
qjay at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...