1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific |
---|
12 | main-programmer: Patrick Boenzli patrick@orxonox.net |
---|
13 | co-programmer: |
---|
14 | */ |
---|
15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
16 | |
---|
17 | |
---|
18 | #include "executor/executor.h" |
---|
19 | #include "util/loading/factory.h" |
---|
20 | #include "util/loading/load_param.h" |
---|
21 | |
---|
22 | |
---|
23 | #include "mount_point.h" |
---|
24 | #include "debug.h" |
---|
25 | #include "state.h" |
---|
26 | |
---|
27 | |
---|
28 | ObjectListDefinition(MountPoint); |
---|
29 | CREATE_FACTORY(MountPoint); |
---|
30 | |
---|
31 | |
---|
32 | /** |
---|
33 | * construct |
---|
34 | */ |
---|
35 | MountPoint::MountPoint (const Vector& up, const Vector& forward, const Vector& center, const std::string& name) |
---|
36 | { |
---|
37 | PRINTF(0)("Created mount point %s\n", name.c_str()); |
---|
38 | |
---|
39 | this->_name = name; |
---|
40 | this->setAbsCoor( center); |
---|
41 | this->setAbsDir( Quaternion(forward, up)); |
---|
42 | |
---|
43 | this->init(); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | /** |
---|
49 | * deconstructor |
---|
50 | */ |
---|
51 | MountPoint::~MountPoint () |
---|
52 | {} |
---|
53 | |
---|
54 | |
---|
55 | /** |
---|
56 | * initializing function |
---|
57 | */ |
---|
58 | void MountPoint::init() |
---|
59 | { |
---|
60 | this->registerObject(this, MountPoint::_objectList); |
---|
61 | this->toList(OM_GROUP_00); |
---|
62 | |
---|
63 | this->_mount = NULL; |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | /** |
---|
68 | * loads the Settings of a MD2Creature from an XML-element. |
---|
69 | * @param root the XML-element to load the MD2Creature's properties from |
---|
70 | */ |
---|
71 | void MountPoint::initMountPoint(const TiXmlElement* root) |
---|
72 | { |
---|
73 | const TiXmlElement* element = root->FirstChildElement("MountPoints"); |
---|
74 | if( element == NULL) |
---|
75 | { |
---|
76 | PRINTF(1)("Object Information file is missing a proper 'MountPoints' section\n"); |
---|
77 | } |
---|
78 | else |
---|
79 | { |
---|
80 | element = element->FirstChildElement(); |
---|
81 | // parse the information for this mount point |
---|
82 | |
---|
83 | PRINTF(4)("Loading WorldEntities\n"); |
---|
84 | while( element != NULL) |
---|
85 | { |
---|
86 | BaseObject* created = Factory::fabricate(element); |
---|
87 | if( created != NULL ) |
---|
88 | PRINTF(4)("Created a %s: %s\n", created->getClassCName(), created->getCName()); |
---|
89 | |
---|
90 | //todo do this more elegant |
---|
91 | if( element->Value() == "SkyBox" && created->isA(SkyBox::staticClassID())) |
---|
92 | { |
---|
93 | this->sky = dynamic_cast<WorldEntity*>(created); |
---|
94 | State::setSkyBox(dynamic_cast<SkyBox*>(this->sky)); |
---|
95 | } |
---|
96 | if( element->Value() == "Terrain" && created->isA(Terrain::staticClassID())) |
---|
97 | { |
---|
98 | this->terrain = dynamic_cast<Terrain*>(created); |
---|
99 | CDEngine::getInstance()->setTerrain(terrain); |
---|
100 | } |
---|
101 | element = element->NextSiblingElement(); |
---|
102 | this->glmis->step(); //! @todo temporary |
---|
103 | } |
---|
104 | PRINTF(4)("Done loading WorldEntities\n"); |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | /** |
---|
111 | * tick |
---|
112 | * @param time time passed since the last tick |
---|
113 | */ |
---|
114 | void MountPoint::tick (float time) |
---|
115 | { |
---|
116 | |
---|
117 | |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | /** |
---|
122 | * draw this entity |
---|
123 | */ |
---|
124 | void MountPoint::draw() const |
---|
125 | { |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | /** |
---|
132 | * function called to draw the mount point itself for debug purposes only |
---|
133 | */ |
---|
134 | void MountPoint::debugDraw() const |
---|
135 | { |
---|
136 | // invoke the underlying pnode debug draw |
---|
137 | this->debugDraw(); |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | /** |
---|
142 | * adds an entity to this mount point |
---|
143 | * @param entity entity to be added |
---|
144 | */ |
---|
145 | void MountPoint::mount(WorldEntity* entity) |
---|
146 | { |
---|
147 | this->_mount = entity; |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | /** |
---|
152 | * removes an entity from this mount point |
---|
153 | */ |
---|
154 | void MountPoint::unmount() |
---|
155 | { |
---|
156 | this->_mount = NULL; |
---|
157 | } |
---|
158 | |
---|