Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

merged network back to trunk

File size: 2.9 KB
RevLine 
[4838]1/*
[1853]2   orxonox - the future of 3D-vertical-scrollers
[9406]3
[1853]4   Copyright (C) 2004 orx
[9406]5
[1853]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.
[9406]10
[1855]11   ### File Specific:
[8490]12   main-programmer: Claudio Botta
[1855]13   co-programmer: ...
[1853]14*/
15
[8081]16#include "bsp_entity.h"
[1853]17
[9869]18#include "debug.h"
19#include "loading/resource_manager.h"
[8087]20
[10114]21
22ObjectListDefinition(BspEntity);
[9869]23CREATE_FACTORY(BspEntity);
[8087]24
[9869]25
[3564]26/**
[8490]27 * constructs and loads a BspEntity from a XML-element
[4838]28 * @param root the XML-element to load from
29 */
[8490]30BspEntity::BspEntity(const TiXmlElement* root)
[4483]31{
32  this->init();
[8490]33
[4838]34  if (root != NULL)
35    this->loadParams(root);
[4483]36}
37
38
39/**
[4838]40 * standard deconstructor
41 */
[8490]42BspEntity::~BspEntity ()
[3566]43{
[9003]44  if( this->bspManager != NULL)
[8490]45    delete this->bspManager;
[3566]46}
47
[8087]48
[9003]49
[3762]50/**
[8490]51 * initializes the BspEntity
[4838]52 * @todo change this to what you wish
53 */
[8490]54void BspEntity::init()
[4483]55{
[9869]56  this->registerObject(this, BspEntity::_objectList);
[5509]57
[9003]58  this->bspManager = NULL;
[9406]59
[9656]60  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
[9406]61
[9059]62  this->setSynchronized( true );
[8490]63}
[5509]64
[8490]65
66void BspEntity::setName(const std::string& name)
67{
68  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
[9406]69
[9059]70  this->name = name;
[8490]71
[9003]72  // Check wether file exists....
[9869]73  if ( File(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(name)).exists()  ) {
[9003]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  }
[4483]87}
88
[5509]89
[4483]90/**
[8490]91 * loads a BspEntity from a XML-element
[4838]92 * @param root the XML-element to load from
93 * @todo make the class Loadable
94 */
[8490]95void BspEntity::loadParams(const TiXmlElement* root)
[4483]96{
[4838]97  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
[9003]98  // WorldEntity::loadParam(root);
[8087]99
[8490]100  LoadParam(root, "Name", this, BspEntity, setName)
[9003]101  .describe("Sets the of the BSP file.");
[4483]102
[9003]103  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
104        .describe("Sets the scale factore of the bsp level.");
105  */
[5509]106
107  /**
108   * @todo: make the class Loadable
109   */
[4483]110}
111
112
113/**
[8490]114 * advances the BspEntity about time seconds
[4838]115 * @param time the Time to step
116 */
[8490]117void BspEntity::tick(float time)
[3762]118{
[8490]119  this->bspManager->tick(time);
[3762]120}
121
[8081]122
[3245]123/**
[4838]124 * draws this worldEntity
125 */
[8490]126void BspEntity::draw () const
[4838]127{
[8081]128  this->bspManager->draw();
[3559]129}
[5509]130
131
132/**
133 *
134 *
135 */
[8490]136void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
[9003]137{}
[9059]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.