Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/bsp_entity.cc @ 10230

Last change on this file since 10230 was 10114, checked in by patrick, 18 years ago

merged network back to trunk

File size: 2.9 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: Claudio Botta
13   co-programmer: ...
14*/
15
16#include "bsp_entity.h"
17
18#include "debug.h"
19#include "loading/resource_manager.h"
20
21
22ObjectListDefinition(BspEntity);
23CREATE_FACTORY(BspEntity);
24
25
26/**
27 * constructs and loads a BspEntity from a XML-element
28 * @param root the XML-element to load from
29 */
30BspEntity::BspEntity(const TiXmlElement* root)
31{
32  this->init();
33
34  if (root != NULL)
35    this->loadParams(root);
36}
37
38
39/**
40 * standard deconstructor
41 */
42BspEntity::~BspEntity ()
43{
44  if( this->bspManager != NULL)
45    delete this->bspManager;
46}
47
48
49
50/**
51 * initializes the BspEntity
52 * @todo change this to what you wish
53 */
54void BspEntity::init()
55{
56  this->registerObject(this, BspEntity::_objectList);
57
58  this->bspManager = NULL;
59
60  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
61
62  this->setSynchronized( true );
63}
64
65
66void BspEntity::setName(const std::string& name)
67{
68  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
69
70  this->name = name;
71
72  // Check wether file exists....
73  if ( File(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(name)).exists()  ) {
74
75    this->bspManager = new BspManager(this);
76
77    if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) {
78      this->bspManager = NULL;
79
80    } else {
81      this->toList(OM_ENVIRON); // Success!!!
82    }
83  } else {
84    this->bspManager = NULL;
85    this->toList(OM_DEAD);
86  }
87}
88
89
90/**
91 * loads a BspEntity from a XML-element
92 * @param root the XML-element to load from
93 * @todo make the class Loadable
94 */
95void BspEntity::loadParams(const TiXmlElement* root)
96{
97  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
98  // WorldEntity::loadParam(root);
99
100  LoadParam(root, "Name", this, BspEntity, setName)
101  .describe("Sets the of the BSP file.");
102
103  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
104        .describe("Sets the scale factore of the bsp level.");
105  */
106
107  /**
108   * @todo: make the class Loadable
109   */
110}
111
112
113/**
114 * advances the BspEntity about time seconds
115 * @param time the Time to step
116 */
117void BspEntity::tick(float time)
118{
119  this->bspManager->tick(time);
120}
121
122
123/**
124 * draws this worldEntity
125 */
126void BspEntity::draw () const
127{
128  this->bspManager->draw();
129}
130
131
132/**
133 *
134 *
135 */
136void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
137{}
138
139void BspEntity::varChangeHandler( std::list< int > & id )
140{
141  if ( std::find( id.begin(), id.end(), this->name_handle ) != id.end() )
142  {
143    this->setName( this->name_write );
144  }
145}
Note: See TracBrowser for help on using the repository browser.