Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10147 in orxonox.OLD for trunk/src/world_entities/world_entity.cc


Ignore:
Timestamp:
Dec 25, 2006, 1:30:44 PM (17 years ago)
Author:
patrick
Message:

merged the mount_point branche back to trunk to use the new std::* based obj file importer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/world_entity.cc

    r10013 r10147  
    1212
    1313   ### File Specific:
    14    main-programmer: Patrick Boenzli
    15    co-programmer: Christian Meyer
     14   main-programmer: Patrick Boenzli, Benjamin Grauer
     15   co-programmer: Christian Meier
    1616*/
    1717#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     
    2424#include "md2/md2Model.h"
    2525#include "md3/md3_model.h"
     26
     27#include "oif/object_information_file.h"
     28#include "mount_point.h"
    2629
    2730#include "aabb_tree_node.h"
     
    6972  this->damage = 0.0f; // no damage dealt by a default entity
    7073  this->scaling = 1.0f;
     74  this->oiFile = NULL;
    7175
    7276  /* OSOLETE */
     
    103107  for (unsigned int i = 0; i < this->models.size(); i++)
    104108    this->setModel(NULL, i);
     109
     110  // remove the object information file
     111  if( this->oiFile)
     112    delete this->oiFile;
     113  // and clear all monut points
     114  this->mountPoints.clear();
    105115
    106116  // Delete the obbTree
     
    191201    {
    192202      PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str());
     203      // creating the model and loading it
    193204      StaticModel* model = new StaticModel();
    194205      *model = ResourceOBJ(fileName, this->scaling);
     
    201212      else
    202213        delete model;
     214
     215      // now get the object information file for this model, if any
     216      std::string oifName = fileName.substr(0, fileName.length() - 4) + ".oif";
     217      this->loadObjectInformationFile( oifName);
    203218    }
    204219    /// LOADING AN MD2-model
     
    249264
    250265
     266
     267/**
     268 * loads the object information file for this model
     269 * @param fileName the name of the file
     270 */
     271void WorldEntity::loadObjectInformationFile(const std::string& fileName)
     272{
     273  PRINTF(4)("loading the oif File: %s\n", fileName.c_str());
     274
     275  this->oiFile = new ObjectInformationFile(fileName);
     276}
     277
     278
    251279/**
    252280 * builds the obb-tree
     
    290318  }
    291319  return true;
     320}
     321
     322
     323/**
     324 * adds a mount point to the end of the list
     325 * @param mountPoint point to be added
     326 */
     327void WorldEntity::addMountPoint(MountPoint* mountPoint)
     328{
     329  // add the mount point at the last position
     330  this->mountPoints.push_back(mountPoint);
     331}
     332
     333/**
     334 * adds a mount point to a world entity
     335 * @param mountPoint point to be added
     336 */
     337void WorldEntity::addMountPoint(int slot, MountPoint* mountPoint)
     338{
     339  if( this->mountPoints[slot] != NULL)
     340  {
     341    PRINTF(0)("adding a mount point to a slot, that already exists! ignoring - maybe some object do not get connected well (object: %s)\n", this->getClassCName());
     342  }
     343
     344  // just connect the mount point
     345  this->mountPoints[slot] = mountPoint;
     346}
     347
     348
     349/**
     350 * mounts a world entity on a specified mount point (~socket)
     351 * @param entity entity to be connected
     352 */
     353void WorldEntity::mount(int slot, WorldEntity* entity)
     354{
     355  if( this->mountPoints[slot] == NULL)
     356  {
     357    PRINTF(0)("you tried to add an entity to a mount point that doesn't exist (slot %i)\n", slot);
     358    return;
     359  }
     360
     361  // mount the entity
     362  this->mountPoints[slot]->mount(entity);
     363}
     364
     365
     366/**
     367 * removes a mount point from a specified mount point
     368 * @param mountPoint entity to be unconnected
     369 */
     370void WorldEntity::unmount(int slot)
     371{
     372    if( this->mountPoints[slot] == NULL)
     373  {
     374    PRINTF(0)("you tried to remove an entity from a mount point that doesn't exist (slot %i)\n", slot);
     375    return;
     376  }
     377
     378  // unmount the entity
     379  this->mountPoints[slot]->unmount();
    292380}
    293381
Note: See TracChangeset for help on using the changeset viewer.