Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/mount_points/src/world_entities/mount_point.cc @ 10239

Last change on this file since 10239 was 10239, checked in by patrick, 17 years ago

found a bug in the object information resources file. fixed

File size: 3.8 KB
Line 
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
28ObjectListDefinition(MountPoint);
29
30
31/**
32 * construct
33 */
34MountPoint::MountPoint (const Vector& up, const Vector& forward, const Vector& center, const std::string& name)
35{
36  PRINTF(0)("Created mount point %s\n", name.c_str());
37
38  this->_name = name;
39  this->setAbsCoor( center);
40  this->setAbsDir( Quaternion(forward, up));
41
42  this->init();
43}
44
45
46
47/**
48 * deconstructor
49 */
50MountPoint::~MountPoint ()
51{}
52
53
54/**
55 * initializing function
56 */
57void MountPoint::init()
58{
59  this->registerObject(this, MountPoint::_objectList);
60  this->toList(OM_GROUP_00);
61
62  this->_mount = NULL;
63}
64
65
66/**
67 * loads the Settings of a MD2Creature from an XML-element.
68 * @param root the XML-element to load the MD2Creature's properties from
69 */
70void MountPoint::initMountPoint(const TiXmlElement* root)
71{
72  const TiXmlElement* element = root->FirstChildElement("MountPoints");
73  if( element == NULL)
74  {
75    PRINTF(1)("Object Information file is missing a proper 'MountPoints' section\n");
76  }
77  else
78  {
79    element = element->FirstChildElement();
80    // parse the information for this mount point
81
82    PRINTF(4)("Loading WorldEntities\n");
83    while( element != NULL)
84    {
85      std::string name = element->Value();
86
87      // check if we got the right mount point
88      if( name == this->_name)
89      {
90        // load it
91        this->loadParam(element);
92      }
93
94      element = element->NextSiblingElement();
95    }
96  }
97}
98
99
100
101/**
102 * load the parameters from the xml section
103 * @param root the root element of this xml branche
104 */
105void MountPoint::loadParam(const TiXmlElement* root)
106{
107  // first check for the description
108  LoadParam(root, "Description", this, MountPoint, setDescription)
109  .describe("Sets this mount point a description");
110
111  // now check for the orx class to create
112  LoadParam(root, "OrxClass", this, MountPoint, setOrxClass)
113  .describe("Sets the class this mount points should host");
114}
115
116
117
118/**
119 * setst the description (optional) via xml tag
120 * @param description string containing the description
121 */
122void MountPoint::setDescription(const std::string& description)
123{
124  this->_description = description;
125}
126
127
128
129/**
130 * sets the class of this mount point
131 * @param orxClass class
132 */
133void MountPoint::setOrxClass(const std::string& orxClass)
134{
135  // create the object for this mount point
136  BaseObject* obj = Factory::fabricate(orxClass);
137  // check if the object is created correctly
138  if( this->_mount != NULL)
139  {
140    if( obj->isA( WorldEntity::staticClassID()))
141    {
142      this->_mount = dynamic_cast<WorldEntity*>(obj);
143    }
144  }
145  else
146    PRINTF(1)("Couldn't create %s for this mount point (%s)\n", orxClass.c_str(), this->_name.c_str());
147}
148
149
150
151/**
152 * tick
153 * @param time  time passed since the last tick
154 */
155void MountPoint::tick (float time)
156{
157
158}
159
160
161/**
162 * draw this entity
163 */
164void MountPoint::draw() const
165{
166}
167
168
169
170/**
171 *  function called to draw the mount point itself for debug purposes only
172 */
173void MountPoint::debugDraw() const
174{
175  // invoke the underlying pnode debug draw
176  this->debugDraw();
177}
178
179
180/**
181 * adds an entity to this mount point
182 * @param entity entity to be added
183 */
184void MountPoint::mount(WorldEntity* entity)
185{
186  this->_mount = entity;
187}
188
189
190/**
191 * removes an entity from this mount point
192 */
193void MountPoint::unmount()
194{
195  this->_mount = NULL;
196}
197
Note: See TracBrowser for help on using the repository browser.