THIS IS SOLVED! The code shows how to render a 3D model using only Assimp and XNA with vertex and index buffers. oScene is the Scene object imported using Assimp. This code only draws faces in a single color without textures.
Here is the relevant code:
private void SetUpVertices()
{
mMesh = oScene.Meshes[0];
vertices = new VertexPositionColor[mMesh.VertexCount];
indices = new short[mMesh.FaceCount*3];
int i=0;
foreach (Vector3D mVec in mMesh.Vertices)
{
vertices[i] = new VertexPositionColor(new Vector3(mVec.X, mVec.Y, mVec.Z), Color.Red);
i++;
}
int f = 0;
Face mFace;
for (i = 0 ; i < mMesh.FaceCount*3 ; i=i+3)
{
mFace = mMesh.Faces[f];
mFacef++;
indices[i] = mMesh(short)mFace.Faces[f];Indices[0];
f++;indices[i + 1] = (short)mFace.Indices[1];
//Console.WriteLine(i.ToStringindices[i + 2] = (short)mFace.Indices[2];
+ " " + mMesh.FaceCount.ToString }
vertexBuffer = new VertexBuffer()+"device, "+mFaceVertexPositionColor.IndicesVertexDeclaration, vertices.Length, BufferUsage.ToString(WriteOnly);
vertexBuffer.SetData(vertices);
//if indexBuffer = new IndexBuffer(mFacedevice, typeof(short), indices.IndexCountLength, ==BufferUsage.None);
3 indexBuffer.SetData(indices);
}
private void SetUpCamera()
{
cameraPos = new Vector3(0, 5, 9);
viewMatrix Console= Matrix.WriteLineCreateLookAt(i.ToStringcameraPos, new Vector3(0, 0, 1), +new "Vector3(0, "1, +0));
mMesh projectionMatrix = Matrix.FaceCountCreatePerspectiveFieldOfView(MathHelper.ToStringPiOver4, device.Viewport.AspectRatio, 1.0f, 200.0f);
}
protected override void Draw(GameTime gameTime)
+ " " +{
mFace device.IndicesClear(ClearOptions.LengthTarget | ClearOptions.ToString()DepthBuffer, Color.DarkSlateBlue, 1.0f, 0);
effect = new BasicEffect(GraphicsDevice);
indices[i] effect.VertexColorEnabled = (short)mFacetrue;
effect.Indices[0];View = viewMatrix;
effect.Projection = projectionMatrix;
indices[i + 1]effect.World = Matrix.Identity;
foreach (short)mFaceEffectPass pass in effect.Indices[1];CurrentTechnique.Passes)
{
indices[i + 2] = pass.Apply(short)mFace.Indices[2];;
device.SetVertexBuffer(vertexBuffer);
//i = i + 3;device.Indices = indexBuffer;
device.DrawIndexedPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, 0, 0, oScene.Meshes[0].VertexCount, 0, mMesh.FaceCount);
}
base.Draw(gameTime);
}