This project is read-only.

XNAnimation Library - I've modified the processor to implement Triangle Picking but animation cracks the vertices information

Aug 18, 2008 at 5:55 PM


      I've modified the XNAnimation  to store the Vertices and BoundingSphere information. Integrating that with the Triangle Picking sample when the model is static (no animations configured to it)  the picking works fine, but when starting animations clips the Vertex (triangles) information does not Update correctly. In the code from the SkinnedModelProcessor I've aded the code bellow in the lines bold commented with  //ADICIONADO - MARCELO. Anyone that knows the XNAnimation Lib can help with integrate it with the  Creator's Club Triangle Picking Sample? Thanks, Marcelo Corni Alves

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

public override SkinnedModelContent Process(NodeContent input, ContentProcessorContext context)
if (input == null)
throw new ArgumentNullException("input");

if (dumpHierarchyEnabled)
DumpHierarchy(input, context);
if (dumpAnimations)
DumpAnimations(input, context);

BoneContent rootBone = MeshHelper.FindSkeleton(input);
ValidateModel(input, rootBone, context);

// Transform scene according to user defined rotation and scale

// Processes model's meshes
ProcessMeshes(input, context);

// Process model's materials
ProcessMaterials(input, context);


// Processes model's skeleton
SkinnedModelBoneContentCollection skinnedModelBoneCollection =
ProcessBones(rootBone, context);

// Processes model's animations
AnimationClipContentDictionary animationClipDictionary =
ProcessAnimations(input, rootBone.Animations, skinnedModelBoneCollection, context);

// Uses the default model processor
ModelContent modelContent =
context.Convert<NodeContent, ModelContent>(input, "ModelProcessor");

Dictionary<string, object> tagData = new Dictionary<string, object>();

modelContent.Tag = tagData;

// Store vertex information in the tag data, as an array of Vector3.
tagData.Add("Vertices", vertices.ToArray());

// Also store a custom bounding sphere.
tagData.Add("BoundingSphere", BoundingSphere.CreateFromPoints(vertices));

// Return a new skinned model
return new SkinnedModelContent(modelContent, skinnedModelBoneCollection,

public void FindVertices(NodeContent node)
// Is this node a mesh?
MeshContent mesh = node as MeshContent;

if (mesh != null)
// Look up the absolute transform of the mesh.
Matrix absoluteTransform = mesh.AbsoluteTransform;

// Loop over all the pieces of geometry in the mesh.
foreach (GeometryContent geometry in mesh.Geometry)
// Loop over all the indices in this piece of geometry.
// Every group of three indices represents one triangle.
foreach (int index in geometry.Indices)
// Look up the position of this vertex.
Vector3 vertex = geometry.Vertices.Positions[index];

// Transform from local into world space.
vertex = Vector3.Transform(vertex, absoluteTransform);

// Store this vertex.

// Recursively scan over the children of this node.
foreach (NodeContent child in node.Children)