1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Si Sun |
---|
24 | * |
---|
25 | */ |
---|
26 | #include "OrxonoxStableHeaders.h" |
---|
27 | #include "Map.h" |
---|
28 | |
---|
29 | #include <string> |
---|
30 | #include <OgreSceneManager.h> |
---|
31 | #include <OgreSceneNode.h> |
---|
32 | #include <OgreEntity.h> |
---|
33 | #include <OgreOverlay.h> |
---|
34 | #include <OgreOverlayElement.h> |
---|
35 | #include <OgreOverlayManager.h> |
---|
36 | #include <OgreOverlayContainer.h> |
---|
37 | #include "core/CoreIncludes.h" |
---|
38 | #include "core/ConfigValueIncludes.h" |
---|
39 | #include "core/ConsoleCommand.h" |
---|
40 | #include "objects/Scene.h" |
---|
41 | |
---|
42 | namespace orxonox |
---|
43 | { |
---|
44 | CreateFactory(Map); |
---|
45 | SetConsoleCommand(Map, openMap, true); |
---|
46 | |
---|
47 | Map::Map(BaseObject* creator) : OrxonoxOverlay(creator) |
---|
48 | { |
---|
49 | RegisterObject(Map); |
---|
50 | |
---|
51 | //Getting Scene Manager (Hack) |
---|
52 | ObjectList<Scene>::iterator it = ObjectList<Scene>::begin(); |
---|
53 | this->sManager_ = it->getSceneManager(); |
---|
54 | |
---|
55 | this->sNode_ = new Ogre::SceneNode(sManager_); |
---|
56 | oManager_ = Ogre::OverlayManager::getSingletonPtr(); |
---|
57 | overlay_ = oManager_->create("Map"); |
---|
58 | //overlay_ is member of OrxonoxOverlay |
---|
59 | |
---|
60 | //Not Showing the map as default |
---|
61 | this->isVisible_=false; |
---|
62 | overlay_->hide(); |
---|
63 | |
---|
64 | //TestEntity |
---|
65 | Ogre::Entity * ent = sManager_->createEntity("ent", "drone.mesh"); |
---|
66 | sNode_->attachObject( ent ); |
---|
67 | sNode_->setPosition(0,0,-50); |
---|
68 | overlay_->add3D(sNode_); |
---|
69 | } |
---|
70 | |
---|
71 | void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode) |
---|
72 | { |
---|
73 | SUPER(Map, XMLPort, xmlElement, mode); |
---|
74 | } |
---|
75 | |
---|
76 | void Map::toggleVisibility() |
---|
77 | { |
---|
78 | if (!(this->isVisible_)) |
---|
79 | { |
---|
80 | this->overlay_->show(); |
---|
81 | this->isVisible_=1; |
---|
82 | } |
---|
83 | else |
---|
84 | { |
---|
85 | this->overlay_->hide(); |
---|
86 | this->isVisible_=0; |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | //Static function to toggle visibility of the map |
---|
91 | void Map::openMap() |
---|
92 | { |
---|
93 | for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin(); |
---|
94 | it!=ObjectList<orxonox::Map>::end(); |
---|
95 | it++) |
---|
96 | { |
---|
97 | //Map * m = it->getMap(); |
---|
98 | COUT(0) << it->isVisible_ << std::endl; |
---|
99 | it->toggleVisibility(); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | void Map::tick(float dt) |
---|
104 | { |
---|
105 | sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z); |
---|
106 | |
---|
107 | } |
---|
108 | |
---|
109 | } |
---|