XNA (nor D3D) does not expose any kind of API-side matrix stack.
There is not that much of a difference between a scene graph visitor that uses the OpenGL matrix stacks and a visitor that maintains its own private stacks.
class GLStyleVisitor
{
public void visit(GroupNode node)
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix(glGetMatrix() * node.mtx);
foreach (Node child in node.children)
{
visit(child);
}
glPopMatrix();
}
}
The traditional visitor shown above doesn't have to be changed much to bundle its own stack or any other context along when visiting the graph. At any place inside the visitor, you have access to the state you need for passing into whoever needs it.
class PersonalVisitor
{
Stack<Matrix> transforms;
public PersonalVisitor()
{
transforms.push(Matrix.Identity());
}
public void visit(GroupNode node)
{
transforms.push(transforms.top() * node.mtx);
foreach (Node child in node.children)
{
Visit(child);
}
transforms.pop();
}
}
Note that class names and methods are not overly accurate, as I am not fluent in C# or XNA.