XNA content pipeline importer questions

Hi,

I am new to XNA and C# as well. I am using the code from here (http://andyq.no-ip.com/blog/ p=16) to get a bounding box information. However it crashes at when I do the following ->

box = (BoundingBox)myModel.Tag;

I have added the custom importer dll to the properties tab under the content pipeline tab. I cant figure out why its giving this error saying object reference not set to an object.




Answer this question

XNA content pipeline importer questions

  • Yawei

    As well as adding the custom processor DLL, you need to make sure the properties for your mesh asset are set to use this custom processor.


  • Keith Chapman

    Hey,

    Thanks for the information. Got the bounding box working. Now to only figure out how to get the triangle information out of the model.



  • shades921

    It's pretty much the same idea. In your custom Content Processor, override the Processs() method. In there cast the NodeContent input to MeshContent. The following snippet returns a List<Vector3> of each of the positions of the mesh. Then you can do whatever you want with the vertex soup.

    private List<Vector3> GetAllVerticies(MeshContent mesh)

    {

    List<Vector3> MeshVerts = new List<Vector3>();

    for (int g = 0; g < mesh.Geometry.Count; g++)

    {

    GeometryContent geometry = mesh.Geometry[ g ];

    for (int ind = 0; ind < geometry.Indices.Count; ind++)

    {

    // Transforms all of my verticies to local space.

    Vector3 position = Vector3.Transform(geometry.Vertices.Positions[geometry.Indices[ind]], mesh.AbsoluteTransform);

    MeshVerts.Add(position);

    }

    }

    return MeshVerts;

    }



  • mark.b

    [moved thread to xna forum]

  • XNA content pipeline importer questions