Reading the vertex data from the opaquedata in a content processor.

My question is really how would this be accomplished

I asked earlier how to write a custom processor, and now I've got one, but I'm not sure how to get vertex data, or certain vertices out of the NodeContent and put it into the ModelContent.

I'm trying to do this for precisely the kind of thing that was demonstrated in the "Gamefest Content Pipeline Demo" video. I would like to read certain marker batch vertices to be able to give me access to that data for placement of other meshes on top of a base mesh at the right spot. I would be much appreciative for help with this! :)



Answer this question

Reading the vertex data from the opaquedata in a content processor.

  • TrussworksLeo1

    The right way to know that it's a MeshContent is to use "as".

    MeshContent isMesh = theNode as MeshContent;
    if (isMesh != null) {
    Do Mesh Stuff
    }

    Also, a better way to debug a running content processor (even if you haven't inserted the call to debugger launch) is to attach to the VCExpress.exe process using some other debugger, such as another instance of VCExpress, or VS2005. Open the file in the second debugger instance, set a breakpoint, and then start the build in the first instance. When it gets to the breakpoint, it will break into the second instance.

    I prefer this to hard-coding the debugger launch, because I may have lots of assets to build, but only want to debug asset building once in a while (or for some specific asset).



  • Darren1

    Thanks! That was pretty helpful, but what about debugging processors Is there a good way to do that at the moment
  • NytewolfAU2k7

    I'm guessing you should be able to get this from some sort of debugger content -- possibly by implementing the above debugging suggestion.  I have yet to design a content processor and therefore are unfamiliar with any debugging limitations, so my apologies if this is way off!


  • Brazzle

    Put a call to System.Diagnostics.Debugger.Launch() in your processor, at the point where you want to start debugging it. This will bring up a debugger launch window, from which you should be able to select the CLR debugger.



  • Pat1111

    Greg Christensen wrote:

    I'm guessing you should be able to get this from some sort of debugger content -- possibly by implementing the above debugging suggestion. I have yet to design a content processor and therefore are unfamiliar with any debugging limitations, so my apologies if this is way off!

    I haven't quite gotten that working yet either. It seems to want to open my regular copy of visual studio, so there is probably something I don't have set right...


  • aborchik

     Shawn Hargreaves - MSFT wrote:
    If you have derived from ModelProcessor, your Process method will be passed a NodeContent instance. This is the root of a tree of node objects. You need to scan down the tree, checking for any entries of type MeshContent. If you find any, cast them to MeshContent, and then look up their Geometry property. There are a lot of different properties on MeshContent and GeometryContent that will give you all the data of the mesh.

    I tried this and was not successful...how do you know if it's a MeshContent type  

    I tried something like so:

     

    public Vector3 FindAVertex(NodeContent input)

    {

    foreach (NodeContent N in input.Children)

    {

    if (N.GetType() == typeof(MeshContent))

    {

    MeshContent MC = (MeshContent)(N);

    return MC.Geometry[0].Vertices.Positions[0];

    }

    else FindAVertex(N);

    }

    return new Vector3(69.0f);

    }

     

    But I always get the vector with 69, meaning it didn't find a vertex.   My guess here is that it is because N would always be NodeContent.   I'm not quite sure how you tell...

     

    EDIT: Actually I just noticed a really stupid bug in this whole thing.  I will look into it tomorrow and see if I still am having this problem...


  • ksona

    I apologize for bumping this, but I still haven't found a suitable answer.

    How do I get the vertex data from the ModelProcessor I would assume it's in the OpaqueData, but when I try something like OpaqueData. Also, I'm not sure how to go about debugging these processors as my breakpoints don't seem to be hitting...


  • David Hubbard

    Most excellent! Thanks a lot! :)
  • D J Mitchell

    If you have derived from ModelProcessor, your Process method will be passed a NodeContent instance. This is the root of a tree of node objects. You need to scan down the tree, checking for any entries of type MeshContent. If you find any, cast them to MeshContent, and then look up their Geometry property. There are a lot of different properties on MeshContent and GeometryContent that will give you all the data of the mesh.


  • Reading the vertex data from the opaquedata in a content processor.