我有一个场景图,我有:如何遍历场景图形树状结构?
class Node
{
public:
struct
{
COLLISION_TYPE collisionType;
void* boundingVolume;
}collisionData;
struct
{
XMFLOAT3 position;
XMFLOAT3 rotation;
}leafData;
Node(Model* representModel, Node* parentNode)
{
this->parentNode = parentNode;
this->representModel = representModel;
this->collisionData.collisionType = representModel->collisionDataDefault.collisionType;
this->collisionData.boundingVolume = &representModel->collisionDataDefault.boundingVolumeDefault;
};
~Node()
{
};
std::vector< std::vector<XMFLOAT3*> > GetChildTransformStream()
{
};
void Transform(XMMATRIX *world)
{
};
Model* representModel;
Node* parentNode;
std::vector<Node*> childNodes;
};
所以在变换方法我要变换的节点的坐标和那些所有它的孩子,所以我必须先得到所有列表有GetChildTransformStream的孩子,但我不知道如何遍历它,因为它可以有任意数量的子节点,并且它们可以有任意数量的子节点等等。你通常如何处理这个问题?
通过深度优先搜索或广度优先搜索。如果它实际上是一个图表,则保存访问的节点列表。你有什么尝试? – OmnipotentEntity
我试过循环._。 – user1777994
我以为有一些普遍接受的处理场景图的方法,所以我就这么问了xD – user1777994