Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

mount point xml file parsing and object creation

File size: 3.6 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);
29CREATE_FACTORY(MountPoint);
30
31
32/**
33 * construct
34 */
35MountPoint::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 */
51MountPoint::~MountPoint ()
52{}
53
54
55/**
56 * initializing function
57 */
58void 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 */
71void 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      std::string name = element->Value();
87
88      // check if we got the right mount point
89      if( name == this->_name)
90      {
91        // load it
92        this->loadParam(element);
93      }
94
95      element = element->NextSiblingElement();
96    }
97  }
98}
99
100
101
102/**
103 * load the parameters from the xml section
104 * @param root the root element of this xml branche
105 */
106void MountPoint::loadParam(const TiXmlElement* root)
107{
108   LoadParam(root, "description", this, WorldEntity, setDescription)
109    .describe("Sets this mount point a description");
110
111
112   LoadParam(root, "OrxClass", this, WorldEntity, 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  this->_mount = Factory::fabricate(orxClass);
137  // check if the object is created correctly
138  if( this->_mount == NULL)
139    PRINTF(1)("Couldn't create %s for this mount point (%s)\n", orxClass.c_str(), this->_name.c_str());
140}
141
142
143
144/**
145 * tick
146 * @param time  time passed since the last tick
147 */
148void MountPoint::tick (float time)
149{
150
151
152}
153
154
155/**
156 * draw this entity
157 */
158void MountPoint::draw() const
159{
160
161}
162
163
164
165/**
166 *  function called to draw the mount point itself for debug purposes only
167 */
168void MountPoint::debugDraw() const
169{
170  // invoke the underlying pnode debug draw
171  this->debugDraw();
172}
173
174
175/**
176 * adds an entity to this mount point
177 * @param entity entity to be added
178 */
179void MountPoint::mount(WorldEntity* entity)
180{
181  this->_mount = entity;
182}
183
184
185/**
186 * removes an entity from this mount point
187 */
188void MountPoint::unmount()
189{
190  this->_mount = NULL;
191}
192
Note: See TracBrowser for help on using the repository browser.