source: trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp @ 59

Revision 59, 4.2 KB checked in by mattausch, 20 years ago (diff)

completely changed file structure plus software design

RevLine 
[59]1#include "OgreSceneNodeHierarchyInterface.h"
2#include <OgreIteratorWrappers.h>
3#include <OgreCamera.h>
4#include <OgreSceneNode.h>
5
6//#include <windows.h>
7
8namespace Ogre {
9
10//-----------------------------------------------------------------------
11SceneNodeHierarchyInterface::SceneNodeHierarchyInterface(SceneManager *sm, RenderSystem *rsys):
12PlatformHierarchyInterface(sm, rsys)
13{               
14}
15//-----------------------------------------------------------------------
16void SceneNodeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node)
17{
18        mNumTraversedNodes ++;
19       
20        SceneNode *sceneNode = static_cast<SceneNode *>(node);
21
22        if (HasGeometry(node))
23        {
24                RenderNode(node);
25        }
26
27        // internal node: add children to priority queue for further processing
28        Node::ChildNodeIterator it = sceneNode->getChildIterator();
29                               
30        while (it.hasMoreElements())                   
31        {
32                mDistanceQueue->push(it.getNext());
33        }
34}
35//-----------------------------------------------------------------------
36void SceneNodeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node)
37{
38#ifdef GTP_VISIBILITY_MODIFIED_OGRE
39        SceneNode *sceneNode = static_cast<SceneNode *>(node);
40
41        if (sceneNode->lastRendered() != sceneNode->lastVisited())
42        {
43                sceneNode->setLastRendered(sceneNode->lastVisited());
44                mNumRenderedNodes ++;
45
46                mSceneManager->_renderSceneNode(mCamera, sceneNode);
47        }
48#endif
49}
50//-----------------------------------------------------------------------
51bool SceneNodeHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node)
52{
53        return (static_cast<SceneNode *>(node)->numChildren() == 0);
54}
55//-----------------------------------------------------------------------
56bool SceneNodeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node)
57{
58        SceneNode *sceneNode = static_cast<SceneNode *>(node);
59       
60        return sceneNode->numAttachedObjects() > 0;
61}
62//-----------------------------------------------------------------------
63void SceneNodeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node)
64{
65#ifdef GTP_VISIBILITY_MODIFIED_OGRE
66        SceneNode *sceneNode = static_cast<SceneNode *>(node);
67
68        while(sceneNode && !sceneNode->isNodeVisible())
69        {
70                sceneNode->setNodeVisible(true);
71                sceneNode = sceneNode->getParentSceneNode();
72        }
73#endif
74}
75//-----------------------------------------------------------------------
76bool SceneNodeHierarchyInterface::HasGreaterDistance(GtpVisibility::HierarchyNode *node1,
77                                                                                                         GtpVisibility::HierarchyNode *node2)
78{
79        SceneNode *sceneNode1 = static_cast<SceneNode *>(node1);
80        SceneNode *sceneNode2 = static_cast<SceneNode *>(node2);
81
82        return sceneNode1->getSquaredViewDepth(mCamera) > sceneNode2->getSquaredViewDepth(mCamera);
83}
84//-----------------------------------------------------------------------
85void SceneNodeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node,
86                                                                                                 const bool visible)
87{
88#ifdef GTP_VISIBILITY_MODIFIED_OGRE
89        SceneNode *sceneNode = static_cast<SceneNode *>(node);
90        sceneNode->setNodeVisible(visible);
91#endif
92}
93//-----------------------------------------------------------------------
94void SceneNodeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, const int frameId)
95{
96#ifdef GTP_VISIBILITY_MODIFIED_OGRE
97        SceneNode *sceneNode = static_cast<SceneNode *>(node);
98        sceneNode->setLastVisited(frameId);
99#endif
100}
101//-----------------------------------------------------------------------
102bool SceneNodeHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node)
103{
104#ifdef GTP_VISIBILITY_MODIFIED_OGRE
105        SceneNode *sceneNode = static_cast<SceneNode *>(node);
106        return sceneNode->isNodeVisible();
107#else
108        return true;
109#endif
110}
111//-----------------------------------------------------------------------
112int SceneNodeHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node)
113{
114#ifdef GTP_VISIBILITY_MODIFIED_OGRE
115        SceneNode *sceneNode = static_cast<SceneNode *>(node);
116        return sceneNode->lastVisited();
117#else
118        return 0;
119#endif
120}
121//-----------------------------------------------------------------------
122AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node)
123{
124        SceneNode *sceneNode = static_cast<SceneNode *>(node);
125        return &mBox;
126}
127} // namespace Ogre     
Note: See TracBrowser for help on using the repository browser.