OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: DumpingNodeTree
View page
Source of version: 5
(current)
From __Kojack__ ([http://www.ogre3d.org/phpBB2/viewtopic.php?t=7881|original thread]): Thought some of you might find this handy. I'd wiki it, but never tried doing that before so I posted it here first. :) This a function which recursively traverses a node hierarchy and builds a string containing the names of every node and the names/types of every attached object, with indenting by recursive level. {CODE(wrap="1", colors="c++")} void DumpNodes(std::stringstream &ss, Ogre::Node *n, int level) { for(int i = 0; i < level; i++) { ss << " "; } ss << "SceneNode: " << n->getName() << std::endl; Ogre::SceneNode::ObjectIterator object_it = ((Ogre::SceneNode *)n)->getAttachedObjectIterator(); Ogre::Node::ChildNodeIterator node_it = n->getChildIterator(); Ogre::MovableObject *m; while(object_it.hasMoreElements()) { for(int i = 0; i < level + 2; i++) { ss << " "; } m = object_it.getNext(); ss << m->getMovableType() << ": " << m->getName() << std::endl; } while(node_it.hasMoreElements()) { DumpNodes(ss, node_it.getNext(), level + 2); } } std::string DumpNodes(Ogre::Node *n) { std::stringstream ss; ss << std::endl << "Node Hierarchy:" << std::endl; DumpNodes(ss, n, 0); return ss.str(); }{CODE} The second DumpNodes is the one you call, the first one is just used by the second. You can call it like this in your code: {CODE(wrap="1", colors="c++")}LogManager::getSingleton().logMessage(Ogre::LML_NORMAL, QGF4::DumpNodes(m_scene_manager->getRootSceneNode()).c_str());{CODE} The result in the log will look like: {CODE(wrap="1", colors="c++")}Node Hierarchy: SceneNode: SceneRoot SceneNode: Physics Debug NX SimpleRenderable: SimpleRenderable2 SimpleRenderable: SimpleRenderable3 SceneNode: Physics Debug ODE SimpleRenderable: SimpleRenderable0 SceneNode: Unnamed_10 SimpleRenderable: SimpleRenderable4 SceneNode: Unnamed_7 Entity: ground SceneNode: Unnamed_9 Entity: gir SceneNode: Unnamed_8 Entity: box3{CODE} One of the reasons why I wrote this (mid last year or so) was so I could call it from a game console window, to see what the current scene was. But I never got around to making the console work (I had text input which was passed directly to Lua as source code, but no output). :) But I did end up using it with some of my students to debug stuff, like doing a node dump every time a certain key is pressed, then reading the log to see what changed each time. From __Falagard__: Just thought I'd mention that in addition to this, the DotSceneInterface has a serializer that can serialize a scene to an xml file as well, which includes meshes, lights, etc. Obviously, it's more complicated so might be overkill, and this one looks like a nice clean function for quick debugging.
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
24 online users